checkpoint
A Claude Code plugin that makes context compaction survivable.
Compaction keeps roughly 2% of a context window. Anything that survives does so
because it is on disk, not because the summary happened to mention it.
This plugin adds a /checkpoint skill that writes a resume brief before the
window is compressed, and hooks that put the brief back afterwards — without
anyone copying and pasting it.
The failure it prevents
A resumed session inherits the format of the work from the artifacts around
it, and silently loses the steps.
In the incident this mechanism was built for, a fresh window reconstructed the
shape of a file bus perfectly and dropped the step of reading a clock. It then
wrote ten plausible timestamps, one of them 31 minutes in the future. They were
later cited as evidence.
So the brief records what must be done, not what things look like. Where
a convention requires measuring something, the brief says it must be measured.
Install
/plugin marketplace add scastillo/claude-checkpoint
/plugin install checkpoint@scastillo-checkpoint
That is the whole install. No settings.json editing, no symlinks.
What you get
| Piece | Event | What it does |
|---|
/checkpoint skill | you invoke it | Writes RESUME.md for the next window, then updates the durable things — issue ledger, memory — that outlive it |
precompact-checkpoint.sh | PreCompact | Stamps measured git sha / branch / dirty count / UTC clock, and steers the summariser toward procedure over narrative |
sessionstart-resume.sh | SessionStart (compact, resume, fork) | Re-injects the brief into the new window, re-measures state itself, and tells the agent to carry on |
checkpoint-monitor.js | PostToolUse | Warns the agent at 70% / 80% context, so it can checkpoint while it still has room to think |
Briefs are written to ~/.claude/checkpoints/<session-id>/. Override with
CLAUDE_CHECKPOINT_DIR.
Using it
Run /checkpoint at a phase boundary, when context passes ~70%, or any time you
are about to hand the session over. Then compact.
Writing a checkpoint does not trigger compaction. It only makes the next one
survivable.
Four design rules, each of them a scar
1. The session id is read, never inferred. An earlier version resolved the
session by picking the most recently modified transcript. Every concurrent
session then resolved to the same directory: four unrelated briefs landed in one
folder and overwrote each other. The hook now reads CLAUDE_CODE_SESSION_ID or
fails loudly. A wrong directory is worse than no directory — it can serve one
agent another agent's plan.
2. The brief is consumed once. After the restore hook injects it, RESUME.md
is renamed to RESUME.consumed.<ts>.md. Without that, the guard fails open in
its most damaging form: checkpoint at phase 3, compact, work on to phase 5, hit
an uncheckpointed compaction — and the hook cheerfully serves the stale phase-3
brief under a green RESUMED banner. A confident wrong answer is worse than a
blank one.
3. Nothing is silent. No checkpoint on file prints an explicit banner.
Silence is indistinguishable from a clean resume, which is exactly how a dead
hook hides.
4. Restore re-measures instead of trusting. Subagents share their parent's
session id and working directory, so the writer of a fact file cannot be
identified. The restore hook takes its own readings and shows them beside the
recorded ones. Disagreement is surfaced, never resolved silently.
Optional: the context nudge
The 70% / 80% warning needs one extra piece. Claude Code hands live context usage
to the statusline only, and paints a bar the model never sees. A statusline
snippet mirrors that number to ~/.claude/run/, where the monitor reads it.
- No statusline of your own? Point
statusLine in ~/.claude/settings.json at
statusline/context-bridge.sh.
- Already have one? Copy the
BRIDGE block out of that file into it.
Without this the monitor says so once per session, then stays quiet. Everything
else in the plugin works regardless.
Environment variables
| Variable | Default | Effect |
|---|
CLAUDE_CHECKPOINT_DIR | ~/.claude/checkpoints | Where briefs and fact files are written |
CHECKPOINT_GUARD_WINDOW_SEC | 10 | Double-fire window. The hooks are safe to register both globally and per-repo; a second fire inside this window stays silent |
CLAUDE_SWARM_BUS | unset | If set to a directory, the restore hook appends a COMPACT_DONE event to $CLAUDE_SWARM_BUS/progress.jsonl. Useful when an orchestrator needs to know the instant a compaction finished, instead of inferring it from a pane |
Requirements