建议在逻辑间隔处进行手动压缩(Manual Compaction),以在整个任务阶段保持上下文(Context),而非随意的自动压缩。
Scanned 9/8/2026
Install to Claude Code
npx -y skills add xu-xiang/everything-claude-code-zh --skill strategic-compact --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Strategic Compact?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/xu-xiang-strategic-compact-d9e2d739)More formats (shields.io, HTML) on the badges page.
---
name: strategic-compact
description: 建议在逻辑间隔处进行手动压缩(Manual Compaction),以在整个任务阶段保持上下文(Context),而非随意的自动压缩。
---
# 策略性压缩(Strategic Compact)技能
建议在工作流的战略点手动执行 `/compact` 命令,而不是依赖随意的自动压缩。
## 为什么需要策略性压缩?
自动压缩会在任意点触发:
- 通常发生在任务中途,导致丢失关键上下文
- 无法识别任务的逻辑边界
- 可能会中断复杂的跨步骤操作
在逻辑边界处进行策略性压缩:
- **探索后、执行前** - 压缩研究上下文,保留实现计划
- **里程碑完成后** - 为下一阶段开启全新开始
- **重大上下文切换前** - 在处理不同任务前清理探索上下文
## 工作原理
`suggest-compact.sh` 脚本在工具调用前(PreToolUse,针对 Edit/Write)执行:
1. **追踪工具调用** - 统计会话(Session)内的工具调用次数
2. **阈值检测** - 达到可配置阈值时给出建议(默认:50 次)
3. **定期提醒** - 超过阈值后每 25 次调用提醒一次
## 钩子(Hook)配置
添加到 `~/.claude/settings.json`:
```json
{
"hooks": {
"PreToolUse": [{
"matcher": "tool == \"Edit\" || tool == \"Write\"",
"hooks": [{
"type": "command",
"command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
}]
}]
}
}
```
## 配置
环境变量:
- `COMPACT_THRESHOLD` - 触发首次建议前的工具调用次数(默认:50)
## 最佳实践
1. **计划后压缩** - 计划确定后,进行压缩并全新开始
2. **调试后压缩** - 在继续前清理错误解决上下文
3. **实现过程中不压缩** - 为相关变更保留上下文
4. **阅读建议** - 钩子(Hook)会提示*何时*压缩,但*是否执行*由你决定
## 相关资源
- [The Longform Guide](https://x.com/affaanmustafa/status/2014040193557471352) - 令牌(Token)优化章节
- 内存持久化钩子 - 用于在压缩后仍需保留的状态
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!
Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.
Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...
Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.
Recovers prior coding-agent session context by running `catchup <agent> --since-compact`, which extracts a clean summary of a previous Codex, Claude Code, Antigravity, OpenCode, or Pi Agent session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", or asks to recover/summarize a previous session before continuing. Do NOT use for the current conversation, git history, or any non-agent log.
A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling