Claude Code Memory System
Distills sessions into compounding knowledge. Every run makes future sessions sharper.
Pipeline — every vir run
01
Scanner free
Walks ~/.claude/projects/**/*.jsonl. Computes SHA-256 of each file. Skips anything already in SQLite with the same hash — fully idempotent.
02
Filter free
Heuristic scorer — no LLM tokens spent. Score based on session length, tool call count, unique files touched, signal words (error, fixed, learned). Sessions below threshold 0.4 are skipped.
03
Scrubber free
Strips API keys, Bearer tokens, AWS credentials, emails, absolute paths with usernames before anything touches the LLM.
04
Classify Haiku
Haiku classifies the session: category (pattern / gotcha / decision / tool), topic (2–4 words), project, confidence (0–1). Sessions with confidence < 0.6 are skipped — no Sonnet call.
05
Distill Sonnet
Sonnet extracts durable knowledge: Summary, What Was Learned, Context, Related. Stored in SQLite content column. Rate-limited with 60/120/240s backoff on 429.
06
Write free
Writes typed markdown note to Obsidian vault: patterns/, gotchas/, decisions/, tools/. Updates index.md catalog and log.md. Wikilinks injected for Obsidian graph view clustering.
Commands
vir run
Run pipeline once. Processes only new/changed sessions. Used by the launchd daemon every 4 hours.
Haiku + Sonnet
vir run --full
Force reprocess all sessions. Required after schema migrations or first setup. Expensive one-time cost.
$$
vir run --rewrite-only
Rewrite all vault notes from SQLite — no LLM calls. Use after changing writer format (e.g. adding wikilinks).
free
vir query "question"
TF-IDF retrieves top 8 notes, Sonnet synthesizes a direct answer. Citations included.
~$0.01
vir summarize <project>
Generate cross-session synthesis for a project: key patterns, gotchas, decisions, knowledge gaps.
~$0.02
vir lint
Three checks: orphan notes, stale notes (>90d with newer activity), contradiction detection between similar notes.
free + Haiku
vir dedupe
Interactive duplicate detection. Haiku finds candidates, you confirm each merge. Duplicates archived, not deleted.
Haiku
vir sync-claude --dry-run
Preview what would be injected into ~/.claude/CLAUDE.md and per-project CLAUDE.md files. Shows diff: added, upgraded, removed.
free
vir status
Knowledge heatmap: notes by project and category, confidence distribution, gaps, daemon status.
free
vir schedule install
Register launchd plist at ~/Library/LaunchAgents/. Runs vir run every 4 hours automatically.
free
The compounding loop
Claude Code
session runs

JSONL transcripts
🌀
Vir
distills knowledge

markdown notes
📓
Obsidian vault
knowledge base

vir sync-claude
🧠
CLAUDE.md
feeds future sessions
Cost reference (Kie.ai)
Operation Model When Cost
Scanner / Filter / Scrubber every session free
Classify Haiku 4.5 sessions passing filter ~$0.001/session
Distill Sonnet 4.6 confidence ≥ 0.6 ~$0.02/session
First full run (226 sessions) Haiku + Sonnet one-time ~$1.50
Ongoing (4h daemon, ~8 sessions) Haiku + Sonnet per run ~$0.05/run
vir query Sonnet 4.6 per query ~$0.01
vir summarize Sonnet 4.6 per project ~$0.02
vir dedupe / lint --contradictions Haiku 4.5 per pair checked ~$0.001/pair