From mtk
Reflects on a finished session to capture discovered commands, gotchas, and patterns as minimal append-only additions to CLAUDE.md, applied only with approval.
How this skill is triggered — by the user, by Claude, or both
Slash command
/mtk:claude-md-captureThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```!
echo "--- Writable CLAUDE.md files ---"
{ find . -maxdepth 6 -name CLAUDE.md -not -path "./.git/*" -not -path "*/node_modules/*" 2>/dev/null; } | sort -u
echo "--- Personal (gitignored) ---"
test -f .claude.local.md && echo ".claude.local.md (present)" || echo ".claude.local.md (absent — create for personal-only notes)"
echo "--- Line budget of root CLAUDE.md ---"
test -f CLAUDE.md && echo "CLAUDE.md: $(wc -l < CLAUDE.md) lines (root cap 120)" || echo "(no root CLAUDE.md — run /mtk-setup first)"
A session often surfaces context that CLAUDE.md was missing — a build command you had to discover, a gotcha you hit, an env quirk, a pattern the codebase follows. That knowledge should compound into project memory so the next session starts where this one ended. This skill reflects on the finished session, drafts minimal additions, shows them as diffs, and applies only what the engineer approves.
It is distinct from its two siblings:
claude-md-audit re-grades what is already in CLAUDE.md against a rubric
and fixes rot. Capture adds new knowledge this session produced.correction-capture records engineer corrections as reusable lessons in
lessons.md. Capture records project facts (commands, gotchas, env) into
CLAUDE.md — the prompt every session loads.It honors S1.5 (CLAUDE.md is protected): append-only by default, Edit never
Write, no additions applied before approval.
/mtk-setup (runs setup-bootstrap)claude-md-auditcorrection-capture (writes a lesson,
not a CLAUDE.md fact)Review the session. What context, had it been in CLAUDE.md at the start, would have saved time? Look specifically for:
If none of these came up, stop here and tell the engineer there is nothing worth capturing.
| Destination | When |
|---|---|
CLAUDE.md (committed, team-shared) | Project facts every contributor and agent benefits from |
.claude.local.md (gitignored, personal) | Your own preferences, local-only paths, machine-specific setup |
Heuristic: first-person preference ("I like to run…") → personal. Project fact
("tests must run with --runInBand due to shared DB state") → team. When in
doubt, propose it as personal.
For monorepos, prefer the nearest package CLAUDE.md when the fact is local
to one package; only put cross-cutting facts in the root file.
Before drafting, grep the target file (and tasks/lessons.md) for the keyword.
If the fact is already documented, do not re-add it — update the existing line
only if it is now wrong.
grep -in "<keyword>" CLAUDE.md .claude.local.md tasks/lessons.md 2>/dev/null
One line per concept. CLAUDE.md is part of the prompt — brevity is the whole
point. Format: `<command or pattern>` — <brief description> and match the
existing file's style (table vs bullet list — do not impose a new structure).
Avoid: verbose explanations, restating what the code already says, generic best practices, and one-off fixes unlikely to recur.
Mind the budget: the root CLAUDE.md cap is 120 lines. If an addition would push
it over, propose moving detail to the relevant .claude/rules/ file instead, or
drop the lowest-value candidate.
Stop before any edit. For each candidate, show where it goes, the diff, and one line of why it helps future sessions.
### Addition 1 → ./CLAUDE.md (Gotchas section)
**Why:** Tests silently corrupt each other without --runInBand; future sessions
would re-discover this the hard way.
\`\`\`diff
+ Tests must run sequentially (`pytest --runInBand`) — shared DB state.
\`\`\`
Then ask: "Apply these? (yes / partial / no)"
After explicit approval, apply with Edit (never Write). Append into the
relevant section; never restructure. If the engineer approved "partial", apply
only the named subset. If a personal item was chosen and .claude.local.md does
not exist, create it (it is gitignored by setup-bootstrap — verify it is
listed in .gitignore before creating; add it if missing).
Edit, never Write on CLAUDE.md (S1.5 protected-file rule)..claude/rules/.See .claude/skills/context-engineering/SKILL.md for the shared MTK table.
Capture-specific traps:
claude-md-audit's job, gated on its own rubric. Capture appends; it does
not refactor..claude.local.md content committed (it must stay gitignored)Edit with explicit old/new strings (never Write).claude.local.md, not the committed fileGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub moberghr/mtk-agent-toolkit --plugin mtk