
Claude Code 技能:/handoff + /pickup。记录并清除你的会话,而不是用 /compact。
概览
一个用于跨会话管理上下文的Claude代码技能。你不让/compact决定模型记住什么,而是保存一个简短的策划交接笔记,并用一个干净的窗口开始下一次会话,只读取该笔记。 该方法符合Anthropic所描述的AI智能体有效上下文工程:持久笔记保持在上下文窗口外,并在后续会话中拉回。 - /compact 在上下文已经被填满时启动,此时模型“迟钝”,自行决定什么重要。- 每次压缩都会丢失一些东西:压缩一张照片会丢失细节,压缩会话时会丢失决策。一个又一个的压缩是复印件的复印件。- 交接是在有意且早期写入的(大约在上下文使用率约50-60%),一次选择性处理。它是你项目中的一个普通标记文件,方便你审查和修正。 1. 会话变得沉重,你输入 。
概述(AI 翻译)
一项用于跨会话管理上下文的Claude代码技能。你不让/compact决定模型记忆什么,而是保存一个简短的策划交接笔记,并用干净的窗口开始下一次会话,只阅读该笔记。
该方法符合Anthropic所描述的“有效上下文工程”中的结构化笔记:持续笔记保持在上下文窗口外,并在后续会话中拉回。
为什么不 /compact?
/compact在上下文已经填充时启动,此时模型“迟钝”,自行决定什么才重要。- 每次压缩都会失去一些东西:压缩一张照片会丢失细节,压缩会话时会丢失决策。一个又一个的压缩包都是复印件的复印件。
- 切换是有意且提前写入(大约50-60%上下文使用率),一次选择性处理。它是项目中的一个普通markdown文件,你可以查看并修正它。
它是如何运作的
- 会话变得繁重,于是你输入**
/handoff**。代理会写一条结构化笔记到 'session-logs/YYYY-MM-DD-TOPIC.
本页由 AI 翻译,技术细节请以原文为准。
README
handoff-skill: /handoff + /pickup for Claude Code
A Claude Code skill for managing context across sessions. Instead of letting /compact decide what the model remembers, you save a short curated handoff note and start the next session with a clean window, reading only that note.
The method matches what Anthropic describes as structured note-taking in Effective context engineering for AI agents: persistent notes kept outside the context window and pulled back in later sessions.
Why not /compact?
/compactkicks in when the context is already stuffed, and at that point the model is “dulled” and decides on its own what matters.- Every compression loses something: compress a photo and you lose detail, compress a session and you lose decisions. Compact after compact is a photocopy of a photocopy.
- A handoff is written deliberately and early (at roughly 50-60% context usage), in one selective pass. It is a plain markdown file in your project, so you can review and correct it.
How it works
- The session gets heavy, so you type
/handoff. The agent writes a structured note tosession-logs/YYYY-MM-DD-topic.md: summary, decisions, state (done / in progress / blocked), artifacts, the next step, and what NOT to do (dead ends). - You clear the window (
/clear) or open a new terminal. - In the fresh session you type
/pickup. The agent reads only the newest handoff (not the old conversation), verifies reality (git status/ls) and summarizes: where we are, the next step, what to avoid.
Installation
git clone https://github.com/simplybychris/handoff-skill.git
cd handoff-skill
mkdir -p ~/.claude/skills ~/.claude/commands
cp -R skills/session-handoff ~/.claude/skills/
cp commands/handoff.md commands/pickup.md ~/.claude/commands/
From now on /handoff [optional-topic] and /pickup [optional-topic] work in every project.
When to hand off (rough thresholds)
- Models with smaller windows: around 100k tokens.
- A standard 200k window: around 200k tokens is already the risk zone, aim earlier.
- A 1M window: around 300-400k tokens.
- Universal rule: ~50-60% of the context meter, not 90%. And do not interrupt a working implementation mid-step just because the meter grew; finish the micro-step, then save.
Research (including “Lost in the Middle” and Chroma’s test of 18 models) shows that the longer the context, the more often a model loses information from the middle of the conversation, even on trivial tasks.
Repo structure
handoff-skill/
├── skills/session-handoff/SKILL.md # the skill (mechanics, file format, rules)
├── commands/handoff.md # /handoff, save mode
└── commands/pickup.md # /pickup, resume mode
License
MIT
推荐工具
换一个关键词,或者移除筛选条件。
安装
npx skillfish add simplybychris/handoff-skill