mcpbeat

Strategic Compact

loulanyue/strategic-compact

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

720 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
265
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/loulanyue/awesome-claude-notes --skill strategic-compact

The instruction itself

1 sections, as written by the author

Strategic Compactスキル

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

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

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

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

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

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

仕組み

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

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

フック設定

~/.claude/settings.jsonに追加:

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "tool == \"Edit\" || tool == \"Write\"",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
      }]
    }]
  }
}

設定

環境変数:

  • COMPACT_THRESHOLD - 最初の提案前のツール呼び出し(デフォルト:50)

ベストプラクティス

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

関連

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

原文

  • 英語版の原文

ナビゲーション

  • 日本語ドキュメント一覧
  • skills/README.md
  • 貢献ガイド

How to use it

Copy the folder

Take loulanyue/strategic-compact from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.