mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-14 02:10:07 +08:00
Extends the hook command path correction from PR #1682 (English source) to the zh-CN, zh-TW, and ja-JP translated mirrors so the PreToolUse hook example matches the actual script location at ~/.claude/scripts/hooks/suggest-compact.js. Changes per locale: - docs/zh-CN/skills/strategic-compact/SKILL.md: update both command strings from ~/.claude/skills/strategic-compact/suggest-compact.js to ~/.claude/scripts/hooks/suggest-compact.js. - docs/zh-TW/skills/strategic-compact/SKILL.md: replace the outdated suggest-compact.sh reference (the .sh variant was removed in merged PR #41) with the current node-invoked suggest-compact.js, and align the matcher block structure with the English canonical SKILL.md post-#1682. - docs/ja-JP/skills/strategic-compact/SKILL.md: same .sh -> .js migration and matcher alignment as zh-TW. The ko-KR mirror already uses the correct CLAUDE_PLUGIN_ROOT-based hook path and needs no change. Refs #1675
1.9 KiB
1.9 KiB
name, description
| name | description |
|---|---|
| strategic-compact | Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction. |
策略性壓縮技能
在工作流程的策略點建議手動 /compact,而非依賴任意的自動壓縮。
為什麼需要策略性壓縮?
自動壓縮在任意點觸發:
- 經常在任務中途,丟失重要上下文
- 不知道邏輯任務邊界
- 可能中斷複雜的多步驟操作
邏輯邊界的策略性壓縮:
- 探索後、執行前 - 壓縮研究上下文,保留實作計畫
- 完成里程碑後 - 為下一階段重新開始
- 主要上下文轉換前 - 在不同任務前清除探索上下文
運作方式
suggest-compact.js 腳本在 PreToolUse(Edit/Write)執行並:
- 追蹤工具呼叫 - 計算工作階段中的工具呼叫次數
- 門檻偵測 - 在可設定門檻建議(預設:50 次呼叫)
- 定期提醒 - 門檻後每 25 次呼叫提醒一次
Hook 設定
新增到你的 ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit",
"hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
},
{
"matcher": "Write",
"hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
}
]
}
}
設定
環境變數:
COMPACT_THRESHOLD- 第一次建議前的工具呼叫次數(預設:50)
最佳實務
- 規劃後壓縮 - 計畫確定後,壓縮以重新開始
- 除錯後壓縮 - 繼續前清除錯誤解決上下文
- 不要在實作中途壓縮 - 為相關變更保留上下文
- 閱讀建議 - Hook 告訴你何時,你決定是否
相關
- Longform Guide - Token 優化章節
- 記憶持久性 hooks - 用於壓縮後存活的狀態