claude-compaction-restore

claude-compaction-restore is a skill for Claude Code from mvschwarz/openrig. It costs 60 tokens per session (4,102 once invoked), scanned A, original, Apache-2.0.

A procedure for restoring an AI coding session after its conversation history has been shortened, or compacted. It rebuilds the task context from saved transcripts and files.

In plain words
What is it for?
Use it to record a durable progress map before compaction and recover the working state afterward.
Why use it?
It helps prevent lost decisions, unfinished work, changed files, and next steps when a session reaches its context limit or resumes later.

Skill for Claude Code

Written for Claude Code: PreCompact hook event. Also seen: reads .claude/ paths; mentions subagents; mentions Claude Code.

Part of the openrig-core plugin — 19 skills shipped together

Good fit Use it to record a durable progress map before compaction and recover the working state afterward.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mvschwarz/openrig/claude-compaction-restore
About the project

OpenRig is a software harness that coordinates Claude Code and Codex coding agents as one system, with agent teams defined in YAML and launched together. It is for organizing persistent teams of coding agents that can delegate work to specialists and return results or decisions. The catalogue lists 53 skills and one plugin as add-ons for OpenRig.

mvschwarz/openrig · 8,168 stars · on GitHub · openrig.dev

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mvschwarz/openrig --skill claude-compaction-restore
Clone the repo
git clone --depth 1 https://github.com/mvschwarz/openrig

Made for: Claude Code.

Or install openrig-core, the plugin that ships this one along with the rest of its 19 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for claude-compaction-restore

README.md
[![agentmods](https://agentmods.dev/badge/skills/mvschwarz/openrig/claude-compaction-restore/github.svg)](https://agentmods.dev/skills/mvschwarz/openrig/claude-compaction-restore)
Your own site
<a href="https://agentmods.dev/skills/mvschwarz/openrig/claude-compaction-restore"><img src="https://agentmods.dev/badge/skills/mvschwarz/openrig/claude-compaction-restore/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for claude-compaction-restore

Your own site · 80×15
<a href="https://agentmods.dev/skills/mvschwarz/openrig/claude-compaction-restore"><img src="https://agentmods.dev/badge/skills/mvschwarz/openrig/claude-compaction-restore.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 60 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,102 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Rogue Agent · line 34
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00060 $0.04102
Opus 5.5 $0.00024 $0.01641
Sonnet 5.5 $0.00012 $0.00820
Haiku 4.5 $0.00006 $0.00410

Measured 2d ago against content hash 623b00143111, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

claude-compaction-restore scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/precompact-hook.mjs, scripts/restore-from-jsonl.mjs), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md · 252 lines

How it starts

The opening of the file, as written. The whole thing — 252 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Claude Compaction Restore

Compaction keeps facts and loses connections. After a compaction you still know file names, row ids and decisions as items. What you lose is the web between them: why a file matters, what depends on what, which decision produced which artifact, what you were about to do next, and how this window relates to the ones before it. Seats whose value is a wide, long-running picture (planners, orchestrators, reviewers holding a standard) lose the most.

This skill keeps that picture alive across compactions. Before compacting, you write a restore map: a short summary plus the connections between things that already exist on disk. After compacting, you re-enter the world, read your own map, and rebuild the picture before acting. Over several compactions the maps chain into one continuous record: a global context window that outlives any single session.

The previous version of this skill is kept at reference/SKILL-v1.md for comparison.

What survives, and what you write

Already on disk; point to it, don't copy it:

  • your session JSONL at ~/.claude/projects/<cwd-slug>/<session-uuid>.jsonl (the post-compaction restore request names the exact path). It holds every message and tool call you made, in order. It does not hold your reasoning;
  • the restore packet the PreCompact hook writes (transcript extract, touched-file triage);
  • queue rows and their transitions, mission files (SPEC.md, NOTES.md, PROGRESS.md), your seat's LEARNED.md, evidence folders, branches and PRs.

Only in your head; write it down:

  • why each important thing matters, and to whom;
  • how things relate: depends on, supersedes, answers, contradicts, was produced by, is owned by;
  • decisions and the reasons for them, options you rejected, judgment and taste you applied;
  • where you were in time: what earlier windows established, what this window did, what comes next and who authorizes it;
  • where to look deeper: which JSONL range or file answers which question.

Read the full file on GitHub · 252 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago Changed · +7 lines 623b00143111
  2. 17d ago Changed · +11 lines a9d309e42c95
  3. 20d ago Changed · +9 lines e86560d6ce8f
  4. 21d ago Changed · +71 lines · +11 tokens per session 36c9818a57cc
  5. 21d ago Changed · -5 lines ca819221c04a
  6. 1mo ago Changed · -8 lines 6c6a8b008bf8
  7. 1mo ago First seen · 167 lines · 49 tokens per session scan A 6f64609f32bc

Subscribe to this mod's changes

claude-compaction-restore is a skill published in the GitHub repository mvschwarz/openrig (8,168 stars, last pushed today), licensed Apache-2.0. It adds 60 tokens to every session and 4,102 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

handoff

Write a compact, decision-ready handoff so the next session (or the user) can continue without reconstructing the current one. Use when the session is ending, context is running low, the user asks for a handoff / 'pass the baton' / 'hand off', or a long-running operation needs a durable state checkpoint.

Hmbown/CodeWhale · 70 tokens

forget

Help the user remove a stored fact using Codewhale's Context Lens when they ask to forget or delete a memory.

Hmbown/Codewhale · 26 tokens

semantix

Install and use the semantix memory kernel as a middleware in your agent: extract user preferences / workflows / experience from past sessions, retrieve and inject them on demand. One binary + your agent's own tools.

Gnosil/semantix · 47 tokens

durable-session-state

Persist plans, scope decisions, evidence, and reviewer/critic verdicts to durable files during long or multi-phase tasks so work survives context compaction, session resumes, and handoffs. Use for swarm-mode tasks, before context grows large, when recording approval gates, and when resuming after compaction or a…

ZaxbyHub/opencode-swarm · 70 tokens

metis

A task-routing and checking workflow for explicitly requested Metis work. It assigns work to defined roles, records checks, and limits recovery when something fails.

Wholiver/metis · 35 tokens

continuous-learning

Use when a mistake, correction, or surprise taught the workspace something that must stick — a retro or postmortem, the same agent error corrected twice, a resolved bug's root cause, scattered notes-to-self — and route that lesson to the durable surface that fires next time. NOT a forward choice with alternatives…

ericrisco/rsc-harness · 73 tokens