Run an evidence-based retrospective over agent session logs (Claude Code and Codex) for a date range or project, and propose ranked environment improvements. Use when asked to learn from past sessions, find repeated corrections, or audit missed sub-agent dispatch. Not for: reviewing a diff, diagnosing one failure, or applying fixes. Output: a ranked report with session-id evidence and proposed issues.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Lesson Learn?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hmj1026-lesson-learn)
---
name: lesson-learn
description: "Run an evidence-based retrospective over agent session logs (Claude Code and Codex) for a date range or project, and propose ranked environment improvements. Use when asked to learn from past sessions, find repeated corrections, or audit missed sub-agent dispatch. Not for: reviewing a diff, diagnosing one failure, or applying fixes. Output: a ranked report with session-id evidence and proposed issues."
---
# Lesson Learn
Find what the user had to correct, repeat, or remind the agent about, and turn
each repeated pattern into one proposed change to the agent's environment:
steering files, checks, skills, agents, or tools. Every finding cites the
sessions it came from.
## Workflow
1. **Scope.** Take `--since`, `--until`, and an optional project. Ask for the
report directory if the repository has no `docs/evidence/`.
2. **Extract.** Run
`extract.js` (not shipped in the Directory Plugin).
It streams Claude Code transcripts and Codex rollouts, skips claude-mem
observer sessions, redacts secrets, and writes `sessions.jsonl` and
`candidates.jsonl`. Record its JSON summary. The ratio is candidates per
transcript record; if it is above 5%, report that and narrow the window
before classifying. `--project` matches the Claude project dir name, a Claude
dir name ending in `-<project>`, or the Codex cwd basename; zero matches
print a warning on stderr. Guard Blocks use the date of the first refusal
in the selected project scope. Other candidates use the transcript file's
modification time. The session total includes transcripts selected by
either rule.
3. **Classify.** Follow [`references/classify-protocol.md`](references/classify-protocol.md):
split candidates into at most 8 batches for fast read-only sub-agents, then
send doubtful clusters to one stronger verifier. Without a sub-agent tool,
classify the batches yourself in sequence and label the report
`dispatch: inline-sequential`.
4. **Rank.** Group findings by [`references/categories.md`](references/categories.md).
Rank by occurrences × sessions affected × cost (rework, lost turns). A
finding seen in one session only is listed as an observation, not a
proposal.
5. **Report.** Write the report (Markdown plus a JSON sidecar) to the agreed
directory. Each proposal names the target file or mechanism, the change,
and at least two evidence rows: `host / project / session id / timestamp /
redacted excerpt`.
6. **Propose issues.** List the issues you would open. Stop and wait for the
user to approve them. Only after approval, create each with
`gh issue create --label needs-triage`.
## When NOT to Use
- Reviewing a finished change: use `diff-review` or `change-verdict`.
- Diagnosing one reproducible failure: use `failure-diagnose`.
- Applying a fix: proposals become issues; implementation is a separate task.
## Output
`Scope → extraction summary → ranked proposals (category, target, change,
evidence rows) → observations → proposed issues awaiting approval`.
Quote only redacted excerpts. Report extraction skips and any batch that was
not classified as `NOT_RUN`.
### Guard Block Recovery
Under the extraction summary, report the Guard Block total and affected
session count from `guardBlocks`. Build one Markdown table from
`guardBlocks.byReason`, with one row per reason and these columns:
| Reason | Guard Blocks | Recovered | Re-blocked | Abandoned | Unmatched | Recovery turns total | Recovery turns median |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
Use the same columns each month. Recovery turns count the assistant turns
from the refusal to the first successful read within the five-turn window.
Show `—` for a `null` median. Copy `guardBlocks` unchanged into the JSON
sidecar, including zero totals and `null` medians. Use the same per-reason
totals for any Guard Block counts in the report.
## Verification
- [ ] The extraction summary (sessions, candidates, ratio, skipped) is in the report.
- [ ] Every proposal has at least two evidence rows from distinct sessions.
- [ ] No unredacted secret, token, or email appears in the report.
- [ ] No issue was created before the user approved the list.