Claude Compaction Restore
Use this skill to preserve continuity before Claude Code compacts and to
restore continuity after compaction. Follow the active restore request or
configured continuity policy. A hook notice identifies available evidence; it
does not by itself request a seat restoration.
If You Are About To Compact
Prepare durable continuity before the context boundary.
- Identify the active task, queue item, mission/slice, branch or commit, and
current working directory.
- Record the current state: decisions made, files changed, commands/tests run,
evidence produced, blockers, caveats, and the next concrete step.
- Create or update a durable mental-model restore map. This map is the main
artifact future-you will use to rebuild context after compaction.
- In the restore map, write an ASCII file/folder tree of every path that
mattered to your working mental model during this session. Include:
- the active queue item or mission packet;
- mission notes, progress, decisions, and evidence files;
- Claude memory/project notes you used or wrote, especially when the memory
folder is shared by many agents;
- files with active edits or recently inspected source;
- root instructions such as
AGENTS.md, CLAUDE.md, or README.md;
- as-built docs, codemaps, conventions, skills, and product docs needed
before code/review work;
- source files, tests, scripts, UI evidence, screenshots, logs, or reports
that shaped your current state.
- For every file or folder in the tree, add a short note explaining why it
matters and whether it is required reading after compaction.
- Write any important glue context that is not already on disk into the
handoff/restore map. This includes assumptions, partial conclusions, failed
paths, and why the listed files fit together.
- In the compaction summary, include the restore map path and the top required
reading paths from that map.
If You Just Compacted
Restore from the evidence for this session before relying on remembered task state.
- Inspect the restore request and any named marker, packet, transcript, restore
map, or extra instruction file. Check recorded seat/session/transcript identity
against the current request, and verify that the referenced packet is readable.
A marker path alone does not prove a usable packet; do not substitute another
seat's packet or select one only because it is the newest.
- Use the existing packet when usable. Read its
restore-instructions.md,
touched-files.md, and any named restore map. A packet already prepared for this
session does not need rebuilding merely because compaction occurred.
- Fall back when the packet is absent or unusable. Record what is missing or
mismatched. Resolve this skill's installed directory and run its
scripts/restore-from-jsonl.mjs with the matching Claude JSONL transcript and a
separate output directory. For a skill installed in the global Claude skill root:
node ~/.claude/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs /path/to/session.jsonl --out /tmp/claude-compaction-restore
If no transcript was named, identify the current session's transcript first.
The script can discover a transcript from a working directory, but inspect that
selection before relying on it. If the session cannot be identified, report
the missing input instead of reconstructing from an unrelated conversation.
Read the resulting restore-instructions.md and touched-files.md.
4. Inspect the actual packet and transcript sizes before choosing how much to read.
The generated instructions report estimated token cost. State a read budget
and stopping rule that leave room for the task. For a large transcript, begin
with the most recent task-relevant unique narrative; read earlier material when
a specific missing decision or dependency requires it. Report ranges actually
read rather than treating a chosen budget as completed coverage.
5. Use the restore map and touched-file list to identify current task files.
The list is a triage aid, not an exhaustive inventory. Prioritize the active
queue/mission packet, decisions and memory named in the map, files with active
edits, root instructions, and relevant as-built docs or codemaps. Read required
task files in full within the stated budget; record any remaining gaps.
6. Re-establish the task's purpose and operating context from the current project,
mission and seat files. A transcript summary alone does not establish current
scope or obligations. Use the shipped refocusing skill for the path-only
topology/work trace when operating inside OpenRig.
7. Report the read-depth audit below. Once the required context is restored, use
the packet's requested acknowledgment, normally:
restored from packet at <path>; resumed at step <X>
Include the main files actually read in full. If essential context remains
missing, report partial restoration and the next recovery action instead of
claiming completion.
The packaged PreCompact writer can prepare a packet and a per-seat pending marker;
the restore bridge can deliver its pointer once for a matching session. Inspect
those actual artifacts. Their creation or delivery is not proof that a provider
restored its context, that the files were read, or that task understanding returned.
Required Read-Depth Audit
After the first restore pass, audit yourself before continuing.
- List every file, packet, marker, restore map, instruction file, and source
document you were asked to read during restore.
- Mark each item as
FULL, PARTIAL, or NOT_READ.
- Distinguish essential current-task context from supplementary history, using
the actual restore request and active task.
- Read
PARTIAL/NOT_READ items in full — but to a declared budget with a stopping rule, not
unbounded. Prioritize by relevance to the active task; for a large transcript read the most recent
unique narrative first (see If You Just Compacted), not front-to-back.
- Stop when either every task-relevant item is
FULL, or you reach the budget — a restore that
cannot leave room for the work it was restored to do is not a successful restore. "Read everything,
never conserve" has no termination condition; that open-endedness is the bug, not the goal.
- Report the final read-depth table honestly (
FULL/PARTIAL/NOT_READ, each with a reason)
before task work. An honest PARTIAL with its reason is a correct outcome, not a failure — do
not claim a completion you did not reach.
Guardrails
- Compaction is survival, not housekeeping — never compact to free space, "lean" a seat, or capture/prepare an agent starter (the
rig agent-image library). It is lossy (a compacted Claude is confident-but-hollow); compact only when a seat is genuinely near its context limit, with a before/after plan. A starter's value is being functional, not small — see the agent-starters skill.
- Do not silently launch fresh after compaction.
- Do not continue from memory when restore evidence exists.
- Do not defer required restore reading until a later user task. The restore is
the current task.
- Do not skip root instructions, as-built docs, or codemaps before product
code/review work.
- Do not treat the generated touched-file list as exhaustive.
- Do not mark a file
FULL unless you actually read the full file content
after compaction.
- Do not resume task work until the restore sentinel and read-depth audit are
complete.
Failure Modes To Avoid
- Confidently-wrong restoration: claiming restoration after reading only
the touched-file list or summary.
- Unreported partial restore: continuing without essential task context or
claiming full coverage after a budget-limited read.
- Skipping project instructions: missing
AGENTS.md, CLAUDE.md,
README.md, as-built docs, or codemaps that govern the task.
- Treating the packet as exhaustive: ignoring mission or workspace files
that are important but were not discovered by the script.
- Waiting for the next task: treating restore reading as conditional on a
future user assignment instead of completing it immediately.
1---2name: claude-compaction-restore3description: Use when a Claude Code session has just compacted, is about to compact, reached context limit, resumed after /compact, or needs to rebuild its working mental model from Claude JSONL transcripts and touched files.4---56# Claude Compaction Restore78Use this skill to preserve continuity before Claude Code compacts and to9restore continuity after compaction. Follow the active restore request or10configured continuity policy. A hook notice identifies available evidence; it11does not by itself request a seat restoration.1213## If You Are About To Compact1415Prepare durable continuity before the context boundary.16171. Identify the active task, queue item, mission/slice, branch or commit, and18 current working directory.192. Record the current state: decisions made, files changed, commands/tests run,20 evidence produced, blockers, caveats, and the next concrete step.213. Create or update a durable mental-model restore map. This map is the main22 artifact future-you will use to rebuild context after compaction.234. In the restore map, write an ASCII file/folder tree of every path that24 mattered to your working mental model during this session. Include:25 - the active queue item or mission packet;26 - mission notes, progress, decisions, and evidence files;27 - Claude memory/project notes you used or wrote, especially when the memory28 folder is shared by many agents;29 - files with active edits or recently inspected source;30 - root instructions such as `AGENTS.md`, `CLAUDE.md`, or `README.md`;31 - as-built docs, codemaps, conventions, skills, and product docs needed32 before code/review work;33 - source files, tests, scripts, UI evidence, screenshots, logs, or reports34 that shaped your current state.355. For every file or folder in the tree, add a short note explaining why it36 matters and whether it is required reading after compaction.376. Write any important glue context that is not already on disk into the38 handoff/restore map. This includes assumptions, partial conclusions, failed39 paths, and why the listed files fit together.407. In the compaction summary, include the restore map path and the top required41 reading paths from that map.4243## If You Just Compacted4445Restore from the evidence for this session before relying on remembered task state.46471. Inspect the restore request and any named marker, packet, transcript, restore48 map, or extra instruction file. Check recorded seat/session/transcript identity49 against the current request, and verify that the referenced packet is readable.50 A marker path alone does not prove a usable packet; do not substitute another51 seat's packet or select one only because it is the newest.522. **Use the existing packet when usable.** Read its `restore-instructions.md`,53 `touched-files.md`, and any named restore map. A packet already prepared for this54 session does not need rebuilding merely because compaction occurred.553. **Fall back when the packet is absent or unusable.** Record what is missing or56 mismatched. Resolve this skill's installed directory and run its57 `scripts/restore-from-jsonl.mjs` with the matching Claude JSONL transcript and a58 separate output directory. For a skill installed in the global Claude skill root:5960```bash61node ~/.claude/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs /path/to/session.jsonl --out /tmp/claude-compaction-restore62```6364 If no transcript was named, identify the current session's transcript first.65 The script can discover a transcript from a working directory, but inspect that66 selection before relying on it. If the session cannot be identified, report67 the missing input instead of reconstructing from an unrelated conversation.68 Read the resulting `restore-instructions.md` and `touched-files.md`.694. Inspect the actual packet and transcript sizes before choosing how much to read.70 The generated instructions report estimated token cost. State a read budget71 and stopping rule that leave room for the task. For a large transcript, begin72 with the most recent task-relevant unique narrative; read earlier material when73 a specific missing decision or dependency requires it. Report ranges actually74 read rather than treating a chosen budget as completed coverage.755. Use the restore map and touched-file list to identify current task files.76 The list is a triage aid, not an exhaustive inventory. Prioritize the active77 queue/mission packet, decisions and memory named in the map, files with active78 edits, root instructions, and relevant as-built docs or codemaps. Read required79 task files in full within the stated budget; record any remaining gaps.806. Re-establish the task's purpose and operating context from the current project,81 mission and seat files. A transcript summary alone does not establish current82 scope or obligations. Use the shipped `refocusing` skill for the path-only83 topology/work trace when operating inside OpenRig.847. Report the read-depth audit below. Once the required context is restored, use85 the packet's requested acknowledgment, normally:8687```text88restored from packet at <path>; resumed at step <X>89```9091 Include the main files actually read in full. If essential context remains92 missing, report partial restoration and the next recovery action instead of93 claiming completion.9495The packaged PreCompact writer can prepare a packet and a per-seat pending marker;96the restore bridge can deliver its pointer once for a matching session. Inspect97those actual artifacts. Their creation or delivery is not proof that a provider98restored its context, that the files were read, or that task understanding returned.99100## Required Read-Depth Audit101102After the first restore pass, audit yourself before continuing.1031041. List every file, packet, marker, restore map, instruction file, and source105 document you were asked to read during restore.1062. Mark each item as `FULL`, `PARTIAL`, or `NOT_READ`.1073. Distinguish essential current-task context from supplementary history, using108 the actual restore request and active task.1094. Read `PARTIAL`/`NOT_READ` items in full — but **to a declared budget with a stopping rule**, not110 unbounded. Prioritize by relevance to the active task; for a large transcript read the most recent111 unique narrative first (see *If You Just Compacted*), not front-to-back.1125. **Stop** when either every task-relevant item is `FULL`, or you reach the budget — *a restore that113 cannot leave room for the work it was restored to do is not a successful restore.* "Read everything,114 never conserve" has no termination condition; that open-endedness is the bug, not the goal.1156. Report the final read-depth table **honestly** (`FULL`/`PARTIAL`/`NOT_READ`, each with a reason)116 before task work. **An honest `PARTIAL` with its reason is a correct outcome, not a failure** — do117 not claim a completion you did not reach.118119## Guardrails120121- Compaction is survival, not housekeeping — never compact to free space, "lean" a seat, or capture/prepare an agent starter (the `rig agent-image` library). It is lossy (a compacted Claude is confident-but-hollow); compact only when a seat is genuinely near its context limit, with a before/after plan. A starter's value is being *functional*, not small — see the `agent-starters` skill.122- Do not silently launch fresh after compaction.123- Do not continue from memory when restore evidence exists.124- Do not defer required restore reading until a later user task. The restore is125 the current task.126- Do not skip root instructions, as-built docs, or codemaps before product127 code/review work.128- Do not treat the generated touched-file list as exhaustive.129- Do not mark a file `FULL` unless you actually read the full file content130 after compaction.131- Do not resume task work until the restore sentinel and read-depth audit are132 complete.133134## Failure Modes To Avoid1351361. **Confidently-wrong restoration**: claiming restoration after reading only137 the touched-file list or summary.1382. **Unreported partial restore**: continuing without essential task context or139 claiming full coverage after a budget-limited read.1403. **Skipping project instructions**: missing `AGENTS.md`, `CLAUDE.md`,141 `README.md`, as-built docs, or codemaps that govern the task.1424. **Treating the packet as exhaustive**: ignoring mission or workspace files143 that are important but were not discovered by the script.1445. **Waiting for the next task**: treating restore reading as conditional on a145 future user assignment instead of completing it immediately.