ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 MichaelP17

compact-shaper

調整 Claude Code 的壓縮行為。一般壓縮會整理成交接內容;`/compact prune` 則裁剪可以重新讀取的工具輸出,同時逐字保留每則訊息。

MichaelP17@MichaelP17

MichaelP17/claude-mods/tree/main/compact-shaper

已翻譯

關於這個 mod

compact-shaper 為 Claude Code 提供兩種壓縮路徑:原生的 /compact 交接式摘要,以及 /compact prune。後者會把較長的工具輸出裁剪到開頭,並附上如何重新取得輸出的說明,同時完整保留所有訊息。它會保護子代理結果、失敗的工具呼叫,以及 git status 和 CI 記錄等狀態快照;如果節省不到 10%,就跳過裁剪,並透過 /config 或 settings.json 暴露 preserveRecentMessages 和 keepHeadChars。/prune-preview 指令可以預覽裁剪結果而不變更工作階段。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add MichaelP17/claude-mods
claude plugin install compact-shaper
原文 / README

compact-shaper

Shapes Claude Code's compaction. A normal compaction is summarized as a handoff; /compact prune cuts tool output that can be read again instead, and keeps every message word for word.

Two ways to compact

| Command | What happens | When it fits | | --- | --- | --- | | /compact | Claude Code's own summary, written along the structure of a handoff: goal, state, decisions and their reasons, rejected approaches, open points, next step, files to read first. Text after /compact is added to that structure | Several topics in, or the context is large; the summary is far smaller than anything a cut leaves | | /compact prune | Long tool outputs are cut to their head and a note on how to get them back; messages stay exactly as written | In the middle of a task, when the exact thread of the conversation matters more than the size |

The automatic compaction takes the first path. Subagents keep the native compaction unchanged.

/prune-preview shows what /compact prune would cut, without changing anything.

The handoff-shaped summary stays inside the session; it writes no HANDOFF.md. For a break between tasks, or to continue on another device, a written handoff and /clear beat both: cache-watch offers that at the right moments.

What /compact prune cuts

Every tool output longer than keepHeadChars + 200 characters, outside the first and the newest preserveRecentMessages messages, keeps its first keepHeadChars characters. Read results of a file that was later edited or read again in full count as superseded and are cut the same way. Edit and Write inputs shrink to their head, since the file on disk holds the current content.

Protected, because they cannot simply be produced again:

  • results of subagents (Agent, Task)
  • failed tool calls
  • git status, git stash list, gh run view and gh pr checks: snapshots of a state that has moved on, and CI logs that expire

A cut that saves less than 10% is skipped and leaves the conversation unchanged.

Configuration

| Option | Default | Meaning | | --- | --- | --- | | preserveRecentMessages | 6 | Newest messages that are never cut | | keepHeadChars | 300 | How much of a cut output stays |

Change them in /config, or in ~/.claude/settings.json under pluginConfigs["compact-shaper"].options.

更多類似作品