compact-guard

Preserves task state and critical files across Claude Code context compaction cycles.

1|Updated May 6, 2026
One-click install
npx skills add https://github.com/surfingalien/FinSurfing --skill compact-guard-surfingalien
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compact-guard
Source: https://github.com/surfingalien/FinSurfing/tree/main/.claude/skills/compact-guard
Command: npx skills add https://github.com/surfingalien/FinSurfing --skill compact-guard-surfingalien

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Context compaction in Claude Code can silently drop the files and task state you were actively working on, forcing you to rebuild context from scratch. This Skill saves your working state before compaction and guides recovery afterward. ## Core Features & Use Cases - Pre-Compact Checklist: Captures current task, files in progress, decisions, blockers, and next steps before running /compact. - Compaction Internals Reference: Documents Claude Code limits such as 5 restored files, 5K tokens per file, and a 50K total restore budget. - Prevention Strategies: Advises delegating searches to subagents, reading partial file ranges, and compacting at task boundaries to reduce token pressure. - Use Case: You receive an auto-compact warning mid-refactor. Run the checklist to record your five active files and next steps, compact safely, then resume exactly where you left off. ## Quick Start Before running /compact, ask the assistant to save my current task state and the top five files I am editing using compact-guard.

Frequently Asked Questions about compact-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid losing context when compacting in Claude Code?

Save your current task, the files you are editing, key decisions, and next steps to a scratch note before running /compact. After compaction, re-read your top-priority file first, since only up to 5 files are restored automatically.

How many files does Claude Code restore after compaction?

Claude Code restores a maximum of 5 files after compaction, with up to 5K tokens per file and a 50K total restore budget. Prioritize the file you are actively editing as the first one to restore.

When does auto-compact trigger in Claude Code?

Auto-compact fires when the context fills to the window size minus a 13K token buffer. When the warning appears, save your working state immediately before the compaction runs.

How can I reduce token usage before compacting?

Delegate broad grep and search tasks to subagents, read only needed line ranges with offset and limit, and compact at natural task boundaries. These strategies can cut token usage by 30-90% per operation.

What should I do immediately after a compaction completes?

Re-read the file you were actively editing, check your task list for current progress, review any scratch notes saved before compacting, and resume from your recorded next steps.