compact-guard
Skill0 starsChanged 7 months agoMITView on GitHub
Survive /compact and auto-compact without losing the plan. Use this skill when the user runs /claude-papercuts:compact-guard, asks why Claude lost their plan after a compact, mentions plan-mode state vanishing mid-session, or wants to see the latest pre-compact snapshot. A PreCompact hook silently captures the current task, active todos, files edited, and the last assistant plan to .papercuts/compact-snapshots/ right before compaction runs; a SessionStart hook (only when source=compact) injects that snapshot back as context so the post-compact session knows what it was doing.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- rohitg00/pro-workflowtheir own version, first seen Sep 29, 2026
- hmzainjamil/claude-ai-skillstheir own version, first seen May 10, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- rohitg00/pro-workflow★ 2.9ksame name
- hmzainjamil/claude-ai-skills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- amnesia-fixSkill
- done-proverSkill
- onboardSkill
- safe-shellSkill
- skill-budgetSkill
- skill-doctorSkill
- subagent-brokerSkill
- token-x-raySkill
- unclearSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 74
When asked to show compact-guard state:
- Very specific: line 76
Check if .papercuts/compact-snapshots/ exists in the project root.
- Distinctive: line 77
If not, tell the user no compaction has happened yet in this project — the directory will populate on the first PreCompact.
- Distinctive: line 82
If asked for a specific snapshot, cat it to the user verbatim.
- Distinctive: line 84
Never modify or delete snapshots automatically.
- Distinctive: line 138
If Anthropic ships a compact-resilient plan-mode (per issues #24686 and #26061), this skill becomes a no-op and gets deprecated in the next …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
compact-guard — survive /compact
What this prevents
"After context compaction occurs during plan mode execution, Claude Code fails to re-read or reference the existing plan." — issue #24686
"Plan mode state lost after context compression." — issue #26061
You're 30 turns into a careful refactor. /compact runs (manually or
because you hit the auto-compact threshold). The summarizer
condenses everything, including the plan you were halfway through.
Claude wakes up on the other side without the plan, and you have to
re-prompt from scratch.
compact-guard snapshots the plan before compaction touches it,
then re-injects the snapshot as context immediately after, so the
post-compact turn starts knowing the current task, active todos,
files touched, and the most recent plan.
How it works (zero manual work for the user)
/compact (manual) or auto-compact at threshold
│
▼
PreCompact hook fires
│
▼
Read transcript → extract:
• Most recent user message (the current task)
• Latest TodoWrite todos (pending + in_progress only)
• Files edited this session (Edit / Write / MultiEdit)
• Last assistant text block (likely the working plan)
│
▼
Write .papercuts/compact-snapshots/<timestamp>.md
(keeps 5 most recent — oldest pruned)
Compaction runs. The summarizer eats most of the context.
Next session start with source="compact"
│
▼
SessionStart hook fires
│
▼
Read the latest snapshot → print to stdout
Claude Code auto-injects stdout as additional contextWhen you (the model) should invoke this skill manually
- User runs
/claude-papercuts:compact-guard - User asks "what was I doing before the compact?"
- User asks to see the latest pre-compact snapshot
- User says they lost their plan / their todos / their work after a compact ran
Manual invocation procedure
When asked to show compact-guard state:
- Check if
.papercuts/compact-snapshots/exists in the project root. - If not, tell the user no compaction has happened yet in this project — the directory will populate on the first PreCompact. Then stop.
- Otherwise, list the snapshots (sorted newest first). Tell the user:
- How many snapshots are stored
- The timestamp of each
- If asked for a specific snapshot, cat it to the user verbatim. The format is plain markdown — don't summarize.
- Never modify or delete snapshots automatically. If the user asks you to clean them up, ask for explicit confirmation first.
Snapshot format
Each snapshot is a markdown file in
.papercuts/compact-snapshots/<UTC-timestamp>.md:
# compact-guard snapshot
- **When:** 2026-05-16 09:14 UTC
- **Trigger:** auto-compact
- **Session:** abc123def456
## Current task (last user message)
> <the most recent user prompt>
## Active todos
- [in_progress] <todo content>
- [pending] <todo content>
## Files edited this session
- `src/middleware/auth.ts`
- `src/__tests__/auth.test.ts`
## Last assistant message (plan / summary)
<the last assistant text block — usually the working plan, capped at 1500 chars>Sections that have nothing useful are omitted. Total snapshot file is uncapped because it's read on demand, not auto-injected into the system prompt.
What this skill does NOT do
- It does not block compaction. PreCompact runs read-only and exits 0.
- It does not modify the transcript. The snapshot is a separate file.
- It does not deduplicate snapshots. Five most-recent are kept, in case you want to inspect a series of compactions.
- It does not survive across projects. Snapshots live in
.papercuts/compact-snapshots/relative to the project's cwd. - It does not inject context on
/clear,/resume, or startup — only post-compact. Useamnesia-fixfor cross-session continuity.
Privacy
Snapshots are written to a local file in your project's .papercuts/
directory. No network calls. Add .papercuts/ to your .gitignore if
not already.
Deprecation plan
If Anthropic ships a compact-resilient plan-mode (per issues #24686 and #26061), this skill becomes a no-op and gets deprecated in the next monthly release with the date.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

