ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
Reddit 貼文 · 發布者 drkokorev

Context Diet:一個防止龐大工具輸出淹沒上下文的 Claude Code 模組

Context Diet 在 Claude 讀取大型工具輸出(測試執行、建置、差異、日誌)之前對其進行裁剪,僅保留失敗、摘要和相關結構,並將完整輸出儲存到檔案以便後續檢索。

已翻譯

關於這個 mod

一次測試執行或建置日誌就能向 Claude 的上下文中傾倒 30–50k 字元,其中幾乎全是雜訊:數千行 PASSED、棄用警告、鎖定檔案差異。上下文被填滿,壓縮更早到來,Claude 忘記了你在開始時說的話。

Context Diet 在 Claude 讀取每個大型輸出之前對其進行裁剪:

  • 測試和建置(pytest、jest、go test、cargo、tsc……)→ 僅保留失敗和摘要
  • JSON → 其結構
  • 差異 → 不含鎖定檔案變動
  • 日誌 → 帶上下文的錯誤

完整輸出始終儲存到檔案,因此 Claude 在需要更多資訊時可以讀取它。額外好處:當測試執行失敗時,Claude Code 會截斷輸出的末尾,而失敗恰恰就在那裡。Context Diet 將它們恢復。

在 18 次代理執行中測試:修復了相同的錯誤,工具呼叫從 8 次減少到 6 次。

安裝:

/plugin marketplace add drkokorev/context-diet /plugin install context-diet@context-diet

https://github.com/drkokorev/context-diet

安裝

安裝方式請查看原始來源。

原文 / README

A single test run or build log can dump 30–50k characters into Claude’s context, almost all of it noise: thousands of PASSED lines, deprecation warnings, lockfile diffs. The context fills up, compaction comes sooner, and Claude forgets what you said at the start. Context Diet trims every big output before Claude reads it: tests and builds (pytest, jest, go test, cargo, tsc…) → only the failures and the summary JSON → its structure, diffs → without lockfile churn, logs → errors with context the full output is always saved to a file, so Claude can read it when it needs more Bonus: when a test run fails, Claude Code cuts the end of the output, exactly where the failures are. Context Diet gives them back. Tested on 18 agent runs: same bugs fixed, 6 tool calls instead of 8. /plugin marketplace add drkokorev/context-diet /plugin install context-diet@context-diet https://github.com/drkokorev/context-diet submitted by /u/drkokorev to r/ClaudeCodeMods [link] [comments]

其他同名作品

更多類似作品