Improve skills, capture context & knowledge
Analyze the current conversation to improve skills, fix codebase gaps, capture durable knowledge, and generate handoff prompts for skills managed outside this repository.
Run /improve at the end of any session where:
git rev-parse --show-toplevel 2>/dev/null | head -1find agents/skills -maxdepth 2 -name SKILL.md 2>/dev/null | head -30cat context/knowledge/index.md 2>/dev/null | head -30When /improve is invoked:
Scan the full conversation for:
/pdf, /review, /test, etc.)/pdf, data export workflows)List each skill used with a brief note on what it did in this session.
Note: If improvements were already applied earlier in the same session (e.g., from manual fixes or a prior /improve run), skip those and only propose net-new changes.
For each skill identified, analyze:
For each skill with proposed changes, determine where it lives:
~/.claude/skills/<name>/SKILL.md)git rev-parse --show-toplevelDefault: local project. All improvements and new skills target the current project unless there is a strong reason to modify an external skill. When an external skill needs changes, generate a handoff prompt (Step 5) -- do not edit it even if you have write access.
For each skill with learnings, draft specific changes:
--input flag for existing files")Code-over-skills check: Before proposing any change that adds inline scripts (bash, Ruby, Python, data transformations, API calls, or parsing logic) to a SKILL.md, check whether the project CLAUDE.md has rules about where logic should live (e.g., "code over skills", "capture reusable logic in CLI commands"). If it does, do NOT add the script to the skill. Instead, route it to Step 7 (Fix Codebase Gaps) as a missing CLI command. The skill improvement becomes: "reference the new CLI command" rather than "embed the script."
Present each proposed change as a before/after diff for the user to review.
For local skills (default path):
For external skills (handoff only -- never edit directly): Generate a copy-pasteable handoff prompt for each external skill with changes. The prompt should:
Format:
## Skill Improvement Handoff: /<skill-name>
**Skill location:** <real path to SKILL.md>
**Source repo:** <git repo that owns the skill>
### Proposed Changes
1. **<change type>: <title>** -- <description>
- Before: <relevant excerpt>
- After: <proposed replacement>
2. ...
### Context
<1-3 sentences explaining what session behavior motivated these changes>
Print each handoff prompt inside a fenced code block so the user can copy it into a session working in the skill source repo.
Review the full session for patterns that are not covered by any existing skill but would benefit from one. Look for:
/improve itself -- if the user described a capability gap when invoking /improve, treat that as a direct signalOnly propose a skill if it passes at least two of these criteria:
For each new skill opportunity, present:
**Proposed Skill: /<name>**
- **What it does:** <1-2 sentence description>
- **Trigger:** When would a user invoke this? What keywords or situations?
- **Key steps:** <numbered list of what the skill would instruct the agent to do>
- **Dynamic context needed:** <what live data the skill would inject, if any>
- **Cross-project or local?** <local (default) or cross-project with rationale>
After the user approves a proposal:
/write-skill <name> -- <description> to create it following established patterns and validation rules. If /write-skill is not available, create the SKILL.md directly in the repo skills directory./write-skill there.New skills default to the local project. Only propose creating a skill in an external repo if the skill is clearly cross-project and not specific to the current codebase -- and in that case, generate a handoff prompt instead of creating it directly.
Review the session for codebase gaps that were discovered or worked around but not fixed. These are issues in the project itself (not in skills):
For each gap found:
Only fix gaps that were actually encountered during the session. Do not speculatively audit the codebase.
Part A: Operational Context
Review the session for extractable operational context:
Update existing context files in context/ directory as appropriate. Create new files as needed for distinct topics. Update CLAUDE.md if the context applies broadly across tasks.
Part B: Knowledge Graph
Check whether the current project has a knowledge base by looking for context/knowledge/index.md (shown in the Context section above).
If no knowledge base exists, skip Part B entirely. Do not suggest creating one, do not update auto memory, do not fall back to any alternative. Just move on.
If a knowledge base exists, review the session for durable knowledge worth preserving:
The knowledge base uses structured topic files with an index. To add knowledge:
context/knowledge/index.md to see existing topics and coveragePart C: Knowledge Graph Gap Analysis
Proactively identify knowledge graph gaps -- entities, topic files, or categories the session revealed that do not yet exist. This goes beyond "capture what was discussed" to "suggest what should be tracked."
Scan for uncaptured entities: Compare entities mentioned in this session against the knowledge index. Flag any that were discussed substantively but have no entry.
Suggest new topic files: If session content does not fit cleanly into existing knowledge files, propose a new topic file. Include:
Identify missing entity types or relationship types: If the session surfaced entities or relationships that do not fit existing categories, propose additions to the taxonomy.
Check coverage map staleness: Scan the Coverage Map section of index.md for:
context/ but are not listed in the coverage mapReport as a "Knowledge Gaps" section in the improvement report:
## Knowledge Gaps Identified
### Uncaptured Entities
- **[Entity Name]** -- mentioned as [role/context], no knowledge entry exists
- Suggested file: [existing-file.md] or [new-file.md]
### New Topic File Proposals
- **[filename.md]** -- [description]. Seed entities: [list].
- Why: [why existing files are not the right home]
### Taxonomy Gaps
- New entity type: `[type]` -- [definition]. Examples: [from session or KB]
- New relationship type: `[type]` -- [definition]. Examples: [from session or KB]
### Stale Coverage
- `context/[file].md` -- exists but not in coverage map
- `knowledge/[file].md` -- last updated [date], touched in this session -> update date
Only report gaps that are actionable and non-trivial. Do not flag every passing mention -- focus on entities with enough substance to warrant a knowledge entry.
Do NOT capture:
Note: The /improve skill itself is in scope for improvement. If this session revealed friction in the improve workflow, include it in the report.
After all improvements are identified, assess which could benefit other engineers beyond this personal repo. Not everything is personal -- some fixes and patterns are generic.
For each improvement applied or proposed in this session, classify:
Decision criteria:
Report format:
## Upstream Sharing Assessment
### Candidates for upstream starter
- **[improvement]** -- [why it is generic]
### Candidates for team-wide plugin
- **[improvement]** -- [why it is team-wide]
### Personal only
- **[improvement]** -- [why it is personal]
Generate handoff prompts for any upstream candidates the user approves. Use the same format as Step 5 handoffs.
/knowledge init instead# Session Improvement Report
## Skills Used
1. `/review` -- Ran code review on authentication refactor (2 iterations)
2. `/test` -- Ran tests, discovered missing edge case coverage
3. `/pdf` -- Exported summary to PDF
## Proposed Improvements
### /review -- 1 change (local, applying directly)
1. **Add: Retry on lint timeout** -- Review step stalled when linter timed out.
Add a 60-second timeout with retry.
### /pdf -- 2 changes (external: personal dotfiles)
Handoff prompt generated below.
### New Skill Proposal: /coverage-report
**Proposed Skill: /coverage-report**
- **What it does:** Run tests, parse coverage output, and highlight untested lines in changed files.
- **Trigger:** After writing code, when checking test coverage for a PR or branch.
- **Key steps:** 1. Identify changed files on branch. 2. Run test suite with coverage. 3. Parse coverage report. 4. Show untested lines in changed files only.
- **Dynamic context needed:** Changed files list, test runner config.
- **Cross-project or local?** Cross-project (handoff to personal repo).
Create with /write-skill? (y/n)
## Codebase Gaps Fixed
1. **AGENTS.md: Missing component** -- Component was used but not listed.
Added row to the table.
## External Skill Handoffs
[copy-pasteable handoff prompt for /pdf]
## Knowledge Captured
Added to context/knowledge/infrastructure.md:
- Authentication service requires X-Request-ID header for all endpoints
Updated context/knowledge/index.md:
- infrastructure.md Last Updated -> 2026-02-27
## Knowledge Gaps Identified
### Uncaptured Entities
- **Nautical Bowls** -- mentioned as case study with metrics, no entry
- Suggested file: merchant-accounts.md
### Taxonomy Gaps
- New entity type: `case_study` -- A merchant success story with quantified outcomes.
Examples: Nautical Bowls (38% activation), Nothing Bundt Cakes ($125M+ loyalty revenue)
### Stale Coverage
- `context/ordering-positioning.md` -- exists but not in coverage map
## Upstream Sharing Assessment
### Candidates for upstream starter
- **write-skill dynamic context fix** -- generic, every fork inherits broken find commands
### Candidates for team-wide plugin
- (none this session)
### Personal only
- **Custom workflow skill** -- references specific org context
Handoff prompt for starter repo generated below.
## Apply all? (y/n)
Each /improve run should leave the system measurably better than it found it. The goal is not just fixing friction today -- it is building a system that compounds: each session learnings reduce friction in all future sessions.