用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Morrison-Lab/ai-config --skill compress-session命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | compress-session |
| description | Distill context before compacting. |
| user-invocable | true |
| allowed-tools | ["Bash","Read","Write"] |
Claude Code auto-compacts long conversations on its own once the context window fills up (see What survives compaction). The automatic pass guesses what to keep. This skill runs before that happens so a higher-fidelity, structured distillation — one the agent actually controls — is what carries forward, using two mechanisms Claude Code already provides rather than any custom hook:
MEMORY.md) is re-injected from disk automatically after
any compaction — no hook needed. Writing the distillation there is enough
to survive compaction./compact — running /compact focus on <what matters> before the automatic pass kicks in lets the summary keep what
you choose, instead of what the automatic pass guesses.checkpoint — that's a deliberate mid-task snapshot triggered by task
phase, written to its own topic file under the same memory directory
(not MEMORY.md itself, since it doesn't need to survive compaction
automatically the way this skill's distillation does). See checkpoint's
distinction table.handoff — that's for ending/pausing the session; this skill doesn't
end anything, it just makes sure the parts worth keeping survive the
next compaction, automatic or manual.MEMORY.md) preserves.MEMORY.mdMEMORY.md lives at ~/.claude/projects/<project>/memory/MEMORY.md (the
same auto-memory directory handoff/checkpoint/memorize use) and its
first 200 lines or 25KB, whichever is smaller, are re-injected into context
automatically after every compaction — this is the load-bearing property
this skill relies on. Keep the entry itself short and move real detail into
a separate topic file in the same directory (referenced from MEMORY.md),
since only MEMORY.md itself is guaranteed to reload after compaction —
topic files reload only when Claude reads them again.
Capture, concisely:
Update the existing MEMORY.md entry for this task in place rather than
appending a new one each time — MEMORY.md has a strict size budget for
what auto-reloads, so a growing pile of stale entries pushes the current,
relevant one past the 200-line/25KB cutoff.
Once the distillation is written, you can additionally run /compact focus on <what to keep> right away instead of waiting for the automatic pass.
Per context-window.md's "When your context fills up"
section:
"The summary keeps what you choose instead of what the automatic pass
guesses is important." This is optional (step 1 alone already protects the
distillation), but worth doing when you know compaction is imminent and
want the conversation summary itself — not just MEMORY.md — to reflect
a deliberate choice.
State that the distillation was written to MEMORY.md (and whether a
focused /compact was also triggered). Don't produce a long report — this
is meant to be a quick, low-ceremony action.
checkpoint — the deliberate, phase-triggered sibling that writes to
its own topic file rather than MEMORY.md itself, because it doesn't need
the auto-reload-after-compaction property. See its distinction table for
the trigger/scope difference.handoff — the session-end/pause counterpart; run that instead when
the session is actually stopping, not just compacting.memorize — general-purpose fact persistence via the same auto-memory
mechanism; this skill is the specialized "protect the highest-value facts
against the next compaction" case, with the added /compact focus
trigger.PreCompact/SessionStart hook is needed to survive
compaction — auto memory already re-injects MEMORY.md automatically;
don't add hook complexity for something the harness already does.MEMORY.md itself — topic files don't auto-reload after compaction, only
MEMORY.md's first 200 lines/25KB do.MEMORY.md entry per compaction instead of updating the
task's existing entry in place — bloats MEMORY.md past its auto-load
budget and pushes the current entry out.