Agent skill
strategic-compact
Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
Install this agent skill to your Project
npx add-skill https://github.com/xu-xiang/everything-claude-code-zh/tree/main/docs/zh-TW/skills/strategic-compact
SKILL.md
策略性壓縮技能
在工作流程的策略點建議手動 /compact,而非依賴任意的自動壓縮。
為什麼需要策略性壓縮?
自動壓縮在任意點觸發:
- 經常在任務中途,丟失重要上下文
- 不知道邏輯任務邊界
- 可能中斷複雜的多步驟操作
邏輯邊界的策略性壓縮:
- 探索後、執行前 - 壓縮研究上下文,保留實作計畫
- 完成里程碑後 - 為下一階段重新開始
- 主要上下文轉換前 - 在不同任務前清除探索上下文
運作方式
suggest-compact.sh 腳本在 PreToolUse(Edit/Write)執行並:
- 追蹤工具呼叫 - 計算工作階段中的工具呼叫次數
- 門檻偵測 - 在可設定門檻建議(預設:50 次呼叫)
- 定期提醒 - 門檻後每 25 次呼叫提醒一次
Hook 設定
新增到你的 ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [{
"matcher": "tool == \"Edit\" || tool == \"Write\"",
"hooks": [{
"type": "command",
"command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
}]
}]
}
}
設定
環境變數:
COMPACT_THRESHOLD- 第一次建議前的工具呼叫次數(預設:50)
最佳實務
- 規劃後壓縮 - 計畫確定後,壓縮以重新開始
- 除錯後壓縮 - 繼續前清除錯誤解決上下文
- 不要在實作中途壓縮 - 為相關變更保留上下文
- 閱讀建議 - Hook 告訴你何時,你決定是否
相關
- Longform Guide - Token 優化章節
- 記憶持久性 hooks - 用於壓縮後存活的狀態
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
investor-materials
创建并更新路演 PPT (Pitch Deck)、单页简介 (One-Pager)、投资者备忘录 (Investor Memo)、加速器申请、财务模型以及融资材料。当用户需要面向投资者的文档、预测、资金用途表、里程碑计划或需要跨多个融资资产保持内部一致性的材料时,请使用此技能。
e2e-testing
Playwright E2E 测试模式、页面对象模型(POM)、配置、CI/CD 集成、产物管理以及不稳定测试(flaky test)策略。
api-design
生产级 API 的 REST API 设计模式,包括资源命名、状态码、分页、过滤、错误响应、版本控制和速率限制。
frontend-patterns
React、Next.js、状态管理(State Management)、性能优化(Performance Optimization)及 UI 最佳实践的前端开发模式。
investor-outreach
Draft cold emails, warm intro blurbs, follow-ups, update emails, and investor communications for fundraising. Use when the user wants outreach to angels, VCs, strategic investors, or accelerators and needs concise, personalized, investor-facing messaging.
verification-loop
为 Claude Code 会话提供的全面验证系统。
Didn't find tool you were looking for?