⚠️ VERY PRELIMINARY — WORK IN PROGRESS⚠️ This project is in an early, exploratory state. The scripts work, the algorithm is sound, but nothing here is packaged, polished, or ready for general use. Expect hard-coded paths, rough edges, and frequent breaking changes.
Anamnesis (Greek: ἀνάμνησις — "unforgetting" / recollection) is a toolkit for parsing and reconstructing human-readable conversation logs from Claude Code's raw JSONL session files.
The end goal: give Claude instances a reliable, scriptable way to review and research their own and other Claudes' conversation history — turning opaque multi-megabyte JSONL files into clean, readable transcripts.
Claude Code stores every conversation as a UUID-named .jsonl file under:
~/.claude/projects/<project-slug>/<uuid>.jsonl
A single day's session can produce 40,000+ lines of JSON. Most of it is noise:
tool invocations, tool results, system-injected notifications, CLI-captured terminal
output, context-continuation summaries, and /loop scheduler repetitions. Extracting
the actual conversation — what the human typed, what Claude replied — requires filtering
through roughly 15 categories of injected content.
This project documents and implements that filtering process.
scripts/
script_01.py — script_27.py
27 Python scripts representing every iteration of the parsing algorithm, developed incrementally against a real Claude Code session log. Each script's docstring fully documents what it does, why it exists, what it fixed, and what the next iteration changed.
Read them in order. The iteration narrative is the knowledge asset.
- Find the right file — scan all
.jsonlfiles, check timestamp ranges (UTC!) - Extract text —
message.contentis a string OR a typed-block list; only{"type": "text"}blocks contain readable content - Filter noise — drop sidechain records, tool-result-only records, system
notifications, local-command output, context summaries,
/loopsentinels - Deduplicate humans —
/loopre-sends the same prompt every N minutes; keep only the first occurrence per text per UTC hour - Collapse assistant blocks — Claude emits one JSONL record per tool-use cycle; pick the last substantive (>100 chars) record from each consecutive block
The full algorithm with commentary lives in CLAUDE.md.
Prerequisite: Python 3.8+, no external dependencies.
Scripts are standalone. Each reads a hard-coded JSONL file path. Before running,
update the filepath = line at the top to point to your target session file.
# Find your Claude Code project directory
ls ~/.claude/projects/
# Run the final full-log script against your session
python3 scripts/script_25.py
# Output: /tmp/may12_clean_log.txt
# Human messages only
python3 scripts/script_24.py
# Output: /tmp/human_messages_may12.txtScripts 01-04 are useful for discovery (which file contains which date range). Script 25 is the primary end-to-end output script.
This is not a roadmap with deadlines — it's a list of directions:
- Standalone CLI:
anamnesis <uuid>.jsonl [--date YYYY-MM-DD] [--from HH:MM] - Configurable output: plain text / JSON / Markdown
- Multi-file support: merge and sort across session files
- Sub-agent thread extraction (isSidechain=True view)
- Tool-use statistics (which tools, how often, patterns)
- MCP server so Claude instances can query their own history directly
- Session comparison and diff across dates
In philosophy and medicine, anamnesis refers to the act of recollecting knowledge that was always there but had been forgotten or obscured. That's exactly what this tool does: the conversation happened, it's all in the JSONL — anamnesis clears away the noise and gives it back to you.
MIT — do what you want with it.
Made by Phil LaFayette / LaFayette Labs