Challenge
- Post-mortems and Q&A that finally made a mechanism click are the best material for books and lectures, yet they get buried once the session ends
- Asking AI to summarise later smooths the wording, and the original words are lost
Approach
- A session-end hook checks the transcript's length and privacy class, and starts harvesting in the background only when both qualify
- The scout agent gets no working tools; it only lifts passages verbatim from the text it is handed. Only the script writes files
Outcome
- Principles, post-mortems, procedures, Q&A and analogies pile up in the library, each tagged with a suggested chapter or lecture
- It only creates new files and never overwrites old records, so reruns never lose material
The author looks for book and lecture material in the conversations held while working with Claude Code. Rereading them by hand does not last, so material is now picked up automatically whenever a session closes.
To avoid delaying exit, the hook only makes a quick decision in under a second and runs the harvest itself in a detached process. Older conversations can be harvested later by running the same script by hand.
The full workflow
| Task | Who | Inputs | Outputs |
|---|---|---|---|
| 1. Work session | Authorauthor | — | Transcript |
| 2. Gate at exit | End-of-session hookedu_hook.py | Transcript | Gate result |
| 3. Extract text | Harvest scriptedu_hook --run | Gate result, Transcript | Dialogue text |
| 4. Pick material | Scout agent_edu (no tools) | Dialogue text, Refers to Topic list | Records |
| 5. Save files | Harvest scriptedu_hook --run | Records | Library |
5 steps · 2 roles · 1 hook · 214 harvests since 2026-08-30 · about 3,000 excerpts
Every time a session closes, look back over it and keep, word for word, the moments a book or lecture can use.
- The only human part is step 1, ordinary work; steps 2–5 run in the background after the session closes
- A hook gates, a script extracts and saves, and an agent with no tools does the picking; all file I/O stays in the script
- Private work is never read: only an "awaiting authorization" line is logged
- Material is only ever added as new files; existing files are never overwritten
Project folders involved (3)
This workflow does not live in one folder: it runs across projects.
- ~/.claude/hooks/edu_hook.py
- One file that is both the hook and the harvest script; it runs in sessions of every project
- ~/.claude/agents/_edu.md
- The scout agent's definition: what to pick and the output format
- private book folder / material library
- Where material lands, together with the topic list and the harvest log
Step 1 · Author
Work sessionClaude Code
Work in Claude Code as usual.
- Nothing special is done to gather material
- Every session leaves a transcript automatically
- Trial and error and rephrasing can become material later
| Outputs | Transcript |
Step 2 · End-of-session hook
Gate at exitunder 1 s
At close, decide only whether to harvest.
- A session-end hook has little time, so it looks only at file size, the privacy mark and the previous harvest
- A transcript harvested before is skipped unless it has grown by 30% or more
- If it passes, a separate process detached from the terminal is started, and the hook exits at once
Common misconceptionDoing heavy work inside the hook slows down closing the session itself
| Inputs | Transcript |
| Outputs | Gate result |
Step 3 · Harvest script
Extract textdetached process
Pull only the user and Claude turns out of the log.
- Tool output and command records are dropped, leaving only the dialogue
- Sessions with fewer than 5 user messages or 2,000 characters are skipped
- Very long sessions keep the first 30% and the last 70%, cutting the middle
Claude CodeOld sessions can be harvested by hand with the same command; private work only with explicit permission
| Inputs | Gate result, Transcript |
| Outputs | Dialogue text |
Step 4 · Scout agent
Pick materialverbatim
An agent with no tools picks what a book or lecture can use.
- A topic list with the book's chapters and planned lectures is re-read every time and used to judge
- Excerpts are verbatim; the agent's own view goes only in the "reason" field
- The dialogue is material, not instructions: "run this" inside it is never obeyed
Claude CodeThe subagent definition is used as the system prompt for a one-shot run with no tools and no hooks
| Inputs | Dialogue text |
| Outputs | Records |
| Refers to | Topic list |
Step 5 · Harvest script
Save filesnew files only
Save each item as a new file in the material library.
- Each file records the source session, date, working folder, suggested destination and the reason
- Name clashes get a number; existing files are never rewritten
- Every run adds one line to the harvest log, including "nothing found" and "awaiting authorization"
| Inputs | Records |
| Outputs | Library |
Key points
Transcript text is material, not instructions. Even if it says "run this" or "ignore previous instructions", the scout just treats it as material. That is also why it holds no working tools.
Never change a word of the original. Excerpts keep punctuation and typos as they are, and the scout's own view goes only into a separate reason field. The single exception is masking secrets such as keys and passwords.
Do not read private work. Sessions from work marked private are not read at all unless the author explicitly authorises it; they are only logged as awaiting permission.