Strategic Compact

affaan-m/ECC/docs/ja-JP/skills/strategic-compact

by affaan-mef648e01899ba3e8dc6371642deaaf64b4477775No license275K starsListed Oct 9, 2026Updated Oct 9, 2026Repository updated 4 days ago

任意の自動コンパクションではなく、タスクフェーズを通じてコンテキストを保持するための論理的な間隔での手動コンパクションを提案します。

AI-generated overview

Suggests manual context compaction at logical workflow boundaries instead of relying on automatic compaction.

What it does
This skill advises when to run a manual /compact during a task, recommending compaction after exploration, after milestones, and before major context shifts. It describes a hook script that counts tool calls and reminds the user at a configurable threshold. It also documents hook configuration and environment variables for the suggestion behavior.
When to use it
Use it when working on long, multi-step tasks where automatic compaction might interrupt work or drop important context. It helps decide when to compact so that research context, plans, and implementation state are preserved at sensible points.
Requirements
Requires the Claude Code hook environment; the described suggest-compact.js hook script runs under Node.js and is registered via plugin hooks or manual settings. Configuration uses the COMPACT_THRESHOLD environment variable. The skill itself ships no scripts, only instructions.

Strategic Compactスキル

任意の自動コンパクションに依存するのではなく、ワークフローの戦略的なポイントで手動の/compactを提案します。

なぜ戦略的コンパクションか?

自動コンパクションは任意のポイントでトリガーされます:

  • 多くの場合タスクの途中で、重要なコンテキストを失う
  • タスクの論理的な境界を認識しない
  • 複雑な複数ステップの操作を中断する可能性がある

論理的な境界での戦略的コンパクション:

  • 探索後、実行前 - 研究コンテキストをコンパクト、実装計画を保持
  • マイルストーン完了後 - 次のフェーズのために新しいスタート
  • 主要なコンテキストシフト前 - 異なるタスクの前に探索コンテキストをクリア

仕組み

suggest-compact.jsスクリプトはPreToolUse(Edit/Write)で実行され:

  1. ツール呼び出しを追跡 - セッション内のツール呼び出しをカウント
  2. 閾値検出 - 設定可能な閾値で提案(デフォルト:50回)
  3. 定期的なリマインダー - 閾値後25回ごとにリマインド

フック設定

プラグインとしてインストール済みの場合:設定は不要です。プラグインの hooks/hooks.json が既に suggest-compact.js を登録しています(フック ID pre:edit-write:suggest-compact、standard と strict フックプロファイルで有効)。下のブロックを ~/.claude/settings.json にコピーしないでください — プラグインインストールでは ~/.claude/scripts/ は存在せず、プラグインフックを重複させると二重実行になります。

手動インストール(./install.sh)の場合、~/.claude/settings.json に追加:

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)

ベストプラクティス

  1. 計画後にコンパクト - 計画が確定したら、コンパクトして新しくスタート
  2. デバッグ後にコンパクト - 続行前にエラー解決コンテキストをクリア
  3. 実装中はコンパクトしない - 関連する変更のためにコンテキストを保持
  4. 提案を読む - フックはいつを教えてくれますが、するかどうかは自分で決める

関連

  • The Longform Guide - トークン最適化セクション
  • メモリ永続化フック - コンパクションを超えて存続する状態用

Source and attribution

Source:affaan-m/ECCindocs/ja-JP/skills/strategic-compactat commitef648e0

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal