session-compaction-and-restore

session-compaction-and-restore is a skill for Claude Code from mvschwarz/openrig. It costs 88 tokens per session (2,386 once invoked), scanned B, original, Apache-2.0.

A guide to preserving an agent’s useful working state when a session loses context, restarts, or is refreshed.

In plain words
What is it for?
Use it to design restore packets, decide what information must survive, and distinguish resuming, copying, or rebuilding an agent’s working model.
Why use it?
It helps prevent long-running work from turning into a cold start where the agent forgets the task’s intent and important decisions.

Skill for Claude Code

Written for Claude Code: PreCompact hook event. Also seen: mentions Claude Code; reads ~/.codex paths; mentions Codex.

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

Good fit Use it to design restore packets, decide what information must survive, and distinguish resuming, copying, or rebuilding an agent’s working model.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mvschwarz/openrig/session-compaction-and-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 · 9,042 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 session-compaction-and-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 session-compaction-and-restore

README.md
[![agentmods](https://agentmods.dev/badge/skills/mvschwarz/openrig/session-compaction-and-restore/github.svg)](https://agentmods.dev/skills/mvschwarz/openrig/session-compaction-and-restore)
Your own site
<a href="https://agentmods.dev/skills/mvschwarz/openrig/session-compaction-and-restore"><img src="https://agentmods.dev/badge/skills/mvschwarz/openrig/session-compaction-and-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 session-compaction-and-restore

Your own site · 80×15
<a href="https://agentmods.dev/skills/mvschwarz/openrig/session-compaction-and-restore"><img src="https://agentmods.dev/badge/skills/mvschwarz/openrig/session-compaction-and-restore.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 88 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,386 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.00088 $0.02386
Opus 5.5 $0.00035 $0.00954
Sonnet 5.5 $0.00018 $0.00477
Haiku 4.5 $0.00009 $0.00239

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

Security

Grade B, and why

session-compaction-and-restore scanned grade B with 1 finding 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 7d ago.

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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

Precise nuance: OpenRig *does* write `~/.codex/config.toml`: it installs OpenRig
packages/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md · 189 lines

How it starts

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

Session Compaction and Restore

Preserving useful working state across compaction, context loss, restart, or seat refresh. Includes Claude compaction restore, Codex resume/fork mechanics, transcript-based mental-model rebuilds, and durable handoff packets.

Long-lived seats are valuable only if they can survive context pressure. If compaction turns a senior seat into a cold-started agent, users will avoid persistent topologies and fall back to throwaway agents.

Use this when

  • A seat is approaching compaction or just compacted
  • Designing a high-fidelity restore packet for an active workflow
  • Distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild
  • Reasoning about what should be preserved vs reconstructable
  • Auditing a restore for product-intent preservation (not just detail preservation)

Don't use this when

  • The session is fresh and has no working state to preserve
  • The intent is to create a new seat from a primed source — that's session-source-fork or agent-starters
  • The packet is a one-off snapshot for human review — restore packets are for re-entering active work

The 5 distinctions (do not collapse)

Per the cross-runtime restore/reentry packet standard:

Mode What it means Outcome literal
Native resume Continue the same managed seat with native runtime token resumed
Fork New managed seat from prior native runtime conversation; new post-fork token forked
Rebuild Fresh-launch seeded with operator-declared artifacts in trust-precedence order rebuilt
Artifact-backed mental-model rebuild Restored seat derives understanding from a packet rather than native runtime continuity (case of rebuilt)
Fresh launch New agent without prior continuity fresh

These are load-bearing distinctions. Do NOT collapse fork into artifact-backed reentry; do NOT collapse rebuild into fork.

The three mechanisms — who owns each (verified vs main d37a08ad, 2026-07-21)

Read the full file on GitHub · 189 lines

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. 7d ago Changed · +3 lines 8d1eba64ad1e
  2. 25d ago Changed b1cbf5f5b0d2
  3. 1mo ago Changed · +19 lines 1abdf9810903
  4. 1mo ago Changed · +6 lines 81f547d3a49e
  5. 2mo ago Changed · +5 lines 6218ebe60190
  6. 2mo ago Changed · -6 lines 36a637b1520f
  7. 2mo ago Changed · -2 lines cdf4e40625e8
  8. 3mo ago First seen · 164 lines · 88 tokens per session scan B 2e785328d6e8

Subscribe to this mod's changes

session-compaction-and-restore is a skill published in the GitHub repository mvschwarz/openrig (9,042 stars, last pushed today), licensed Apache-2.0. It adds 88 tokens to every session and 2,386 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

session-compaction-and-restore compared with skills from other repositories

session-compaction-and-restore next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
session-compaction-and-restoremvschwarz/openrigSkill9.0ktodayApache-2.0B88Claude Code
handoffHmbown/CodeWhaleSkill41ktodayMITA70Claude Code, Codex
forgetHmbown/CodewhaleSkill41k2mo agoMITA26Claude Code, Codex
semantixGnosil/semantixSkill8157d agoMITA47Claude Code, Codex
continuous-learningericrisco/rsc-harnessSkill7093d agoMITA73Claude Code, Codex
durable-session-stateZaxbyHub/opencode-swarmSkill557todayMITA70Claude Code
memoryrunxhq/runxSkill106todayApache-2.0A53Claude Code, Codex