smart-compact
セッションのコンテキストを分析し、重要な情報を保持するためのプロンプトを生成して /compact コマンドの実行を支援するスキル。コンテキストウィンドウが逼迫してきた時や、セッションを整理したい時に使用。
Best use case
smart-compact is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
セッションのコンテキストを分析し、重要な情報を保持するためのプロンプトを生成して /compact コマンドの実行を支援するスキル。コンテキストウィンドウが逼迫してきた時や、セッションを整理したい時に使用。
Teams using smart-compact should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/smart-compact/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How smart-compact Compares
| Feature / Agent | smart-compact | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
セッションのコンテキストを分析し、重要な情報を保持するためのプロンプトを生成して /compact コマンドの実行を支援するスキル。コンテキストウィンドウが逼迫してきた時や、セッションを整理したい時に使用。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Smart Compact セッションのコンテキストを分析し、ユーザーの意図に沿った `/compact` プロンプトを生成する。 ## 実行フロー ### Phase 1: セッションコンテキスト分析 会話履歴全体を分析し、以下の要素を抽出する: - **作業中のタスク**: 現在取り組んでいる実装・修正・調査の内容 - **重要な技術的決定**: アーキテクチャ選定、ライブラリ選定、設計判断 - **未解決の問題**: まだ対応が必要なエラー、バグ、課題 - **ファイル変更履歴**: セッション中に変更・作成したファイルとその目的 - **コンテキスト依存情報**: 後続の作業に必要な前提知識や制約 分析結果を簡潔に箇条書きで表示する。 ### Phase 2: ヒアリング Phase 1の分析結果に基づき、AskUserQuestionでユーザーにヒアリングする。 **質問の生成ルール:** - セッションの内容に応じて **動的に** 選択肢を生成する - 選択肢はそのセッション固有のコンテキスト(タスク名、ファイル名、技術スタック等)を含む具体的なものにする - multiSelect: true で複数選択可能にする - 2〜4個の選択肢を用意する **質問テンプレート:** ```plain 質問: "compactで重点的に保持したい情報はどれですか?" header: "保持情報" multiSelect: true 選択肢の例(セッション内容に応じて動的生成): - "<具体的なタスク名>の実装進捗と残作業" - "<ファイル名>周辺のエラー調査コンテキスト" - "<技術名>に関する設計判断と理由" - "<機能名>のAPI仕様と型定義" ``` **重要**: プリセットの汎用的な選択肢ではなく、セッション分析結果から導出した具体的な選択肢を生成すること。 ### Phase 3: プロンプト生成 ユーザーの回答に基づき、`/compact` に渡すプロンプトを生成する。 **プロンプト生成ガイドライン:** 1. ユーザーが選択した保持項目を最優先で含める 2. 現在のタスクの継続に必要な最小限のコンテキストを含める 3. 具体的なファイル名、関数名、エラーメッセージなど固有名詞を含める 4. 「何を捨てるか」ではなく「何を保持するか」の指示として記述する 5. プロンプトは日本語で生成する **生成フォーマット:** ```plain 以下の情報を重点的に保持してコンテキストを圧縮してください: 1. [保持項目1の具体的な内容] 2. [保持項目2の具体的な内容] 3. [保持項目3の具体的な内容] 特に以下は正確に保持してください: - [重要な固有名詞、パス、コマンドなど] ``` ### Phase 4: 確認と実行案内 生成したプロンプトをユーザーに提示し、AskUserQuestionで確認する。 ```plain AskUserQuestionで確認: - "このプロンプトでcompactを実行しますか?" - "実行する" - コマンドを表示 - "修正する" - 修正点を指示 - "キャンセル" ``` **承認された場合:** 以下のフォーマットでコピー可能なコマンドを出力する: ````plain 以下のコマンドをコピーして実行してください: ``` /compact <生成したプロンプト> ``` ```` **修正が必要な場合:** ユーザーの修正指示を反映してプロンプトを再生成し、再度確認する。 ## エラーハンドリング | 状況 | 対応 | | ------------------------------- | --------------------------------------- | | セッションが短すぎてcompact不要 | compactの必要性が低いことを通知して終了 | | 保持すべき情報が特にない場合 | 引数なしの `/compact` を提案 | | ユーザーがキャンセルした場合 | 何もせず終了 | ## 使用例 ```plain > /smart-compact === Phase 1: セッションコンテキスト分析 === このセッションの主な内容: - dotfiles CLIのMCPMerger機能の実装 - defu を使ったディープマージのバグ修正 - tests/core/mcp-merger.test.ts のテスト追加 === Phase 2: ヒアリング === [AskUserQuestion] compactで重点的に保持したい情報はどれですか? [1] MCPMergerのdefu統合バグの調査経緯と修正内容 [2] mcp-merger.test.ts の追加テストケースと意図 [3] claude.jsonのマージ仕様(キー保持ルール) [4] Other > 1, 3 を選択 === Phase 3: プロンプト生成 === 生成したプロンプト: --- 以下の情報を重点的に保持してコンテキストを圧縮してください: 1. MCPMergerでdefuを使ったmcpServersマージ時に、既存キーが上書きされるバグの原因と修正内容(src/core/mcp-merger.ts の mergeConfig 関数) 2. claude.jsonのマージ仕様:mcpServersキーのみマージし、apiKey等の他キーはdefu経由で保持する設計判断 特に以下は正確に保持してください: - src/core/mcp-merger.ts, tests/core/mcp-merger.test.ts のファイルパス - defu の非破壊マージ挙動(ターゲット側の値が優先される仕様) --- === Phase 4: 確認 === [AskUserQuestion] このプロンプトでcompactを実行しますか? > 実行する 以下のコマンドをコピーして実行してください: /compact 以下の情報を重点的に保持してコンテキストを圧縮してください:... ``` ## Notes - `/compact` はClaude Codeの組み込みコマンドのため、スキルから直接実行はできない - 生成されたコマンドはユーザーが手動でコピー&実行する必要がある - セッションが十分に長い(コンテキストが逼迫している)時に最も効果的
Related Skills
typescript-performance
Comprehensive TypeScript performance analysis and optimization. Use when users report slow TypeScript compilation, slow editor experience, or want to investigate TypeScript performance issues. This skill provides diagnostic tools, trace analysis workflows, and optimization strategies. Key triggers include mentions of slow builds, type-checking delays, tsc performance, editor lag with TypeScript, or requests to analyze/improve TypeScript performance. Always prioritize data-driven analysis using --extendedDiagnostics, --generateTrace, and TS Server logs before making optimization recommendations.
watch-ci
CI を監視し、失敗したら自律的に修正してパスするまでループするスキル。push 後・PR 作成後・rebase 後に CI が通るか確認したいとき、CI が落ちていたら直してほしいとき、CI の結果を待ちたいときに使う。「CI 監視して」「CI が通るまで待って」「CI 直して」「push したので CI を見ておいて」など、CI の状態確認・自動修正が必要な場面では必ずこのスキルを呼び出すこと。
vue-style-guide
Vue を書くときは基本的に参考にしてください。 個人的に気に入っている ubgeeei 氏の Vue.js のスタイルガイドです。
vitess
Vitess best practices, query optimization, and connection troubleshooting for PlanetScale Vitess databases. Load when working with Vitess databases, sharding, VSchema configuration, keyspace management, or MySQL scaling issues.
triage-pr-reviews
Triages unresolved PR review comments using gh-pr-reviews. Analyzes code context and classifies each comment as Agree / Partially Agree / Disagree. Walks through each comment one-by-one, asking the user what action to take. Use when the user wants to triage, review, or analyze unresolved PR comments.
terraform-test
Comprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios with run blocks, validating infrastructure behavior with assertions, mocking providers and data sources, testing module outputs and resource configurations, or troubleshooting Terraform test syntax and execution.
terraform-style-guide
Generate Terraform HCL code following HashiCorp's official style conventions and best practices. Use when writing, reviewing, or generating Terraform configurations.
terraform-stacks
Comprehensive guide for working with HashiCorp Terraform Stacks. Use when creating, modifying, or validating Terraform Stack configurations (.tfcomponent.hcl, .tfdeploy.hcl files), working with stack components and deployments from local modules, public registry, or private registry sources, managing multi-region or multi-environment infrastructure, or troubleshooting Terraform Stacks syntax and structure.
teach-impeccable
One-time setup that gathers design context for your project and saves it to your AI config file. Run once to establish persistent design guidelines.
stacked-pr
依存関係のある複数の PR を管理・同期するためのスキル。stacked PR のカスケード rebase、PR 間の依存検出、base branch 管理、CI の上流優先修正を行う。PR が別の PR に依存している状況全般で使う — cascade rebase、スタック sync、依存先 PR 更新後のメンテ、PR チェーンの整合性確認などをするときなど。
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
semgrep
Run Semgrep static analysis scans and create custom detection rules. Use when asked to scan code with Semgrep, find security vulnerabilities, write custom YAML rules, or detect specific bug patterns. IMPORTANT: Also use this skill when users ask to 'scan for bugs', 'check code quality', 'find vulnerabilities', 'static analysis', 'lint for security', 'audit this code', or want to enforce coding standards — even if they don't mention Semgrep by name. Semgrep is the right tool for pattern-based code scanning across 30+ languages.