compact-guard

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

2.8k|277|Updated Feb 1, 2026
One-click install
npx skills add https://github.com/rohitg00/pro-workflow --skill compact-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compact-guard
Source: https://github.com/rohitg00/pro-workflow/tree/main/skills/compact-guard
Command: npx skills add https://github.com/rohitg00/pro-workflow --skill compact-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Context compaction in Claude Code silently drops working state: only 5 files survive within a 50K token budget, and task progress, decisions, and blockers vanish. This Skill saves critical context before compaction and restores it afterward so work continues without losing the thread.

Core Features & Use Cases

  • Pre-Compact Checklist: Captures the current task, files in progress, decisions, blockers, and next steps before running /compact.
  • Post-Compact Recovery: Re-reads the top-priority file, checks task progress, and resumes from saved next steps after compaction.
  • Token Prevention Strategies: Delegates searches to subagents, reads partial file ranges, and compacts at task boundaries to reduce context pressure.
  • Use Case: You are mid-refactor when the auto-compact warning appears. Run compact-guard to snapshot your working state, compact safely, then resume editing exactly where you left off.

Quick Start

Ask the assistant to run compact-guard to save my current task state before compacting the conversation.

Frequently Asked Questions about compact-guard

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

FAQPage Schema
How do I preserve context when compacting a Claude Code session?

Save your current task, files in progress, decisions, blockers, and next steps to memory or a scratch file before running /compact. After compaction, re-read your top-priority file and resume from the saved next steps.

How many files survive Claude Code compaction?

Compaction restores a maximum of 5 files, 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 approaches the window limit minus a 13K token buffer. When the warning appears, save your working state immediately before the compaction cycle runs.

How can I reduce token usage to avoid compaction?

Delegate broad grep and search operations to subagents, read only needed file lines with offset and limit parameters, and compact at logical task boundaries. These strategies can cut token usage by 30-90% per operation.

What should I do if auto-compact fires unexpectedly?

Immediately re-read the file you were actively editing, then check your task list and any scratch notes saved before compaction. Resume work from the recorded next steps rather than restarting exploration.