capture-learning
Captures a validated learning and writes it to the correct learnings.md. Invoke when: a bug is resolved non-obviously, a pattern is discovered, the user corrects a mistake, or a solution took 2+ attempts. Do NOT invoke for typos, obvious errors, or one-time config changes.
What it does
Capture Learning
When to invoke
- Bug resolved with non-obvious root cause
- Pattern discovered that applies beyond this one case
- User corrected your approach
- Solution took 2+ attempts to get right
- Framework or library quirk discovered
Do NOT invoke for: typos, missing imports, obvious variable errors, one-off config.
Protocol
Step 1 — Choose target skill
| Domain | Target |
|---|---|
| Debugging, error fixing | systematic-debugging/learnings.md |
| Next.js, React, App Router | next-best-practices/learnings.md |
| CodeGraph usage | codegraph-context/learnings.md |
| UI, components, styling | frontend-design/learnings.md |
| Session/workflow patterns | verification-before-completion/learnings.md |
| Vercel, React performance | vercel-react-best-practices/learnings.md |
If uncertain: use the skill most closely related to the DOMAIN, not the activity.
Step 2 — Draft the learning
Fill ALL required fields:
## Learning L-{skill}-{NNN}
id: "L-{skill}-{NNN}"
date: "{today YYYY-MM-DD}"
type: "{bug-fix|pattern|anti-pattern|preference|negative}"
status: "active"
project: "{project-name or global}"
scope: "{project-specific|global}"
tags: [{tag1}, {tag2}]
confidence: 1
context: "In [technology/version], when [specific situation]..."
problem: "{what went wrong or was unclear}"
solution: "{what worked — actionable, specific}"
reason: "{WHY this works — not just what}"
validated_by: ["{session-date}"]
created_in: "{session-date}"
supersedes: null
superseded_by: null
reinforces: []
contradicts: []
Step 3 — Validate (no exceptions)
Before writing, verify ALL of these:
context,problem,solution,reasonare filled and non-emptytagshas between 2 and 5 itemsproblemandsolutioncontain NO absolute file pathssolutionis at least 10 words and actionablereasonexplains WHY (not just restates the solution)- If
type: negativethenconfidencemust be 1
Fix any failure before writing. Do not skip any check.
Step 4 — Contradiction check
Search existing learnings for entries sharing 2+ tags with the new one:
grep -r "tags:" "/Users/dan/Desktop/progetti-web/Fullstack session/.agents/skills/*/learnings.md" \
| grep "{tag1}\|{tag2}"
If a conflict is found, surface it to the user:
CONFLICT DETECTED
New: "{summary}" [tags: ...]
Existing: L-{id} "{summary}" — confidence: N
A) New supersedes old → set supersedes/superseded_by fields
B) Both valid with different scope → adjust scope
C) Cancel new learning
Wait for the user's decision. Never auto-resolve.
Step 5 — Write
Calculate the next ID: count existing ## Learning lines in the target file + 1, zero-padded to 3 digits.
Append the learning between <!-- LEARNINGS START --> and <!-- LEARNINGS END -->.
Step 6 — Re-index skills with embeddings
node "/Users/dan/Desktop/progetti-web/Fullstack session/packages/codegraph/dist/cli.js" analyze "/Users/dan/Desktop/progetti-web/Fullstack session/.agents/skills" --skip-git 2>&1 | tail -3
This updates the structural index. Semantic search works at query-time via the embedding model (loaded automatically on first query).
Step 7 — Confirm
✅ Learning captured: L-{skill}-{NNN}
Type: {type} | Confidence: 1 | Scope: {scope}
Tags: {tags}
File: {skill}/learnings.md
Multi-agent safety
If running as a subagent, do NOT write directly to learnings.md.
Write to a temp file instead:
/Users/dan/Desktop/progetti-web/Fullstack session/.agents/skills/_pending/learning-{date}-{random}.yml
The parent agent or post-session-review will merge these at session end.
Capabilities
Install
Quality
deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 7 github stars · SKILL.md body (3,686 chars)