no-amnesia

May 11, 2026 · View on GitHub

tests License: Apache 2.0 Claude Code

A Claude Code hook bundle that snapshots your working state before context compaction and rehydrates it on the next session, so the model doesn't lose the thread when Claude Code auto-compacts mid-task.

no-amnesia is a small bash + python3 script (state.sh) plus four tiny hook wrappers wired into Claude Code's PreCompact, PostCompact, Stop, and SessionStart events. On every assistant turn end it refreshes .no-amnesia/state/CURRENT.md with the live task handoff (active task, files in play, git status, last assistant closeout, last compact summary). On SessionStart it injects CURRENT.md back into the conversation as additionalContext.

The result: when Claude Code's auto-compaction fires (or you /clear and resume), the next session starts with a structured working-state brief in context instead of a fresh-amnesia opener.

Why this exists

Claude Code's auto-compaction is triggered by context-window pressure. When it fires, the model loses everything except whatever it summarized into the compact prompt — which is often optimized for token efficiency rather than for resuming the actual task. Result: the next session starts confused about what was being worked on, what files are in play, and what verification status is.

The standard fix people reach for is "write more in CLAUDE.md" — but CLAUDE.md is for durable context, not current-task state. Mixing the two pollutes both. no-amnesia keeps them separate: durable in CLAUDE.md, ephemeral in .no-amnesia/state/CURRENT.md, refreshed automatically.

This is the out-of-band continuity counterpart to the rest of the LLM Dark Patterns Hooks suite — instead of blocking dishonest closeouts, it injects honest context.

What it does

Hook eventWhat runsPurpose
Stopstate.sh stopRefresh CURRENT.md after each completed assistant turn
PreCompactstate.sh precompactSnapshot state right before manual or auto-compaction
PostCompactstate.sh postcompactCapture Claude Code's compact summary into CURRENT.md
SessionStartstate.sh hydrateInject CURRENT.md as additionalContext on startup, resume, and post-compact

CURRENT.md is structured (task, active signals, files in play, git status, last compact summary, rehydrate instructions) and intentionally compact (truncated to ~9 KB on hydrate to fit any session budget).

Install

Copy all five scripts into .claude/hooks/:

mkdir -p .claude/hooks
for f in state.sh state-stop.sh state-precompact.sh state-postcompact.sh state-sessionstart.sh; do
  curl -fsSL "https://raw.githubusercontent.com/waitdeadai/no-amnesia/main/hooks/${f}" \
    -o ".claude/hooks/${f}"
  chmod +x ".claude/hooks/${f}"
done

Then merge settings.example.json hooks block into your .claude/settings.json.

Requires python3 (preinstalled on macOS, Ubuntu, and most Linux distros).

State lives in .no-amnesia/state/ (CURRENT.md + per-session snapshots + per-day event log). Add to .gitignore unless you want to commit the working state.

What it does NOT do

  • It is not durable memory. CURRENT.md is overwritten on every Stop event. For durable lessons / decisions / patterns, use a real memory system (the parent minmaxing harness ships one).
  • It is not a replacement for the operator's own task tracking. CURRENT.md is a continuity hint, not ground truth. Reconcile against git status / SPEC.md / your task list before editing.
  • It does not call any external API or service. State is local files; no telemetry.
  • It does not auto-redact secrets perfectly. The script applies a coarse-grained redaction (sk-*, api_key=, bearer, etc.) before writing state, but operators handling especially sensitive prompts should review .no-amnesia/state/ before sharing the workspace.

Sister tools

Part of the LLM Dark Patterns Hooks suite — the continuity branch. The other branches:

Interaction-style: no-vibes, time-anchor, no-curfew, no-sycophancy, no-cliffhanger, honest-eta

Fact-fabrication: no-fake-recall, no-fake-stats, no-fake-cite

Parent harness: minmaxing — full governance harness; this hook bundle was extracted from it.

License

Apache-2.0.