Self-Improve
Review the current conversation to extract durable lessons and route each one to the right knowledge layer.
Step 1: Detect Context
Available destinations:
- Project CLAUDE.md / AGENTS.md — The root
.claude/CLAUDE.md(may be a symlink to../AGENTS.md— resolve it), plus any nestedCLAUDE.md/AGENTS.mdfiles in subdirectories. Claude Code loads a subdirectory's file on demand when files in that subtree are accessed, so a lesson scoped to one subtree belongs in the nearest enclosing file, with the root reserved for project-wide rules. - Auto memory — The project-specific memory directory at
~/.claude/projects/<project-hash>/memory/. ReadMEMORY.mdthere if it exists. - Skills — Project skills at
skills/or.claude/skills/(resolve symlinks)
Discover the project CLAUDE.md/AGENTS.md files (the root file and any nested ones in subdirectories) and read them, then read MEMORY.md. List all skill directories but do not read them yet — Step 2 needs to run first so you know what to look for.
Turbo Skill Detection
Read ~/.turbo/config.json for repoMode. If repoMode is "fork" or "source", turbo skill improvements can be contributed upstream.
If ~/.turbo/repo/ exists, identify which installed skills are turbo skills:
- List directories in
~/.turbo/repo/claude/skills/ - Any skill in
~/.claude/skills/that has a matching directory in~/.turbo/repo/claude/skills/is a turbo skill - Skills only in
~/.claude/skills/(no match in the repo) are user/project skills
Verification rule (mandatory before routing in Step 4): For every candidate skill that is about to be routed as turbo, confirm with a fresh test -d ~/.turbo/repo/claude/skills/<name> check that the skill actually lives in the turbo repo. Do not rely on remembered listings from earlier in the session, filename hits in grep output, or assumptions based on where a SKILL.md was read from. A miss here mislabels a user/project skill as turbo, triggers the contribution flow unnecessarily, and can introduce session-specific content into a shared skill — so the check is not optional.
Exception: If the current project IS the turbo repo (i.e., the working directory contains this skill collection), route turbo skill lessons through the Existing user/project skill destination in Step 4 — edits go directly to claude/skills/<name>/ in the project, with no installed-copy indirection and no contribution flow.
Step 2: Identify Session Skills and Scan for Lessons
Identify Session Skills
Before scanning for lessons, identify which skills were loaded during this session:
- Scan the conversation for Skill tool invocations and SKILL.md reads from
~/.claude/skills/ - Build a list of session skills, marking each as turbo or user/project skill (using the detection from Step 1)
- This list informs routing in Step 4: when a lesson clearly arose from a specific skill's workflow, that skill is the natural routing target
Scan for Lessons
Scan the full conversation with this priority:
- Corrections — Where the user interrupted, said "no", "actually", "stop", "not like that", redirected, or manually fixed something Claude did wrong. Highest-value lessons.
- Repeated guidance — Instructions the user gave more than once.
- Skill-shaped knowledge — Domain expertise that was needed repeatedly, tool/API integration details that had to be looked up, decision frameworks that emerged for evaluating options, content templates or writing conventions that were refined, and multi-step workflows where ordering mattered (as reusable domain knowledge, not the workflow itself — see #4).
- New workflows — Did this session establish a novel multi-step procedure, coordination pattern, or automation that worked? A successful workflow that would need to be repeated is a prime skill candidate — even if it ran fine this time. Distinct from #3: this captures the procedure itself as a repeatable artifact, not knowledge about how to do it. Flag it.
- Preferences — Formatting, naming, style, or tool choices the user expressed.
- Failure modes — Approaches that failed, with what worked instead. For tool or script call failures, trace back to the information source that led to the error and route the fix there (e.g., clarify a reference file, update skill instructions, add missing documentation).
- Domain knowledge — Facts or conventions Claude needed but did not have.
- Improvement opportunities — Out-of-scope improvements noticed during work: code that could be refactored, missing tests, performance issues, readability concerns, or feature ideas that were intentionally skipped to stay focused. Skipped findings count here: when code simplification or code review identified a genuine improvement or issue but it was skipped for this session, route it as a project improvement so it isn't lost.
- Trusted reviewer feedback — Human PR review comments that reveal project conventions, patterns, or corrections. Trusted reviewers are repo collaborators with
adminormaintainroles (determine viagh api repos/{owner}/{repo}/collaborators --jq '.[] | select(.role_name == "admin" or .role_name == "maintain") | .login'). Their feedback takes precedence over other reviewers and AI bots when there are contradictions.
After scanning, read all skill SKILL.md files (they are small). This gives Step 4 full context for routing.
Step 3: Filter
Keep only lessons that are:
- Stable — likely to remain true across future sessions
- Non-obvious — Claude would not already know this
- Actionable — can be expressed as a rule or instruction
- Not already documented — absent from the files read in Step 1. A lesson documented only in an unrelated subtree's CLAUDE.md/AGENTS.md still counts as undocumented for the subtree it actually applies to.
- Still a concern — the issue is not already fixed by changes made in this session. If a bug was found and fixed, or a missing feature was added, future sessions will see the corrected code — they don't need a reminder about the old problem. Exception: successful workflows and procedures are not "resolved" — they're skill candidates precisely because they worked and will need to be repeated.
Discard anything session-specific, speculative, one-off, or already resolved by code changes in this session (but not successful workflows — see exception above). If no lessons survive filtering, tell the user and stop.
Step 4: Route Each Lesson
Assign each surviving lesson to exactly one destination.
Skill-first rule (mandatory): Before consulting the table below, check whether the lesson corrects, refines, or adds a guardrail to any existing skill's behavior — turbo or user/project. This includes lessons about skipping steps, wrong defaults, missing edge cases, or any "don't do X when running /skill-name" correction. If yes, route to that skill. Do not route skill corrections to auto memory or CLAUDE.md — they belong in the skill they correct. This rule is not a preference; it is a hard constraint that takes precedence over the table rows below.
| Destination | Criteria |
|---|---|
| Project improvements | Actionable improvement to existing code: refactoring, performance, reliability, readability, testing, or DX. Not for documentation fixes — factual errors in CLAUDE.md belong in the Project CLAUDE.md / AGENTS.md row. Route to .turbo/improvements.md via the /note-improvement skill. |
| Auto memory | Discovered knowledge with no skill home: API quirks, debugging workarounds, compiler gotchas, tool pitfalls, user preferences. Must not overlap with any existing skill's domain — if it does, route to the skill instead (see skill-first rule above). |
| Project CLAUDE.md / AGENTS.md | Intentional project decisions: conventions, architecture, stack choices, build setup, module boundaries. Also factual corrections to CLAUDE.md content (wrong comman |