Capture Lessons
Turn the current session into a concise markdown note that future agents can reuse. Capture only the parts that would save time later: constraints, root causes, decisions, commands, and file-level evidence.
Workflow
- Review the current conversation and the files that matter.
- Prefer concrete evidence from code, configs, and command results.
- Ignore routine back-and-forth unless it explains a non-obvious decision.
- Decide what is worth keeping.
- Keep root causes, fixes, decision rationale, reusable commands, and repo-specific constraints.
- Skip raw transcript content, generic advice, and dead ends that add no future value.
- Draft a short note before writing anything.
- Use a specific title tied to the problem or decision.
- Keep the note scannable and reuse-oriented.
- Prefer this structure:
# <title>
## Context
## Lessons
- <lesson>
## Evidence
## Affected Files
- [path](/absolute/path)
## Open Questions
- Resolve the output directory and save the note.
- Run
python3 scripts/save_lesson.py --workspace <repo> --title "<title>" --content-file <tmp-markdown-file>.
- The script searches upward from
--workspace.
- In each directory, it checks
AGENTS.md before CLAUDE.md.
- It accepts explicit declarations such as
LESSONS_DIR: Lessons, lessons folder: docs/lessons, save lessons to: .agents/lessons/, or save lessons to: .claude/lessons/.
- If no declaration is found, it reuses
.agents/lessons/ when present, otherwise .claude/lessons/ when present, otherwise creates .agents/lessons/ under the workspace root.
- Re-open the written file and verify quality.
- Every lesson should be actionable or explanatory.
- The note should be shorter and cleaner than the original conversation.
- Keep filenames stable and descriptive; let the script append a numeric suffix if the slug already exists.
Destination Rules
- Support absolute or relative paths declared in
AGENTS.md or CLAUDE.md.
- Resolve relative paths from the directory containing the declaration file.
- Prefer the nearest declaration to the current workspace.
- Fall back in this order when no declaration exists:
.agents/lessons/, then .claude/lessons/ if it already exists.
Supported Declarations
The bundled script recognizes these common forms:
LESSONS_DIR: Lessons
LESSONS_PATH = docs/lessons
- lessons folder: .agents/lessons/
- lessons folder: .claude/lessons/
- lessons directory: docs/lessons
- save lessons to: docs/retros
Keep declarations simple: one path per line. The helper also tolerates legacy values joined with or, but new declarations should stay single-path.
Content Bar
Good lesson notes usually include:
- Why something failed or succeeded.
- Constraints that are easy to miss on a fresh read.
- Commands, paths, or patterns worth reusing.
- Evidence pointing to the changed files or configs.
Weak lesson notes usually include:
- Generic best practices.
- Raw transcript snippets.
- Status updates with no reusable insight.
- Exhaustive implementation detail with no future decision value.
Script Reference
Use the bundled helper from this skill directory:
python3 scripts/save_lesson.py --workspace "$PWD" --print-dir
python3 scripts/save_lesson.py --workspace "$PWD" --title "fix data loader race" --content-file /tmp/lesson.md
Arguments:
--workspace: repository or working directory to resolve against.
--title: optional note title; if omitted, the first markdown H1 is used.
--content-file: read the lesson body from a markdown file. If omitted, read from stdin.
--print-dir: print the resolved lessons directory without writing a note.
--dry-run: print the resolved output path without writing the file.
1---2name: capture-lessons3description: Summarize the current conversation and implementation into a durable lessons note saved under the project's lessons directory. Use when the user asks to capture lessons learned, save takeaways, record gotchas, write a retrospective, preserve decisions or fixes from the current session, or update a lessons log. Resolve the destination by reading AGENTS.md or CLAUDE.md for an explicit lessons path; if none is declared, prefer `.agents/lessons/`, then `.claude/lessons/`.4---5
6# Capture Lessons
7
8Turn the current session into a concise markdown note that future agents can reuse. Capture only the parts that would save time later: constraints, root causes, decisions, commands, and file-level evidence.
9
10## Workflow
11
121. Review the current conversation and the files that matter.
13- Prefer concrete evidence from code, configs, and command results.
14- Ignore routine back-and-forth unless it explains a non-obvious decision.
15
162. Decide what is worth keeping.
17- Keep root causes, fixes, decision rationale, reusable commands, and repo-specific constraints.
18- Skip raw transcript content, generic advice, and dead ends that add no future value.
19
203. Draft a short note before writing anything.
21- Use a specific title tied to the problem or decision.
22- Keep the note scannable and reuse-oriented.
23- Prefer this structure:
24
25```markdown
26# <title>
27
28## Context
29
30## Lessons
31- <lesson>
32
33## Evidence
34
35## Affected Files
36- [path](/absolute/path)
37
38## Open Questions
39```
40
414. Resolve the output directory and save the note.
42- Run `python3 scripts/save_lesson.py --workspace <repo> --title "<title>" --content-file <tmp-markdown-file>`.
43- The script searches upward from `--workspace`.
44- In each directory, it checks `AGENTS.md` before `CLAUDE.md`.
45- It accepts explicit declarations such as `LESSONS_DIR: Lessons`, `lessons folder: docs/lessons`, `save lessons to: .agents/lessons/`, or `save lessons to: .claude/lessons/`.
46- If no declaration is found, it reuses `.agents/lessons/` when present, otherwise `.claude/lessons/` when present, otherwise creates `.agents/lessons/` under the workspace root.
47
485. Re-open the written file and verify quality.
49- Every lesson should be actionable or explanatory.
50- The note should be shorter and cleaner than the original conversation.
51- Keep filenames stable and descriptive; let the script append a numeric suffix if the slug already exists.
52
53## Destination Rules
54
55- Support absolute or relative paths declared in `AGENTS.md` or `CLAUDE.md`.
56- Resolve relative paths from the directory containing the declaration file.
57- Prefer the nearest declaration to the current workspace.
58- Fall back in this order when no declaration exists: `.agents/lessons/`, then `.claude/lessons/` if it already exists.
59
60## Supported Declarations
61
62The bundled script recognizes these common forms:
63
64```markdown
65LESSONS_DIR: Lessons
66LESSONS_PATH = docs/lessons
67- lessons folder: .agents/lessons/
68- lessons folder: .claude/lessons/
69- lessons directory: docs/lessons
70- save lessons to: docs/retros
71```
72
73Keep declarations simple: one path per line. The helper also tolerates legacy values joined with `or`, but new declarations should stay single-path.
74
75## Content Bar
76
77Good lesson notes usually include:
78- Why something failed or succeeded.
79- Constraints that are easy to miss on a fresh read.
80- Commands, paths, or patterns worth reusing.
81- Evidence pointing to the changed files or configs.
82
83Weak lesson notes usually include:
84- Generic best practices.
85- Raw transcript snippets.
86- Status updates with no reusable insight.
87- Exhaustive implementation detail with no future decision value.
88
89## Script Reference
90
91Use the bundled helper from this skill directory:
92
93```bash
94python3 scripts/save_lesson.py --workspace "$PWD" --print-dir
95python3 scripts/save_lesson.py --workspace "$PWD" --title "fix data loader race" --content-file /tmp/lesson.md
96```
97
98Arguments:
99- `--workspace`: repository or working directory to resolve against.
100- `--title`: optional note title; if omitted, the first markdown H1 is used.
101- `--content-file`: read the lesson body from a markdown file. If omitted, read from stdin.
102- `--print-dir`: print the resolved lessons directory without writing a note.
103- `--dry-run`: print the resolved output path without writing the file.