When an engineer corrects your approach, that correction contains knowledge that should compound across sessions. Capture it immediately, process it into a reusable lesson, and ensure it loads in future sessions. The goal: the engineer should never need to give the same correction twice.
-
Recognize the correction. Look for:
- Direct negation: "no", "don't", "stop", "wrong"
- Redirection: "instead do X", "use Y not Z", "the pattern here is..."
- Frustration signal: "I already said", "again", "like I mentioned"
-
Acknowledge without performing. State what you understand changed:
- "Understood — I'll use X instead of Y because [reason]."
- Do not say "You're absolutely right!" or "Great point!" — just state the correction and act on it.
-
Decide where it belongs — personal or team. Two destinations:
.claude/lessons/personal.md (gitignored) — default. Personal preferences, individual workflow tweaks, "I prefer X here".
tasks/lessons.md (committed) — team-wide rules. Architectural patterns, repeated team-wide mistakes, conventions every contributor should follow.
Heuristic:
- First-person language ("I", "my", "for me") → personal.
- References to team/architecture/codebase patterns ("the team's...", "we always...", "this codebase uses...") → ask before writing to team file.
- When in doubt → personal. Promotion to team is explicit via
/promote-lesson.
-
Check for prior lessons. Before capturing, grep both files for keywords related to this correction. If a similar lesson already exists, update it instead of duplicating.
grep -i "<keyword>" .claude/lessons/personal.md tasks/lessons.md 2>/dev/null
When replacing an existing lesson (vs. appending), write to a temp file and promote via mtk_guarded_write so a partial regenerate cannot truncate the file. Pure appends are safe — append never shrinks.
If the grep finds a lesson that contradicts the new one (not a duplicate — an actual reversal of prior guidance), do not silently append a second, conflicting rule. Capture the new lesson with --supersedes <old-id>: the old entry stays for the audit trail but learnings.sh query stops surfacing it, so retrieval never returns two rules that disagree. A duplicate of the same rule is different — that just increments recurrence.count.
-
Capture the lesson — structured + markdown.
a. Structured (preferred when scripts/learnings.sh is present). Append a JSONL entry to .mtk/learnings.jsonl (gitignored, machine-readable). Then regenerate the markdown view:
LS="scripts/learnings.sh"; [ -f "$LS" ] || LS="${CLAUDE_PLUGIN_ROOT:-.}/scripts/learnings.sh"
bash "$LS" add \
--workflow "${MTK_WF_UUID:-manual}" \
--scope "personal|team" \
--source correction \
--decision-origin "claude-recommended-rejected|claude-recommended-modified|user-directed" \
--severity "info|warn|block" \
--phase "spec|plan|implement|review|any" \
--files "comma,separated,paths" \
--title "Short title" \
--body "What the engineer said" \
--rule "The reusable rule extracted" \
--applies-when "When this rule should activate" \
--wrong-turns "dead end A,dead end B" \
--time-cost 12 \
--evolution-actions "routing|claude_md|reference|hook|none" \
--memory-type "episodic|semantic|procedural" \
--supersedes "L-old-id"
bash "$LS" regen-markdown
Schema: .claude/references/learnings-schema.md.
b. Markdown fallback (older repos without learnings.sh). Append to the chosen file (create .claude/lessons/ if missing). Resolve path to main worktree if in a worktree.
## [Date] — [Short title]
**Correction:** [What the engineer said]
**Rule:** [The reusable rule extracted from the correction]
**Why:** [Why this matters — the underlying principle]
**Applies to:** [When this rule should activate in future work]
**Wrong turns:** [Dead ends tried this session, so they aren't repeated — omit if none]
**Time cost:** [Rough minutes lost — omit if not measurable]
**Evolution:** [Which toolkit asset you changed because of this: routing / CLAUDE.md / a reference / a hook / none-and-why]
The structured form enables 5-layer retrieval (proximity / recurrence / severity / validity / phase) at the start of the next spec or fix. The markdown form remains the team-canonical, committed view.
-
Check for pattern. If this is the second or third time a similar correction has been captured:
- For personal lessons: still personal — repetition just means a stable preference.
- For team lessons: escalate — suggest adding the rule to
CLAUDE.md as a permanent standard. Reference the prior lessons as evidence of a pattern.
- Cross-file: if a personal lesson keeps recurring AND clearly applies to others, suggest promotion via
/promote-lesson.
-
Apply immediately. Adjust your current work to follow the correction. Do not wait for the next task.