close
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/close
/close
Capture learnings while context is rich, then commit and exit.
在上下文信息完整时梳理经验,然后提交并退出。
When to Use
适用场景
- Session ending naturally (work complete)
- Context window nearly full
- User says "wrap up", "let's finish", "one more thing then done"
- Main task complete and about to summarize
- 会话自然结束(工作已完成)
- 上下文窗口即将占满
- 用户提及“wrap up”“let's finish”“one more thing then done”
- 主要任务完成,即将进行总结
When NOT to Use
不适用场景
- Mid-session checkpoint (pause and check direction instead)
- Quick question that doesn't need handoff
- Exploratory work with no conclusions yet
- 会话中途检查点(此时应暂停并确认方向)
- 无需交接的快速问题
- 尚未得出结论的探索性工作
Structure
流程结构
Prerequisites → Verify infrastructure
Pre-flight → Return to home directory
Gather → todos, tracker (bon), git, drift, SESSION_ID
Orient → Claude answers six questions in prose → user responds
Decide → Claude proposes Now/Next plan → user amends (STOP)
Act → execute, write handoff, stage extraction, commit
Remember → index session (background, automatic)Prerequisites → 验证基础设施
Pre-flight → 返回主目录
Gather → 待办事项、追踪器(bon)、git、偏差、SESSION_ID
Orient → Claude用散文形式回答六个问题 → 用户回复
Decide → Claude提出Now/Next计划 → 用户修改(暂停执行)
Act → 执行计划、撰写交接文档、准备提取内容、提交
Remember → 索引会话(后台自动执行)Prerequisites
前置条件
Before running /close, verify infrastructure is healthy. Broken scripts mean lost handoffs.
| Check | How | If Broken |
|---|---|---|
| close-context.sh exists | | Run |
| check-home.sh exists | | Fix symlinks |
| Handoffs dir writable | | Create: |
Quick pre-flight:
bash
[ -x ~/.claude/scripts/close-context.sh ] && [ -x ~/.claude/scripts/check-home.sh ] && echo "OK" || echo "BROKEN"If broken: STOP, diagnose, then write handoff manually rather than skipping closure entirely. See .
~/Repos/trousse/references/ERROR_PATTERNS.md运行/close前,请验证基础设施是否正常。 脚本故障会导致交接文档丢失。
| 检查项 | 检查方式 | 故障处理 |
|---|---|---|
| close-context.sh是否存在 | | 运行 |
| check-home.sh是否存在 | | 修复符号链接 |
| Handoffs目录是否可写 | | 创建目录: |
快速预检命令:
bash
[ -x ~/.claude/scripts/close-context.sh ] && [ -x ~/.claude/scripts/check-home.sh ] && echo "OK" || echo "BROKEN"若故障:立即停止,先诊断问题,再手动撰写交接文档,切勿跳过收尾流程。详情请见。
~/Repos/trousse/references/ERROR_PATTERNS.mdPre-flight: Return Home (MANDATORY)
预检:返回主目录(必填)
You may have 'd during work. Your system prompt contains in the block — this is immutable, where the session actually started.
cdWorking directory: /path/...<env>- Extract that exact path from your system prompt
- Run:
~/.claude/scripts/check-home.sh "/that/path" - If , run
CD_REQUIRED=trueimmediatelycd <HOME_DIR>
Do not skip. Do not trust pwd. Do not reason about whether you moved back. The script is authoritative.
工作过程中你可能执行过命令切换目录。系统提示的块中包含,这是会话实际启动的不可变路径。
cd<env>Working directory: /path/...- 从系统提示中提取该精确路径
- 运行:
~/.claude/scripts/check-home.sh "/that/path" - 若返回,立即执行
CD_REQUIRED=truecd <HOME_DIR>
请勿跳过此步骤。不要信任pwd命令的结果,也不要自行判断是否已返回主目录。脚本的判断是权威的。
Gather
收集信息
bash
~/.claude/scripts/close-context.shScript outputs: TIME, GIT, BON, LOCATION context, HANDOFF_DIR, SESSION_ID.
Use TIME_OF_DAY for greetings. Use YEAR to anchor the handoff date. Hold onto HANDOFF_DIR and SESSION_ID — you'll need both in Act.
bash
~/.claude/scripts/close-context.sh脚本输出内容包括:TIME、GIT、BON、LOCATION上下文、HANDOFF_DIR、SESSION_ID。
使用TIME_OF_DAY生成问候语,使用YEAR标记交接文档日期。请牢记HANDOFF_DIR和SESSION_ID——在Act阶段会用到这两个参数。
Script Failure Handling
脚本故障处理
If the script fails (exit code 127 = file not found, or any error):
- STOP. Tell the user: "close-context.sh failed. Likely a broken symlink."
- Diagnose: Run
~/.claude/scripts/check-symlinks.sh - Fallback: If you can't fix it, write handoff manually to — don't skip closure entirely.
~/.claude/handoffs/<encoded-path>/
Why this matters: Broken scripts (Jan 3-10 2026) meant /close ran without proper context gathering. Never continue silently.
From script output, assess:
- Work progress — what's done, what's incomplete?
- Tracker — Bon: open items to complete or defer
- Git — uncommitted files? unpushed commits?
- Drift — what did /open say we'd do vs what we actually did?
Surface stale artifacts: screenshots, temp files, old sketches, superseded plans.
若脚本执行失败(退出码127表示文件未找到,或其他错误):
- 立即停止,告知用户:“close-context.sh执行失败,可能是符号链接损坏。”
- 诊断问题:运行
~/.claude/scripts/check-symlinks.sh - 备选方案:若无法修复,手动将交接文档写入——切勿完全跳过收尾流程。
~/.claude/handoffs/<encoded-path>/
重要性说明:2026年1月3日-10日期间曾出现脚本故障,导致/close命令在未收集完整上下文的情况下运行。切勿静默继续执行。
根据脚本输出,评估以下内容:
- 工作进度——已完成和未完成的工作
- 追踪器——Bon中待完成或需延期的事项
- Git状态——是否有未提交文件?未推送的提交?
- 偏差——/open命令中计划的工作与实际完成的工作有何差异?
清理过时产物:截图、临时文件、旧草图、已废弃的计划。
Orient
梳理反思
This is THE reflection. What emerges here feeds the handoff and the extraction. There is no second pass later.
Answer all six questions in prose — don't compress into bullets, don't pre-bake options. The point is surfacing what you noticed that the user might not have.
Looking Back:
- What did we forget? — Dropped intentions, docs now stale, tests we said we'd write, files touched with untraced downstream effects
- What did we miss? — Edge cases, unverified assumptions, things that work in test but may not in production
- What could we have done better? — Simpler approaches, abstractions in the wrong place, patterns from the codebase we ignored
Looking Ahead:
4. What could go wrong? — Race conditions, silent failures, fragile dependencies, things that work now but break when X changes
5. What won't make sense later? — Why we made a particular choice, implicit knowledge not written down, non-obvious relationships between files
6. What will we wish we'd done? — Tests, verification, documentation, conversations we should have had
Share these directly, then ask: "What resonates? What am I missing?"
Wait for the user's response. Their additions and corrections go into the handoff Reflection section verbatim.
这是核心的反思环节。此阶段得出的内容将用于交接文档和记忆提取,后续不会有二次梳理机会。
请用散文形式回答所有六个问题——不要压缩为项目符号,也不要预设选项。目的是挖掘你注意到但用户可能忽略的信息。
回顾总结:
- 我们遗漏了什么?——未落实的计划、已过时的文档、承诺要写的测试、修改后未追踪下游影响的文件
- 我们忽略了什么?——边缘案例、未验证的假设、测试环境可行但生产环境可能失效的内容
- 我们本可以做得更好的地方?——更简单的实现方式、错误的抽象位置、未遵循的代码库模式
前瞻思考:
4. 可能出现什么问题?——竞态条件、静默故障、脆弱的依赖关系、当前正常但X变更后会失效的内容
5. 后续可能无法理解的内容?——做出特定选择的原因、未记录的隐性知识、文件间非显而易见的关联
6. 我们会后悔没做什么?——测试、验证、文档、本该进行的沟通
直接分享以上思考,然后询问:“哪些内容你有共鸣?我还遗漏了什么?”
等待用户回复。用户补充和修正的内容将原封不动放入交接文档的Reflection部分。
Decide
决策阶段
STOP. Do not execute anything until this phase completes.
From Gather + Orient, identify all incomplete work and draft a concrete plan. Present it — don't ask the user what they want. Propose; let them amend.
立即停止,完成此阶段前请勿执行任何操作。
结合Gather和Orient阶段的结果,识别所有未完成工作并制定具体计划。主动提出计划——不要询问用户需求。先给出方案,再由用户修改。
Bucket everything
工作分类
Now — executes before /exit, benefits from current context:
- Incomplete work finishable in under 2 minutes
- Close a tracker item with resolution notes
- Update CLAUDE.md (local or global) when a clear pattern emerged
- Quick fixes where the how is obvious
Bon — each becomes a tracked item for a future session. Before filing any bon, answer: "If this never gets done, what breaks?" If the answer is "not much", it belongs in the handoff Next section, not a bon. This is the gate.
Handoff only — direction, context, and risks that don't rise to bon level.
Now——在/exit前执行,可利用当前上下文:
- 2分钟内可完成的未完成工作
- 用解决记录关闭追踪器事项
- 当明确模式出现时,更新CLAUDE.md(本地或全局)
- 操作方式明确的快速修复
Bon——每个事项将成为未来会话的追踪项。在创建Bon前,请回答:“如果永远不做这件事,会有什么影响?” 如果答案是“影响不大”,则应放入交接文档的Next部分,而非Bon。这是筛选标准。
仅交接——无需追踪的方向、上下文和风险信息。
Present the plan
提交计划
"Here's my plan:Now: [concrete list — things I'll do before /exit]Bons to file: [each with one line on what breaks if skipped]Handoff only: [things worth noting but not tracking]Tell me if anything should move."
Wait for approval. Nothing executes until the user confirms or amends.
“我的计划如下:Now: [具体列表——/exit前要完成的工作]待创建的Bon事项: [每个事项需包含一行说明:若跳过会有什么影响]仅交接内容: [值得记录但无需追踪的信息]请告诉我是否需要调整。”
等待用户确认。用户确认或修改后,方可执行后续操作。
Act
执行阶段
Execute in this order.
请按以下顺序执行。
Execute "Now" items
执行“Now”事项
Do the approved immediate actions: finish incomplete todos, close tracker items with notes, update CLAUDE.md, quick fixes.
完成已确认的即时操作:完成待办事项、用记录关闭追踪器事项、更新CLAUDE.md、快速修复。
File bons
创建Bon事项
For each approved item:
bash
bon new "title" --why "consequence if not done" --what "concrete actions" --done "definition of done"--why对于每个已确认的事项:
bash
bon new "title" --why "不执行的后果" --what "具体操作" --done "完成标准"--whyWrite handoff
撰写交接文档
Handoff location is non-negotiable. The script computes the path; you use it exactly.
bash
~/.claude/scripts/close-context.sh | grep -E 'HANDOFF_DIR|SESSION_ID'This outputs both — use them directly, never recompute.
| Rule | Why |
|---|---|
Write to | Central location, /open finds it |
Never write locally ( | /open won't find it — information becomes invisible |
| Never compute path yourself | Encoding differences cause folder fragmentation |
Why this matters (Jan 2026 incident): A Claude wrote to locally. The next session's /open loaded a stale handoff instead — the work existed but was invisible to the protocol.
.handoff-kube-migration.mdFallback: If SESSION_ID is empty (script failed), use timestamp:
2026-01-04-2215.mdFilename: first 8 chars of SESSION_ID +
Example: →
.mdSESSION_ID=51d17dc5-b714-481c-9dfb-6d4128800e7b51d17dc5.mdHandoff template:
undefined交接文档的存储位置不可更改。脚本会计算路径,请直接使用该路径。
bash
~/.claude/scripts/close-context.sh | grep -E 'HANDOFF_DIR|SESSION_ID'该命令会输出两个参数——请直接使用,切勿自行计算。
| 规则 | 原因 |
|---|---|
写入 | 集中存储,/open命令可找到 |
切勿写入本地(如项目中的 | /open命令无法找到——信息会变得不可见 |
| 切勿自行计算路径 | 编码差异会导致文件夹碎片化 |
重要案例(2026年1月事件):某Claude将交接文档写入本地,导致下一会话的/open命令加载了过时的交接文档——工作内容存在但协议无法识别。
.handoff-kube-migration.md备选方案:若SESSION_ID为空(脚本故障),使用时间戳命名:
2026-01-04-2215.md文件名格式:SESSION_ID的前8个字符 +
示例: →
.mdSESSION_ID=51d17dc5-b714-481c-9dfb-6d4128800e7b51d17dc5.md交接文档模板:
undefinedHandoff — {DATE}
交接文档 — {DATE}
session_id: {SESSION_ID}
purpose: {first Done bullet, truncated to ~60 chars}
session_id: {SESSION_ID}
purpose: {第一个Done事项的摘要,约60字符}
Done
已完成
- [Completions in verb form — include item ID if closing one] e.g., "Fixed auth bug (claude-go-xyz)" or "Completed migration (bon-gutowa)"
- [动词形式的完成内容——若关闭追踪项请包含事项ID] 示例:"修复认证漏洞(claude-go-xyz)"或"完成迁移(bon-gutowa)"
Gotchas
注意事项
[What would trip up next Claude — specific, not generic]
[后续Claude可能遇到的问题——具体而非泛泛]
Risks
风险
[What could go wrong with what we built]
[我们构建的内容可能出现的问题]
Next
后续工作
[Direction for next session]
[下一会话的方向]
Artifacts
产物
[Only if Google Drive work — see Knowledge Work section]
[仅适用于Google Drive工作——见知识工作部分]
Commands
命令
Optional — verification or continuation commands
可选——验证或后续操作命令
Reflection
反思
Claude observed: [Key observations from Orient]
User noted: [What they added or emphasized]
undefinedClaude观察到: [Orient阶段的关键结论]
用户补充: [用户添加或强调的内容]
undefinedKnowledge Work Context (Google Drive)
知识工作上下文(Google Drive)
When working in Google Drive (not ~/Repos): Add an Artifacts section.
You already know what you touched — you called MCP tools during the session. Recall which docs you read (), updated (, ), or browsed ().
get_contentupdate_docappend_to_doclist_filesundefined当在Google Drive(而非~/Repos)中工作时:添加产物部分。
你已了解自己操作过的内容——会话中调用过MCP工具。回忆你读取()、更新(/)或浏览()的文档。
get_contentupdate_docappend_to_doclist_filesundefinedArtifacts
产物
Working folder: Project Name
This session:
- Updated: Contract Stewardship Doc — added supplier descriptions
- Created: Q1 Review Notes
- Referenced: Budget Template — read-only
Knowledge work doesn't have commits. This is the equivalent. Next Claude can `get_content()` on these links to pull current state — links are stable, content is always fresh.Stage extraction for memory
准备记忆提取内容
After writing the handoff, generate a session extraction from your live context. This replaces the expensive subprocess the session-end hook would otherwise spawn.
claude -pWrite the extraction JSON using the Write tool to :
/tmp/garde-extraction.jsonjson
{
"summary": "2-3 sentences — what happened and why it matters",
"arc": {
"started_with": "initial goal/problem",
"key_turns": ["pivots, discoveries, changes in direction"],
"ended_at": "final state"
},
"builds": [{"what": "thing created/modified", "details": "context"}],
"learnings": [{"insight": "what was learned", "why_it_matters": "significance", "context": "how discovered"}],
"friction": [{"problem": "what was hard", "resolution": "how resolved or 'unresolved'"}],
"patterns": ["recurring themes, collaboration style, meta-observations"],
"open_threads": ["unfinished business, deferred work"]
}Guidelines:
- = the "so what" — why this session mattered, not what was done
summary - = concrete artifacts: code, config, docs, skills
builds - = insights that transfer to other contexts (not just "I learned X exists")
learnings - = things harder than expected and how they resolved
friction - = deferred, not abandoned
open_threads
Then stage it:
bash
~/.claude/scripts/stage-extraction.sh < /tmp/garde-extraction.json \
&& rm /tmp/garde-extraction.jsonThe script computes the correct UUID filename and places it where the hook expects. If the script is missing (fresh install before runs), the hook falls back to — safe to continue.
install.shgarde process撰写完交接文档后,从当前上下文生成会话提取内容。这将替代会话结束钩子原本会启动的昂贵子进程。
claude -p使用Write工具将提取内容JSON写入:
/tmp/garde-extraction.jsonjson
{
"summary": "2-3句话——会话内容及其重要性",
"arc": {
"started_with": "初始目标/问题",
"key_turns": ["转折点、发现、方向变更"],
"ended_at": "最终状态"
},
"builds": [{"what": "创建/修改的内容", "details": "上下文"}],
"learnings": [{"insight": "学到的内容", "why_it_matters": "重要性", "context": "发现过程"}],
"friction": [{"problem": "遇到的困难", "resolution": "解决方式或‘未解决’"}],
"patterns": ["重复出现的主题、协作方式、元观察"],
"open_threads": ["未完成的工作、延期的任务"]
}指导原则:
- = 核心价值——会话的重要性,而非具体做了什么
summary - = 具体产物:代码、配置、文档、技能
builds - = 可迁移到其他场景的洞见(不只是“我了解了X的存在”)
learnings - = 比预期更困难的内容及其解决方式
friction - = 延期而非放弃的工作
open_threads
然后准备提取内容:
bash
~/.claude/scripts/stage-extraction.sh < /tmp/garde-extraction.json \
&& rm /tmp/garde-extraction.json脚本会计算正确的UUID文件名并放入钩子预期的位置。若脚本缺失(运行前的全新安装),钩子会回退到——可安全继续执行。
install.shgarde processCommit
提交代码
If git dirty in the working directory:
- Stage relevant files (handoff too if the repo is the project)
- Commit with standard message + co-authorship
- Push if user approves
Only commit the working directory. Other repos' dirty state is not your concern.
若工作目录的Git状态为dirty:
- 暂存相关文件(若仓库是项目仓库,也需暂存交接文档)
- 使用标准提交信息并添加共同作者
- 若用户同意,推送提交
仅提交当前工作目录,无需关心其他仓库的dirty状态。
Tell user to exit
告知用户退出
Say: "Type to close." Don't exit programmatically.
/exit提示:“输入以关闭会话。” 请勿以编程方式自动退出。
/exitRemember
后台索引
Automatic — handled by session-end hook. You don't invoke this.
The hook () takes one of two paths when the user runs :
~/.claude/hooks/session-end.sh/exit-
Staged extraction exists (the file you wrote above):
- on the session (fast, no LLM)
garde index - with your pre-generated JSON
garde store-extraction - Staging file removed
- No subprocess spawned
-
No staged extraction (crash, ctrl-c, no /close):
- Falls back to — spawns
garde processto extract from the raw transcriptclaude -p - Same quality, slower, costs a subprocess
- Falls back to
Either way, handoffs are scanned afterward. Just tell the user to .
/exit自动执行——由会话结束钩子处理,无需手动调用。
当用户运行时,钩子()会执行以下两种路径之一:
/exit~/.claude/hooks/session-end.sh-
存在已准备的提取内容(你写入的文件):
- 对会话执行(快速,无需LLM)
garde index - 使用你预先生成的JSON执行
garde store-extraction - 删除准备文件
- 无需启动子进程
- 对会话执行
-
无已准备的提取内容(崩溃、ctrl-c、未使用/close):
- 回退到——启动
garde process子进程从原始会话记录中提取内容claude -p - 质量相同,但速度更慢,且需要子进程
- 回退到
无论哪种情况,后续都会扫描交接文档。只需告知用户输入即可。
/exitAnti-Patterns
反模式
| Pattern | Problem | Fix |
|---|---|---|
| Compress Orient into bullets or options | Misses unexpected observations | Answer six questions in prose |
| Ask "what do you want?" in Decide | Puts burden on user, invites deferral | Propose a concrete plan; user amends |
File bons with weak | Future Claude can't prioritise | State the consequence of skipping |
| Skip pre-flight cd check | Handoff written to wrong project | Always run check-home.sh |
| Write handoff locally (.handoff.md) | /open won't find it | Use HANDOFF_DIR from script |
| Silently drop incomplete work | Work disappears | Every piece in Now, bon, or handoff Next |
| Commit other repos | Unwanted "helpful" tidying | Only commit working directory |
| Recompute SESSION_ID or HANDOFF_DIR | Encoding drift, folder fragmentation | Read from close-context.sh output |
| 模式 | 问题 | 修复方案 |
|---|---|---|
| 将Orient阶段压缩为项目符号或选项 | 遗漏意外发现 | 用散文形式回答六个问题 |
| 在Decide阶段询问“你想怎么做?” | 将负担转嫁给用户,导致拖延 | 提出具体计划,由用户修改 |
创建Bon时 | 后续Claude无法确定优先级 | 明确说明跳过的后果 |
| 跳过预检的cd检查 | 交接文档写入错误项目 | 始终运行check-home.sh |
| 将交接文档写入本地(.handoff.md) | /open命令无法找到 | 使用脚本输出的HANDOFF_DIR |
| 静默丢弃未完成工作 | 工作内容丢失 | 所有工作必须归入Now、Bon或交接文档的Next部分 |
| 提交其他仓库 | 不必要的“善意”整理 | 仅提交当前工作目录 |
| 自行计算SESSION_ID或HANDOFF_DIR | 编码偏差、文件夹碎片化 | 从close-context.sh输出中读取 |
GODAR Reference
GODAR参考对照表
| Phase | /open | /close |
|---|---|---|
| Gather | Handoff, tracker, script | Tracker, git, drift; HANDOFF_DIR + SESSION_ID |
| Orient | "Where we left off" | Six questions in prose → user responds |
| Decide | User picks direction | Claude proposes Now/Bon/Handoff plan → user amends |
| Act | Draw-down from Bon | Execute, write handoff, stage extraction, commit |
| Remember | — | Index session (background, automatic on /exit) |
| 阶段 | /open | /close |
|---|---|---|
| Gather(收集) | 交接文档、追踪器、脚本 | 追踪器、git、偏差;HANDOFF_DIR + SESSION_ID |
| Orient(梳理) | “上次会话进度” | 六个问题的散文回答 → 用户回复 |
| Decide(决策) | 用户选择方向 | Claude提出Now/Bon/Handoff计划 → 用户修改 |
| Act(执行) | 从Bon中提取任务 | 执行计划、撰写交接文档、准备提取内容、提交 |
| Remember(记忆) | — | 索引会话(/exit时后台自动执行) |