A pi extension that automatically extracts reusable problem-solving patterns from session transcripts.
Runs pattern detection on session shutdown and session switch (/new), extracting:
- Retry loop detection — same tool fails then succeeds with a different approach
- Error→fix pair detection — error messages mapped to their resolutions
- User correction detection — user messages that corrected agent behavior
- Confirmation detection — user messages that validated an approach (positive signal)
Candidates accumulate with confidence scores and auto-promote to permanent pi-memory lessons when they reach threshold.
pi install @samfp/pi-lesson-extractorRequires @samfp/pi-memory as a peer dependency (for lesson promotion).
session_before_switch— runs fast heuristic pattern detection on current session entries before/newor/resumesession_shutdown— same extraction on process exitsession_start— checks for pending candidates, runs auto-promotion pipeline, shows notification count
Candidates that meet promotion criteria (high confidence, seen across multiple sessions) are automatically promoted to permanent pi-memory lessons on the next session start.
| Tool | Description |
|---|---|
lesson_candidates |
List pending lesson candidates by status |
lesson_accept |
Promote a candidate to a permanent lesson |
lesson_reject |
Reject a candidate permanently |
| Command | Description |
|---|---|
/lessons-review |
Interactive review of pending candidates |
Candidates are stored in a SQLite database at ~/.pi/agent/lesson-extractor/candidates.db.
MIT