Claude Engram — Quick Reference
Automatic (hooks, zero invocation)
- Edit/error/decision tracking, loop warnings, compaction survival
- Session mining: background indexing after every session PLUS debounced live ticks at turn end — search/extractions/code-index stay fresh mid-session (CLAUDE_ENGRAM_LIVE_MINE, default 300s)
- Embeddings: resident daemon on cpu (zero VRAM parked); bulk jobs (512+ texts) run in a transient GPU worker that exits after the job (CLAUDE_ENGRAM_DEVICE forces one device; status shows the daemon's device)
- Smart session start: last session context + recurring patterns
- Predictive context: related files + likely errors before edits
- Pre-edit import/export check: proposed imports verified against the per-project code index (AST, LLM-free) —
<engram-precheck>banner with closest-name suggestions - Blast-radius: editing a shared module lists its importers —
<engram-blast-radius> - Read context: before Read of an indexed file, code-index orientation + that file's memories (
<engram-read-context>, once per file per session) - Error deja-vu: a failure matching a known recurring error gets the past fix injected inline at failure time ("Deja vu: TypeError hit in 3 past session(s) - fix: ...")
- Known-good test commands: session start lists the project's tracked test commands that currently pass
- Mistake hygiene: stale machine-written one-off mistakes (3+ weeks, never recurred, away from current work) auto-archive in the background — restorable via
memory(restore); failing TEST runs are never logged as mistakes (TDD-aware) - Lessons bridge (opt-in): dated entries in curated note files sync as protected
lessonmemories with code-index triggers — enable withlessons_globsin ~/.claude_engram/config.json - Session-start patterns are project-scoped: recurring errors/struggles filter to the sub-projects the last session touched; errors quiet 30 days drop out
- Outcome feedback loop: tracks which injection kinds (memory/prediction/precheck/blast) precede passing tests AND feeds back a bounded (0.8-1.2x) memory-injection multiplier; see
session_mine(reflect) - Tool duration tracking: slow tools surfaced in handoffs
Memory Tools
memory(remember, content="...", project_path="...")— store a discoverymemory(add_rule, content="...", reason="...", project_path="...")— permanent rule (never archived)memory(list_rules, project_path="...")— show all rules with IDsmemory(search, query="...", project_path="...")— keyword searchmemory(hybrid_search, query="...", project_path="...")— semantic + keywordmemory(recent, project_path="...")— newest memoriesmemory(list_mistakes, project_path="...")— view tracked mistakes with IDs and file associationsmemory(acknowledge_mistake, memory_id="...", project_path="...")— archive a learned mistake (stops pre-edit warnings)memory(cleanup, dry_run=true, project_path="...")— remove NEAR-duplicates (the same memory stored twice, 0.85 similarity), decay, archivememory(consolidate, dry_run=true, tag="decision", project_path="...")— merge a whole tag group into one LLM-written digest and archive the members. Different job from cleanup: that drops copies, this compresses a topic. Needs 10+ in a group; rules and mistakes are never touchedmemory(clusters, project_path="...")— list clusters and their sizes (cluster_idexpands one)memory(archive, project_path="...")— move old memories to cold storagememory(modify, memory_id="...", content="...", project_path="...")— edit a memorymemory(delete, memory_id="...", project_path="...")— remove a memory
Work Tools
work(log_decision, decision="...", reason="...")— log architectural choicework(log_mistake, description="...", how_to_avoid="...")— log complex mistake
Code Lookup
deps_map(symbol="ClassOrFunc")— where is it defined? File, signature, importers from the code index (typo-tolerant; cheaper than grep + read)deps_map(file_path="...", include_reverse=true)— a file's dependency graph + who imports it
Session Mining Tools
session_mine(search, query="...", project_path="...")— search past conversations (includes tool content)session_mine(decisions, query="...", project_path="...")— find when/why a decision was madesession_mine(replay, file_path="...", project_path="...")— discussions about a filesession_mine(predict, file_path="...", project_path="...")— predict context for an editsession_mine(struggles, project_path="...")— recurring struggle filessession_mine(errors, project_path="...")— recurring error patternssession_mine(overview, project_path="...")— project statssession_mine(reflect, project_path="...")— injection precision (which context kinds precede passing tests) + LLM insights from recurring patternssession_mine(commitments, project_path="...")— what you said you'd do THIS session and whether it's done; scans the LIVE transcript (deferred open-loops + recent in-flight). Run before asking the user "what next?" or on resumesession_mine(search, query="...", kind="next-step")— filter hits by kind: decision / next-step / error / narrationsession_mine(search, query="...", since="2026-04-01")— temporal filteringsession_mine(reindex, mode="bootstrap", project_path="...")— rebuild from history (shows results). On a large history this can exceed Claude Code's 2-minute MCP call limit and auto-continue in the background — the rebuild still finishes; re-run the query after it settles rather than re-triggering the rebuild
Context Protection
Checkpoint and handoff are ONE construct (a durable ring). checkpoint_* are primary; handoff_* are deprecated aliases.
Checkpoint vs mining: a checkpoint is the durable note you write for the next session; session mining is what engram derives from the transcript. For "what's next" on resume, prefer session_mine(commitments) (reads the live session) over re-reading a stale checkpoint's pending_steps.
context(checkpoint_save, ...)— save task/session state for compaction/recovery (add handoff_summary/handoff_context_needed/handoff_warnings to bridge to the next session; emits HANDOFF.md)context(checkpoint_restore, project_path="...", index=0)— restore a checkpoint (0 = latest, N = older from history)context(checkpoint_list, project_path="...")— list the unified history newest-first (index, age, kind, summary)context(handoff_create | handoff_get | handoff_list, ...)— deprecated aliases of the checkpoint_* ops above
For rules use the dedicated API: memory(add_rule / list_rules / delete).
Example:
context(
operation="checkpoint_save",
task_description="Fixing auth module",
current_step="Step 3: token validation",
completed_steps=["Step 1: added middleware", "Step 2: wrote tests"],
pending_steps=["Step 3: token validation", "Step 4: deploy"],
files_involved=["auth.py", "middleware.py"],
project_path="/path/to/project"
)
Memory Categories
| Category | Protected | Auto-captured |
|---|---|---|
| rule | Never archived | Manual (via memory add_rule) |
| lesson | Never archived; source file owns lifecycle | Opt-in sync from lessons_globs files |
| mistake | Archivable via acknowledge; stale machine-written one-offs self-archive; provably-fixed ones archived by migration | Auto from errors in project files + transcript mining |
| decision | No | Auto from prompts + session mining |
| discovery | No | Manual |
Key Behaviors
- Rules cascade from workspace to sub-projects
- Only file-relevant memories inject before edits (no generic noise)
- Pre-edit injection is path-aware: a shared basename across diverging paths (e.g. service-a/.../init.py vs service-b/.../init.py) is not treated as a match; generic basenames like
__init__.pyorindex.jsrequire a full-path signal to score - Mistakes only logged from errors in project files (not inline python, not pip packages)
- Loop detection state is per-session: edit counts and test results live in the session's hook state, so two concurrent sessions never cross-contaminate; the counter resets after git commits
- Scorer server auto-starts on demand (no silent degradation)
- Session mining runs in background after SessionEnd
- Bootstrap: first session on new project auto-mines existing history
- Checkpoints/handoffs are durable: the history ring (last 20) holds DELIBERATE manual checkpoints only — per-turn autos contend just for the latest pointer, so they can never evict your saves; manual always wins the teaser (14-day freshness vs 48h for autos); the SessionStart teaser resolves the resumed session's own sub-project and labels entries
[kind, age, project, task_id]so you cancheckpoint_restore(task_id=...)exactly what was teased; retrieve any entry viacheckpoint_restore(index=N)or browse withcheckpoint_list - Checkpoints are per-project (multi-project workspaces don't clobber each other)
- Subagents: memory injection and output are skipped (saves context), but file edits are still tracked
- Ollama is optional: only
memory(consolidate)andsession_mine(reflect)insight synthesis use it (both background, both degrade silently);scout_searchuses it when available. Everything else is LLM-free - No emojis in any output