strategic-compact

A workflow guide that suggests when to manually shorten the assistant’s conversation memory during a coding task. It recommends doing this at clear stage boundaries, such as after planning or debugging.

In plain words
What is it for?
It helps configure reminders before code edits, track tool calls, and choose points to shorten context during multi-step implementation or debugging work.
Why use it?
It helps prevent automatic memory shortening from happening halfway through a task and dropping useful details. You decide when to start the next phase with a cleaner context.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/codelably/harmony-claude-code/strategic-compact
Any agent
npx skills add codelably/harmony-claude-code --skill strategic-compact
Clone the repo
git clone --depth 1 https://github.com/codelably/harmony-claude-code

Made for: Claude Code, Codex.

Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 614 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00027 $0.00614
Opus 5 $0.00014 $0.00307
Sonnet 5 $0.00005 $0.00123
Haiku 4.5 $0.00003 $0.00061

Measured 2d ago against content hash 5361c102d922, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

strategic-compact scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

新增到你的 `~/.claude/settings.json`:
docs/zh-TW/skills/strategic-compact/SKILL.md · 64 lines

What it actually says

策略性壓縮技能

在工作流程的策略點建議手動 /compact,而非依賴任意的自動壓縮。

為什麼需要策略性壓縮?

自動壓縮在任意點觸發:

  • 經常在任務中途,丟失重要上下文
  • 不知道邏輯任務邊界
  • 可能中斷複雜的多步驟操作

邏輯邊界的策略性壓縮:

  • 探索後、執行前 - 壓縮研究上下文,保留實作計畫
  • 完成里程碑後 - 為下一階段重新開始
  • 主要上下文轉換前 - 在不同任務前清除探索上下文

運作方式

suggest-compact.sh 腳本在 PreToolUse(Edit/Write)執行並:

  1. 追蹤工具呼叫 - 計算工作階段中的工具呼叫次數
  2. 門檻偵測 - 在可設定門檻建議(預設:50 次呼叫)
  3. 定期提醒 - 門檻後每 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)

最佳實務

  1. 規劃後壓縮 - 計畫確定後,壓縮以重新開始
  2. 除錯後壓縮 - 繼續前清除錯誤解決上下文
  3. 不要在實作中途壓縮 - 為相關變更保留上下文
  4. 閱讀建議 - Hook 告訴你何時,你決定是否

相關

  • Longform Guide - Token 優化章節
  • 記憶持久性 hooks - 用於壓縮後存活的狀態
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 64 lines · 27 tokens per session scan B 5361c102d922

Subscribe to this mod's changes

strategic-compact is a skill published in the GitHub repository codelably/harmony-claude-code (42 stars, last pushed 6mo ago), licensed MIT. It adds 27 tokens to every session and 614 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens