jpskill.com
💼 ビジネス コミュニティ

context-compactor

Automatic context summarization for long-running sessions. Use when context is approaching limits, summarizing completed work, preserving critical information, or managing token budgets.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o context-compactor.zip https://jpskill.com/download/9407.zip && unzip -o context-compactor.zip && rm context-compactor.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/9407.zip -OutFile "$d\context-compactor.zip"; Expand-Archive "$d\context-compactor.zip" -DestinationPath $d -Force; ri "$d\context-compactor.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して context-compactor.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → context-compactor フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1
📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

Context Compactor

Automatically summarizes and compacts context when approaching token limits while preserving critical information.

Quick Start

Check if Compaction Needed

from scripts.compactor import ContextCompactor

compactor = ContextCompactor()
if compactor.should_compact(context, limit=100000):
    compacted = compactor.compact(context)

Compact Context

compacted = compactor.compact(context)
# Preserves: architectural decisions, bugs, current state
# Discards: stale tool outputs, redundant messages

Preservation Strategy

┌─────────────────────────────────────────────────────────────┐
│                  PRESERVATION PRIORITY                       │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  MUST PRESERVE (Never remove)                               │
│  ├─ Architectural decisions                                 │
│  ├─ Unresolved bugs and blockers                           │
│  ├─ Current feature state                                   │
│  ├─ Recent file changes (last 5)                           │
│  └─ Error patterns and solutions                           │
│                                                              │
│  CAN SUMMARIZE (Compress to summary)                        │
│  ├─ Completed features (list of IDs)                       │
│  ├─ Resolved errors (brief mention)                        │
│  └─ Historical decisions (key points)                      │
│                                                              │
│  CAN DISCARD (Remove entirely)                              │
│  ├─ Redundant tool outputs                                 │
│  ├─ Stale search results                                   │
│  ├─ Superseded messages                                    │
│  └─ Verbose logging                                         │
│                                                              │
└─────────────────────────────────────────────────────────────┘

Compaction Process

  1. Score Importance: Assign score to each message/content
  2. Identify Critical: Mark must-preserve content
  3. Summarize Middle: Compress can-summarize content
  4. Discard Stale: Remove can-discard content
  5. Validate: Ensure compacted context is coherent

Token Budgets

Context Type Limit Action
< 50% Normal No action
50-75% Warning Prepare for compaction
75-90% Compact Trigger compaction
> 90% Critical Aggressive compaction

Integration Points

  • autonomous-session-manager: Triggers compaction check
  • memory-manager: Stores compacted summaries
  • handoff-coordinator: Uses compacted state for handoffs

References

  • references/COMPACTION-STRATEGY.md - Detailed strategy
  • references/TOKEN-BUDGETS.md - Budget management

Scripts

  • scripts/compactor.py - Core ContextCompactor
  • scripts/importance_scorer.py - Message scoring
  • scripts/summarizer.py - Content summarization
  • scripts/token_estimator.py - Token counting