chat-compactor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChat Compactor
Chat Compactor
Generate structured summaries optimized for AI agent continuity across sessions.
生成针对跨会话AI Agent连续性优化的结构化摘要。
Why This Exists
设计初衷
Human-written summaries and ad-hoc AI summaries lose critical context:
- Decision rationale gets lost (why X, not Y)
- Dead ends get forgotten (agent re-tries failed approaches)
- Implicit knowledge isn't captured (file locations, naming conventions, gotchas)
- State is unclear (what's done, what's pending, what's blocked)
This skill produces agent-optimized handoff documents that prime the next session.
人工撰写的摘要和临时生成的AI摘要会丢失关键上下文:
- 决策依据丢失(为什么选择X而非Y)
- 失败尝试被遗忘(Agent会重复尝试已失败的方法)
- 隐性知识未被捕获(文件位置、命名规范、潜在陷阱)
- 当前状态不明确(已完成、待处理、阻塞的内容分别是什么)
本Skill生成Agent优化的交接文档,为下一次会话做好准备。
Output Format
输出格式
Generate a markdown file with this structure:
markdown
undefined生成具有以下结构的Markdown文件:
markdown
undefinedSession: [Brief Title]
Session: [Brief Title]
Date: [YYYY-MM-DD]
Duration: ~[X] messages
Date: [YYYY-MM-DD]
Duration: ~[X] messages
Context Snapshot
Context Snapshot
[1-2 sentences: What project/task, what state it's in right now]
[1-2 sentences: What project/task, what state it's in right now]
What Was Accomplished
What Was Accomplished
- [Concrete outcome 1]
- [Concrete outcome 2]
- [Concrete outcome 1]
- [Concrete outcome 2]
Key Decisions & Rationale
Key Decisions & Rationale
| Decision | Why | Alternatives Rejected |
|---|---|---|
| [Choice] | [Reason] | [What didn't work and why] |
| Decision | Why | Alternatives Rejected |
|---|---|---|
| [Choice] | [Reason] | [What didn't work and why] |
Current State
Current State
- Working: [files/features that are functional]
- Broken/Blocked: [what's not working and why]
- Modified files: [list with brief note on changes]
- Working: [files/features that are functional]
- Broken/Blocked: [what's not working and why]
- Modified files: [list with brief note on changes]
Dead Ends (Don't Retry)
Dead Ends (Don't Retry)
- ❌ [Approach that failed] — [why it failed]
- ❌ [Approach that failed] — [why it failed]
Next Steps (Prioritized)
Next Steps (Prioritized)
- [Most important next action]
- [Second priority]
- [Most important next action]
- [Second priority]
Environment & Gotchas
Environment & Gotchas
- [Any setup notes, versions, quirks discovered]
- [Any setup notes, versions, quirks discovered]
Key Code/Commands Reference
Key Code/Commands Reference
[Only if there are non-obvious commands or snippets the next session needs]
undefined[Only if there are non-obvious commands or snippets the next session needs]
undefinedWorkflow
工作流程
- Scan conversation for: decisions, outcomes, failures, file changes, blockers
- Identify the "handoff moment" — what would a fresh agent need to continue?
- Generate structured summary using format above
- Save to file: in project root or
session-[topic]-[date].md/home/claude/sessions/
- 扫描对话:提取决策、成果、失败、文件变更、阻塞项等信息
- 确定“交接节点”:新Agent继续工作需要了解哪些信息?
- 生成结构化摘要:按照上述格式生成内容
- 保存文件:将文件保存至项目根目录或下,命名为
/home/claude/sessions/session-[topic]-[date].md
Compaction Triggers
压缩触发条件
Invoke this skill when:
- User says: "compact", "wrap up", "save session", "summarize for next time"
- Context window exceeds ~50% capacity and task is ongoing
- Before major context switches
- End of debugging/implementation session
在以下场景中调用本Skill:
- 用户提及:“压缩”“收尾”“保存会话”“为下一次总结”
- 上下文窗口已使用约50%容量且任务仍在进行中
- 进行重大上下文切换前
- 调试/实现会话结束时
Quality Criteria
质量标准
Good compactions are:
- Scannable: Next agent gets orientation in <30 seconds
- Actionable: Clear next steps, not vague summaries
- Defensive: Dead ends documented to prevent re-exploration
- Minimal: No fluff, every line earns its tokens
优质的压缩摘要需满足:
- 易扫描:新Agent可在30秒内了解会话概况
- 可执行:明确的下一步行动,而非模糊的总结
- 防御性:记录失败尝试以避免重复探索
- 极简:无冗余内容,每一行都有价值
Anti-Patterns
反模式
Avoid:
- Narrative prose ("First we tried X, then Y, then Z...")
- Redundant context (don't repeat what's in code comments)
- Vague summaries ("Made good progress on the feature")
- Missing failure documentation (most valuable part!)
需避免:
- 叙事性散文(“首先我们尝试了X,然后是Y,接着是Z……”)
- 冗余上下文(不要重复代码注释中已有的内容)
- 模糊的总结(“在功能上取得了不错的进展”)
- 遗漏失败记录(这是最有价值的部分!)
Example Trigger & Response
触发示例与响应
User: "Let's wrap up, compact this session"
Agent:
- Reviews conversation for key decisions, outcomes, failures
- Generates structured markdown per format above
- Saves to
session-[topic]-[date].md - Confirms: "Session compacted to — ready for next time."
session-auth-refactor-2025-01-06.md
用户:“我们收尾吧,压缩这个会话”
Agent:
- 回顾对话,提取关键决策、成果、失败项
- 按照上述格式生成结构化Markdown内容
- 将文件保存为
session-[topic]-[date].md - 确认:“会话已压缩至— 已为下一次会话做好准备。”
session-auth-refactor-2025-01-06.md