Pin the facts, decisions and constraints that must survive context compaction, and get them back word for word the moment a long session resumes.
$ claude --plugin-dir ./context-anchor > /context-anchor:pin "don't touch the auth module, it's mid-refactor" pinned · 1 anchor in .claude/context-anchor/anchors.jsonl > /context-anchor:pin "staging DB is read-only until Friday" pinned · 2 anchors … 3h later, context compacted … context-anchor restored 2 pinned anchors: · don't touch the auth module, it's mid-refactor · staging DB is read-only until Friday
When a Claude Code session runs long, the transcript gets summarized to stay inside the context window. That's necessary, but summaries are lossy. A constraint stated early on, like "don't touch the auth module", "the deadline is Friday" or "we decided X, not Y", can be smoothed over or dropped.
context-anchor gives you an explicit way to pin something so it survives that boundary intact. Pinned anchors are re-injected as a reminder on the first turn after a compaction, instead of relying on the summary to have kept them.
/context-anchor:pin appends your text with a timestamp to a per-project anchors file. Nothing is paraphrased.
Fires right before compaction, flushes anchors to disk and logs the trigger and anchor count.
Fires when a session resumes after compaction and puts every pinned anchor back in view on the next turn.
Anchors live under the project directory, not a single session. List or clear them at any time.
State a constraint once with /context-anchor:pin.
The PreCompact hook persists anchors before the transcript is summarized.
The SessionStart hook re-injects them word for word after compaction.