compact-guard

仓库创建 2026年2月2日最近提交 6 天前SkillHot 收录 20 天前
▸ 精选理由

保护关键状态避免 compaction 导致信息丢失。

这个 Skill 做什么

在上下文压缩前保存重要文件与进度,并在后续恢复。

在做上下文压缩前先把关键文件、任务进度和当前工作状态保存好,压缩后再尽量恢复这些内容,防止重要信息被丢。适合在手动执行 /compact 或收到自动压缩提醒时使用。特别会遵循 Claude Code 的恢复限额和 token 预算,优先保留对后续工作最重要的少量大文件。

▸ 展开 SKILL.md 英文原文

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.

Skill 开发管理上下文保全自动压缩状态恢复Claude Code
2.7k
Stars
257
Forks
40
仓库内 Skill
+55
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/rohitg00/pro-workflow/main/skills/compact-guard/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/rohitg00/pro-workflow/main/skills/compact-guard/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# 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)

- `POST_COMPACT_MAX_FILES_TO_RESTORE = 5` — only 5 files survive
- `POST_COMPACT_TOKEN_BUDGET = 50K` — total restore budget
- `POST_COMPACT_MAX_TOKENS_PER_FILE = 5K` — per-file limit
- Auto-compact fires at `context_window - 13K` buffer

## Pre-Compact Checklist

Before compacting, save these to memory or a scratch file:

1. **Current task** — What are you working on? One sentence.
2. **Files in p
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有