Help us improve
Share bugs, ideas, or general feedback.
From cc-best
Compresses conversation context: saves task status, decisions, and todos to progress.md, generates _compact_summary.md, and guides clearing/restoring to reduce token usage.
npx claudepluginhub xiaobei930/cc-best --plugin cc-bestHow this command is triggered — by the user, by Claude, or both
Slash command
/cc-best:compact-contextThis command is limited to the following tools:
The summary Claude sees in its command listing — used to decide when to auto-load this command
# /compact-context - 上下文压缩 智能压缩当前对话上下文,保留关键信息,释放 token 空间。 > ⚠️ **重要提示**:官方 auto-compact 有已知 bug,建议在上下文 **70%** 时主动执行压缩。 > 详见:[#18211](https://github.com/anthropics/claude-code/issues/18211)、[#21853](https://github.com/anthropics/claude-code/issues/21853) ## 使用场景 - 对话过长,响应变慢 - 完成一个大功能后,准备开始新功能 - 上下文中有大量已完成任务的冗余讨论 - **上下文使用率接近 70%**(避免触发官方 bug) ## 执行流程 ### 1. 状态保存(必须) 在压缩前,确保以下信息已持久化到文件: ### 2. 生成压缩摘要 创建 `memory-bank/_compact_summary.md`(临时文件): ### 3. 压缩策略 | 保留 | 移除 | | -------------- | -------------------- | | 当前任务上下文 | 已完成任务的详细讨论 | | 关键决策和原因 | 冗余的代码...
/context-compactGenerates structured task summary with completed work, next steps, key files, branch, issue refs, and notes for context compaction near token limits.
/context-summarizationCompresses conversation history when context utilization nears 40%, writes structured summary to memory/, and starts fresh context window.
/smart-compactAnalyzes current conversation to generate optimized /compact command preserving high-value context (tasks, changes, errors), summarizing medium-value info, and discarding stale content.
/compact-guardSaves critical task state, edited files (up to 5), and decisions before compaction, then restores them to protect working context.
/dev-docs-updateUpdates dev documentation before context compaction: task status, session context, unfinished work, handoff notes for seamless continuation.
/context-saveCompacts session or saves full handoff to .handoff/ file with progress summary, git state, and next steps when context pressure detected.
Share bugs, ideas, or general feedback.
智能压缩当前对话上下文,保留关键信息,释放 token 空间。
⚠️ 重要提示:官方 auto-compact 有已知 bug,建议在上下文 70% 时主动执行压缩。 详见:#18211、#21853
在压缩前,确保以下信息已持久化到文件:
□ 当前任务状态 → progress.md
□ 重要决策 → progress.md 决策记录表
□ 待确认假设 → progress.md 待确认列表
□ 未完成的代码变更 → 已保存到文件
创建 memory-bank/_compact_summary.md(临时文件):
# 上下文压缩摘要
## 会话概述
- 开始时间: [时间]
- 主要目标: [目标]
- 完成状态: [X/Y 任务完成]
## 关键决策
1. [决策1]: [原因]
2. [决策2]: [原因]
## 当前状态
- 正在进行: [任务]
- 阻塞项: [如有]
## 重要发现
- [发现1]
- [发现2]
## 下一步
- [待办1]
- [待办2]
| 保留 | 移除 |
|---|---|
| 当前任务上下文 | 已完成任务的详细讨论 |
| 关键决策和原因 | 冗余的代码展示 |
| 待办事项 | 探索性的失败尝试 |
| 错误和解决方案 | 重复的文件读取 |
| 架构约束 | 已解决的问题讨论 |
progress.md 的 last_checkpoint 字段/clear| 命令 | 来源 | 行为 | 适用场景 |
|---|---|---|---|
/clear | 官方 | 完全清除上下文 | 任务完成,开始新任务 |
官方 /compact | 官方 | 自动压缩(有 bug) | 不推荐使用 |
本插件 compact-context | 本插件 | 保存状态 + 生成摘要 | 压缩前的准备工作 |
本插件 catchup | 本插件 | 恢复上下文 | /clear 后恢复 |
命令格式说明:根据安装方式不同,命令格式也不同:
- 通过
/plugin install安装:使用/cc-best:compact-context、/cc-best:catchup- 直接 clone 到
.claude/:使用/cc-best:compact-context、/cc-best:catchup
## 上下文压缩完成
### 已保存
- ✓ 进度状态 → progress.md
- ✓ 决策记录 → progress.md
- ✓ 压缩摘要 → _compact_summary.md
### 压缩摘要
[摘要内容]
### 下一步
执行官方 `/clear` 清除对话,然后执行 `/cc-best:catchup` 恢复上下文。
_compact_summary.md 是临时文件,恢复后可删除记住: 压缩时机很重要——70% 是最佳压缩点,超过 85% 可能失败。宁可早压缩也不要等到来不及。