Agent skill

Session Compaction And Restore

by mvschwarz in mvschwarz/openrig

A skill your agent uses when reasoning about what survives compaction/context-loss/restart/seat-refresh, designing a high-fidelity restore packet, or distinguishing native runtime resume vs fork vs…

Apache-2.0Auto-check passedAgent Workflows

Install Session Compaction And Restore

skills CLI
$ npx skills add mvschwarz/openrig --skill session-compaction-and-restore -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mvschwarz/openrig session-compaction-and-restore --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mvschwarz/openrig.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore .claude/skills/session-compaction-and-restore && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
session-compaction-and-restore
GitHub stars
6.6k
Token cost
~2.2k tokens
SKILL.md length
1,011 words
Files
1
Skills in repo
49
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when reasoning about what survives compaction/context-loss/restart/seat-refresh, designing a high-fidelity restore packet, or distinguishing native runtime resume vs fork vs…

  • Works in 3 steps: Claude built-in /compact — a Claude Code… → OpenRig-managed restore — the enforcer +… → Codex session continuity —…
  • Reasoning about what survives compaction/context-loss/restart/seat-refresh
  • SKILL.md covers Use this when, Don't use this when, The 5 distinctions (do not… and The three mechanisms — who…, plus 6 more sections
  • Calls codex

What it does

Session Compaction And Restore is an agent skill from mvschwarz/openrig. Use when reasoning about what survives compaction/context-loss/restart/seat-refresh, designing a high-fidelity restore packet, or distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild. Covers the 4 failure modes that prevent honest restore (compacted seat drops hot potato; restore packet preserves details but loses product intent; runtime resume mistaken for handover or fork; rebuilt seat starts with stale instructions).

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows. The repository describes itself as: Build your own network of agents from Claude Code, Codex and Pi: persistent teams with roles, shared context and owned work. The licence is Apache-2.0.

When your agent uses it

  • Reasoning about what survives compaction/context-loss/restart/seat-refresh
  • Designing a high-fidelity restore packet
  • Distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild

Example prompts

  • “/session-compaction-and-restore”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Claude built-in /compact — a Claude Code HARNESS feature, **not OpenRig
  2. OpenRig-managed restore — the enforcer + hook bridge: a precompact hook
  3. Codex session continuity — resume/rollout tokens (codex resume ),

What it can do on your machine

Read from SKILL.md and the folder at commit 4b48ca2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • codex

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Session Compaction And Restore loads about 2.2k tokens when it runs. Until then it costs about 122 tokens; SKILL.md has 1,011 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~122
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mvschwarz/openrig at commit 4b48ca2, republished under its Apache-2.0 licence (© mvschwarz). 1,011 words, ~2,228 tokens.

Download SKILL.mdSave it as .claude/skills/session-compaction-and-restore/SKILL.md (or your agent's skills folder).
name
session-compaction-and-restore
description
Use when reasoning about what survives compaction/context-loss/restart/seat-refresh, designing a high-fidelity restore packet, or distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild. Covers the 4 failure modes that prevent honest restore (compacted seat drops hot potato; restore packet preserves details but loses product intent; runtime resume mistaken for handover or fork; rebuilt seat starts with stale instructions).
metadata.cli_surfaces_referenced
whoami

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:

ModeWhat it meansOutcome literal
Native resumeContinue the same managed seat with native runtime tokenresumed
ForkNew managed seat from prior native runtime conversation; new post-fork tokenforked
RebuildFresh-launch seeded with operator-declared artifacts in trust-precedence orderrebuilt
Artifact-backed mental-model rebuildRestored seat derives understanding from a packet rather than native runtime continuity(case of rebuilt)
Fresh launchNew agent without prior continuityfresh

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)

The outcomes above ride on three DISTINCT mechanisms; keep them separate:

  1. Claude built-in /compact — a Claude Code HARNESS feature, not OpenRig code. OpenRig only emits the literal /compact toward the pane after a prep turn; there is no compaction algorithm in the OpenRig repo. Provider-owned.
  2. OpenRig-managed restore — the enforcer + hook bridge: a precompact hook WRITES a restore packet; a bridge READER injects exactly ONE restore directive back via the harness hook channel (hookSpecificOutput.additionalContext), seat-isolated. The OpenRig-owned half.
  3. Codex session continuity — resume/rollout tokens (codex resume <token>), a separate path from the Claude mechanisms. Never conflate with Claude restore.

Safety boundary (ties to native-session-file-lab-boundary): no supported OpenRig path EDITS provider-owned native session / auth / transcript files to inject context. Context enters ONLY through sanctioned channels: the hook additionalContext, a normal user message via rig send, or Codex resume tokens. Precise nuance: OpenRig does write ~/.codex/config.toml — but only to install OpenRig activity hooks and [features], never session or auth state. So the rule is "never edits native session/auth/transcript files," NOT "never touches any provider-owned file."

Current CLI surface (operator / kernel seats; verified vs main d37a08ad)

Managed compaction/restore is driven by five shipped verbs — pick per intent, and stay durable-substrate-first (the packet/artifacts are the truth; the CLI is the trigger):

  • rig compact <session> — guided managed compaction for ONE Claude seat (prep → /compact → restore → audit). Non-Claude seats rejected. ~180s.
  • rig compact-plan — READ-ONLY triage; does not compact. Flags --rig, --refresh, --threshold-tokens, --threshold-percent. (Codex seats flagged codex_not_managed_by_claude_compact_in_place.)
  • rig restore-check — restore-readiness probe across running rigs; read-only; exit 0/1/2. Flags --full, --ready, --rig, --no-queue, --no-hooks.
  • rig restore-packet {write,read,validate} — the cross-runtime restore packet (v0): write / read / validate the durable packet this skill's contract defines.
  • rig restore <snapshotId> --rig <rigId> — ⚠ RIG SNAPSHOT restore (infra), a DIFFERENT mechanism — NOT session-context restore. Do not conflate.
Show full SKILL.md (453 more words)Show less

Failure modes (4)

  1. A compacted seat forgets active workflow state and drops the hot potato. Compaction without continuity preservation is silent failure.
  2. A restore packet preserves details but loses the user's product intent. Restore must preserve why this work matters, not just what was happening.
  3. A runtime resume is mistaken for a seat handover or fork. These have different continuity outcomes and provenance — don't conflate.
  4. A rebuilt seat starts with stale instructions that conflict with current workflow mode. Restore must include current state, not just historical state.

Re-entering project context, on any runtime. A restore packet carries the work in flight, not the project's declared intent and context files. rig context work-install lists what the project declares; read the pieces the restored task needs. --deliver prints them all, and when several projects are declared (--json lists the ids), select one with --project <id> instead of guessing.

Proof standard

Proof should include a deliberate compaction/restart of a seat with active work, followed by measured recovery: identity, current workflow, next owner, relevant files, and constraints all restored without human re-briefing.

Canonical packet contract (16-field, v0)

The cross-runtime restore/reentry packet standard v0 defines:

  • Source/target identity
  • Runtimes
  • Workspace root, default repo, role pointer
  • Bounded latest transcript
  • Touched-path inventory
  • Durable work pointers
  • Current work + next owner
  • Caveats + authority boundaries
  • Omitted classes + redaction policy
  • Source-trust ranking
  • Generated-at + generator version

Plus a 6-item restored-seat acceptance checklist.

Source-trust ranking applies when restored seat ingests packet evidence: rig whoami > target rigspec > bounded latest transcript > full transcript > touched-files > restore-summary.json.

Memory surfaces consumed at restore time

A restore may consume transcripts, durable messages, startup context, checkpoints and a restore packet. Inventory the surfaces actually present for this seat, with their source, freshness and purpose. Do not infer that a named surface exists or grants write authority.

The active project/rig policy and task authorization determine what may be written. Treat provider-owned conversation records as evidence to read through supported tooling. For placement and durable context, load skills/openrig-operating-model/SKILL.md with rig context get; for the selected startup path, use skills/core/agent-startup-and-context-ingestion/SKILL.md. A packet or marker proves retained/delivered evidence, not successful provider restoration; measure the resumed seat against the proof standard above.

Before a planned compaction, restart or long pause, write the seat's authored recap with rig context recap-write --rig <rig> --seat <seat> --file <draft>. Its format is in seat-continuity-and-handover, "Write the seat's recap before a handover". A rebuild reads it before LEARNED.md, and a profile source of seat:RECAP.md serves it after a restore.

See also

  • claude-compaction-restore skill — the Claude Code restore SOP (PreCompact hook + JSONL restore script for post-compaction recovery)
  • session-source-fork skill — fork mode for native-runtime-continuity-based restoration
  • seat-continuity-and-handover skill — occupant-creation primitives (resume/fork/rebuild/fresh) that this primitive instantiates
  • openrig-operating-model skill — placement and authority of durable context

© mvschwarz, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in packages/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore of mvschwarz/openrig.

Open the folder on GitHubat commit 4b48ca2

Compare with similar skills

Session Compaction And Restore next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Session Compaction And Restore compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Session Compaction And Restore this skillmvschwarz/openrig6.6k—~2.2kAutomated safety check: PassApache-2.0
MCP Server Builderanthropics/skills180k63 repos~2.3kAutomated safety check: PassApache-2.0
Hook Development for Claude Code Pluginsanthropics/claude-plugins-official38k10 repos~4.1kAutomated safety check: NotesApache-2.0
Using Superpowersfarm-fe/farm5.6k35 repos~1.4kAutomated safety check: PassMIT
Executing Plans Inlineobra/superpowers297k2 repos~5.1kAutomated safety check: PassMIT
Skill CreatorAzure/azqr79689 repos~8.2kAutomated safety check: PassApache-2.0

Similar skills

  • MCP Server Builder

    anthropics/skills

    Official

    Guides the design and implementation of Model Context Protocol servers in TypeScript or Python, from tool naming and error messages to evaluation.

    180k GitHub starsUsed in 63 repos~2.3k tokens
    Agent WorkflowsAuto-check passed
  • Hook Development for Claude Code Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to write Claude Code plugin hooks, both prompt-based checks and bash commands, for events such as PreToolUse, Stop and SessionStart.

    38k GitHub starsUsed in 10 repos~4.1k tokens
    Agent WorkflowsAuto-check: notes
  • Using Superpowers

    farm-fe/farm

    A skill your agent uses when starting any conversation - establishes how to find and use skills, requiring Skill tool invocation before ANY response including clarifying questions

    5.6k GitHub starsUsed in 35 repos~1.4k tokens
    Agent WorkflowsAuto-check passed
  • Executing Plans Inline

    obra/superpowers

    Has the agent carry out an implementation plan itself, task by task in the current session, keeping a ledger, proving each step with a test and ending with one whole-branch review.

    297k GitHub starsUsed in 2 repos~5.1k tokens
    Agent WorkflowsAuto-check passed
  • Skill Creator

    Azure/azqr

    Official

    Create new skills, modify and improve existing skills, and measure skill performance.

    796 GitHub starsUsed in 89 repos~8.2k tokens
    Agent WorkflowsAuto-check passed
  • Claude Code Agent Development

    anthropics/claude-plugins-official

    Official

    Explains how to write agents for Claude Code plugins: the markdown file with YAML frontmatter, trigger descriptions, model and color settings, and system prompt design.

    38k GitHub starsUsed in 7 repos~2.8k tokens
    Agent WorkflowsAuto-check passed

More from mvschwarz/openrig

All 49 skills in this repo
  • OpenRig Upgrade Procedure

    mvschwarz/openrig

    Walks an agent through upgrading the OpenRig CLI and daemon one observed step at a time, keeping live seats alive and reconciling managed plugin files.

    6.6k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Agent Refocusing

    mvschwarz/openrig

    Re-grounds a long-running agent in the current product outcome by running a path-based trace to the root of its topology and work trees.

    6.6k GitHub stars~864 tokensUpdated today
    Auto-check passed
  • OpenRig Software Factory

    mvschwarz/openrig

    Helps set up a continuing agent software team for a real repository with OpenRig, choosing between manual work, queue handoffs and an explicit Workflow.

    6.6k GitHub stars~2.6k tokensUpdated today
    Auto-check passed
  • Separates a stable agent seat's identity from its changing occupant, and records honest, two-part provenance whenever one occupant replaces another.

    6.6k GitHub stars~2.5k tokensUpdated today
    Auto-check passed
  • Loads one section of a Markdown file by its path#h2-slug address with a bundled resolver script, for use outside OpenRig's context library.

    6.6k GitHub stars~341 tokensUpdated today
    Auto-check passed
  • Agent Starters

    mvschwarz/openrig

    Covers authoring, inspecting, refreshing, promoting and deprecating named Agent Starters, the reusable starting points for agent seats in a rig.

    6.6k GitHub stars~1.7k tokensUpdated today
    Auto-check passed

Categories

Questions about Session Compaction And Restore

What does Session Compaction And Restore do?

A skill your agent uses when reasoning about what survives compaction/context-loss/restart/seat-refresh, designing a high-fidelity restore packet, or distinguishing native runtime resume vs fork vs…. Session Compaction And Restore is an agent skill from mvschwarz/openrig. Use when reasoning about what survives compaction/context-loss/restart/seat-refresh, designing a high-fidelity restore packet, or distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild.

When should I use Session Compaction And Restore?

Session Compaction And Restore fits situations like: reasoning about what survives compaction/context-loss/restart/seat-refresh; designing a high-fidelity restore packet; distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild.

How do I install Session Compaction And Restore in Claude Code?

Run `npx skills add mvschwarz/openrig --skill session-compaction-and-restore -a claude-code`. Or copy the skill folder (packages/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore in mvschwarz/openrig) into .claude/skills/session-compaction-and-restore in your project. Claude Code loads it when a task matches its description.

How do I install Session Compaction And Restore in Codex?

Run `npx skills add mvschwarz/openrig --skill session-compaction-and-restore -a codex`. Or copy the skill folder (packages/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore in mvschwarz/openrig) into .agents/skills/session-compaction-and-restore in your project. Codex loads it when a task matches its description.

Can I use Session Compaction And Restore in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mvschwarz/openrig --skill session-compaction-and-restore -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/session-compaction-and-restore, .gemini/skills/session-compaction-and-restore, .github/skills/session-compaction-and-restore and .opencode/skills/session-compaction-and-restore in your project.

What does Session Compaction And Restore need to run?

Going by SKILL.md and its folder, Session Compaction And Restore needs the command-line tools its instructions call (codex).

Does Session Compaction And Restore access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Session Compaction And Restore safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Session Compaction And Restore use?

Session Compaction And Restore is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Session Compaction And Restore use?

About 2.2k tokens (SKILL.md is roughly 8.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Session Compaction And Restore?

Skills that share tags, products or a category with Session Compaction And Restore: MCP Server Builder (anthropics/skills, 180k stars), Hook Development for Claude Code Plugins (anthropics/claude-plugins-official, 38k stars), Using Superpowers (farm-fe/farm, 5.6k stars) and Executing Plans Inline (obra/superpowers, 297k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Session Compaction And Restore?

mvschwarz (a GitHub user) maintains it in mvschwarz/openrig, which has 6,551 GitHub stars. The repository holds 49 skills in this directory. The repository was last updated on October 10, 2026.

Source: mvschwarz/openrig on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.