# compact-guard

> Claude/Codex skill by [@rohitg00](https://omgskills.com/library/rohitg00/index.md) · 2.8k stars · Updated 2026-07-27

Smart context compaction with state preservation. Saves critical files, task progress, and working state before compaction, restores after. Use before manual compact or when auto-compact triggers.

Tags: agent-orchestration, ai-agents, ai-coding, ai-workflow, claude, claude-code, claude-code-plugin, claude-code-skills, claude-skills, codex, context-engineering, cursor, developer-tools, gemini-cli, hooks, productivity, self-correction, workflow, worktrees

## Install

```sh
git clone https://github.com/rohitg00/pro-workflow /tmp/pro-workflow && ln -s /tmp/pro-workflow/skills/compact-guard ~/.claude/skills/compact-guard
```

## From README

Compact Guard Protect important context through compaction cycles. Based on Claude Code internals: compaction restores max 5 files with 5K tokens each, within a 50K total budget. Trigger Use before /compact or when auto-compact warning appears. Key Constants (from Claude Code source) POSTCOMPACTMAXFILESTORESTORE = 5 — only 5 files survive POSTCOMPACTTOKENBUDGET = 50K — total restore budget POSTCOMPACTMAXTOKENSPERFILE = 5K — per-file limit Auto-compact fires at contextwindow - 13K buffer Pre-Compact Checklist Before compacting, save these to memory or a scratch file: Current task — What are you working on? One sentence. Files in progress — Which files are being edited? (max 5 — compaction only restores 5) Decisions made — Any architectural choices made this session Blockers — What's preventing progress?

## Links

- HTML page: https://omgskills.com/library/rohitg00/pro-workflow/skills/compact-guard/
- GitHub: https://github.com/rohitg00/pro-workflow
- Author: [@rohitg00](https://omgskills.com/library/rohitg00/index.md)

## More from this repo

- [context-engineering](https://omgskills.com/library/rohitg00/pro-workflow/skills/context-engineering/index.md) — Master the four operations of context engineering — Write, Select, Compress, Isolate.
   - [@rohitg00](https://omgskills.com/library/rohitg00/index.md) · 2.9k stars
- [auto-setup](https://omgskills.com/library/rohitg00/pro-workflow/skills/auto-setup/index.md) — Auto-configure quality gates, hooks, and settings for a new project.
   - [@rohitg00](https://omgskills.com/library/rohitg00/index.md) · 2.8k stars
- [batch-orchestration](https://omgskills.com/library/rohitg00/pro-workflow/skills/batch-orchestration/index.md) — Decompose large-scale changes into independent units and spawn parallel agents in isolated worktrees.
   - [@rohitg00](https://omgskills.com/library/rohitg00/index.md) · 2.8k stars
