chat-compactor

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Chat 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
undefined

Session: [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

DecisionWhyAlternatives Rejected
[Choice][Reason][What didn't work and why]
DecisionWhyAlternatives 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)

  1. [Most important next action]
  2. [Second priority]
  1. [Most important next action]
  2. [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]
undefined

Workflow

工作流程

  1. Scan conversation for: decisions, outcomes, failures, file changes, blockers
  2. Identify the "handoff moment" — what would a fresh agent need to continue?
  3. Generate structured summary using format above
  4. Save to file:
    session-[topic]-[date].md
    in project root or
    /home/claude/sessions/
  1. 扫描对话:提取决策、成果、失败、文件变更、阻塞项等信息
  2. 确定“交接节点”:新Agent继续工作需要了解哪些信息?
  3. 生成结构化摘要:按照上述格式生成内容
  4. 保存文件:将文件保存至项目根目录或
    /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:
  1. Reviews conversation for key decisions, outcomes, failures
  2. Generates structured markdown per format above
  3. Saves to
    session-[topic]-[date].md
  4. Confirms: "Session compacted to
    session-auth-refactor-2025-01-06.md
    — ready for next time."
用户:“我们收尾吧,压缩这个会话”
Agent
  1. 回顾对话,提取关键决策、成果、失败项
  2. 按照上述格式生成结构化Markdown内容
  3. 将文件保存为
    session-[topic]-[date].md
  4. 确认:“会话已压缩至
    session-auth-refactor-2025-01-06.md
    — 已为下一次会话做好准备。”