jpskill.com
📦 その他 コミュニティ

mobile-compaction

大規模なAndroidプロジェクトで、重要な情報を保持しつつ、Claudeの利用に必要なトークン数を最適化し、より効率的にコンテキスト情報を活用できるようにするSkill。

📜 元の英語説明(参考)

Context compaction strategies for large Android codebases. Optimize token usage while preserving critical context.

🇯🇵 日本人クリエイター向け解説

一言でいうと

大規模なAndroidプロジェクトで、重要な情報を保持しつつ、Claudeの利用に必要なトークン数を最適化し、より効率的にコンテキスト情報を活用できるようにするSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して mobile-compaction.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → mobile-compaction フォルダができる
  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

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Mobile Compaction Skill

大規模な Android プロジェクトにおいて、重要な情報を保持しながらトークン使用量を最適化するための戦略的なコンテキスト圧縮です。

圧縮のタイミング

以下の場合にコンテキストを圧縮します。

  • トークン使用量が 100,000 を超える場合
  • 多数のファイルにまたがる大規模なリファクタリングに取り組んでいる場合
  • 無関係な機能間を切り替える場合
  • セッションが集中力を失った場合
  • コンテキストに解決済みのディスカッションが含まれている場合

圧縮戦略

1. モジュールレベルの圧縮

単一の Android モジュールに焦点を当てます。

/compact --module=feature:auth

何が起こるか:

  • 保持: feature:auth モジュール内のすべてのファイル
  • 要約: 他のモジュールをハイレベルな説明に要約
  • 削除: 他のモジュールに関する解決済みのディスカッション

使用時: 特定の機能に関する集中的な作業

2. レイヤーベースの圧縮

アーキテクチャレイヤーに焦点を当てます。

/compact --layer=ui
/compact --layer=data
/compact --layer=domain

何が起こるか:

レイヤー 保持 要約
UI Composables, ViewModels, ナビゲーション Repository の詳細、データモデル
Data Repositories, データソース、モデル Compose コード、UI 状態
Domain Use cases, ドメインモデル 実装の詳細

使用時: レイヤーにおけるクロス・カッティングな懸念事項に取り組む場合

3. ビルドバリアントの焦点

特定のビルドバリアントに絞り込みます。

/compact --variant=debug

何が起こるか:

  • 保持: デバッグ固有の設定、テストコード
  • 要約: リリース設定、ProGuard ルール

使用時: デバッグまたはテスト開発

4. テストの分離

失敗しているテストを中心に圧縮します。

/compact --test=AuthViewModelTest
/compact --test-failing

何が起こるか:

  • 保持: テストファイル、関連するソースファイル
  • 要約: 無関係なテストディスカッション
  • 削除: 解決済みのテスト修正に関するディスカッション

使用時: 特定のテストの失敗を修正する場合

5. パターンベースの圧縮

アーキテクチャパターンに基づいて圧縮します。

/compact --pattern=compose
/compact --pattern=mvi
/compact --pattern=koin

何が起こるか:

  • 保持: パターンに一致するファイル
  • 要約: パターンに一致しないファイルをパターン名のみに要約

使用時: パターン固有の作業 (例: Compose の最適化)

圧縮レベル

レベル 保持 トークン節約 ユースケース
Lite 現在のタスクのみ 70-80% 集中作業
Medium 現在 + 関連 50-60% 機能開発
Standard プロジェクトの概要 30-40% デフォルトの圧縮
Minimal 必須のみ 80-90% コンテキストが制限に達している場合

何が保持されるか

常に保持 (重要)

  • アクティブなタスクコンテキスト (現在行っていること)
  • 最近のコード変更 (最後の 5〜10 ファイル)
  • 現在のエラー/失敗
  • モバイルメモリコンテキスト
  • 信頼度の高い直感 (> 0.7)
  • 未解決の質問

通常保持 (重要)

  • アーキテクチャの決定
  • 最近のディスカッション (最後の 50 メッセージ)
  • 関連するファイルの内容
  • テスト状態

要約 (圧縮可能)

  • 完了した機能
  • 解決済みのバグ
  • 作業コードの説明
  • バックグラウンドディスカッション

削除 (破棄可能)

  • 成功したビルド出力
  • 些細な操作
  • 重複した情報
  • オフトピックのディスカッション

圧縮コマンド

基本的な圧縮

/compact                      # 自動的に戦略を選択
/compact --level=medium       # レベルを指定
/compact --focus=compose      # 特定の領域に焦点を当てる

スマート圧縮

/compact --smart              # AI が戦略を選択
/compact --adaptive           # 使用状況に基づいて調整

手動圧縮

/compact --keep=file1.kt,file2.kt   # 特定のファイルを保持
/compact --drop=discussion-1        # 特定のディスカッションを削除
/compact --summarize=feature-x      # 特定のトピックを要約

圧縮ワークフロー

圧縮前

1. /memory-save all              # 現在の状態をメモリに保存
2. /mobile-checkpoint save pre-compact  # オプションのチェックポイント
3. /compact --strategy=module --focus=feature:auth

圧縮後

1. /memory-summary              # メモリが保持されていることを確認
2. /instinct-status             # 直感が保持されていることを確認
3. 作業を続行...

統合

チェックポイントとの連携

# 圧縮前のフックで自動的にチェックポイントを保存
# 必要なコンテキストが圧縮によって削除された場合に復元

メモリとの連携

# メモリは圧縮後も保持される
# メモリをクエリして詳細を復元:
/memory-query "What was the auth flow architecture?"

直感との連携

# 直感は圧縮後も保持される
# 信頼度の高い直感は常に保持される
# 信頼度の低い直感は要約される可能性がある

アンチパターン

以下の場合には圧縮しないでください:

  • デバッグの最中
  • 未解決のエラーが存在する場合
  • アクティブなディスカッションが進行中の場合
  • タスクがほぼ完了している場合

以下の場合には圧縮してください:

  • 新しいタスクを開始する場合
  • コンテキストを切り替える場合
  • トークン制限に近づいている場合
  • タスクが完了し、概要を保持する場合

回復

圧縮によって必要なコンテキストが削除された場合:

1. /memory-query <topic>        # メモリをクエリ
2. /mobile-checkpoint list      # チェックポイントを確認
3. /mobile-checkpoint restore <name>  # 必要に応じて復元
4. ファイルの差分に関する Git の履歴

例 1: 機能開発

コンテキスト: 認証機能の開発中、コンテキストには古いホーム機能のディスカッションが含まれている
アクション: /compact --module=feature:auth
結果: 認証ファイルを保持し、ホーム機能を要約

例 2: テスト修正

コンテキスト: 多数のファイル、LoginTest の修正に焦点を当てる
アクション: /compact --test=LoginTest
結果: LoginTest、関連する認証ファイルを保持し、残りを要約

例 3: Compose の最適化

コンテキスト: 大規模なプロジェクト、Compose のパフォーマンスを最適化
アクション: /compact --pattern=compose --level=medium
結果: Compose ファイルを保持し、データ/ネットワークレイヤーの概要を要約

覚えておいてください: 圧縮はチェックポイントとメモリを介して元に戻すことができます。 迷った場合は、最初にチェックポイントを作成してください。

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Mobile Compaction Skill

Strategic context compaction for large Android projects to optimize token usage while preserving critical information.

When to Compact

Compact context when:

  • Token usage exceeds 100,000
  • Working on large refactors spanning many files
  • Switching between unrelated features
  • Session becomes unfocused
  • Context contains resolved discussions

Compaction Strategies

1. Module-Level Compaction

Focus on a single Android module:

/compact --module=feature:auth

What happens:

  • Retain: All files in feature:auth module
  • Summarize: Other modules to high-level description
  • Drop: Resolved discussions about other modules

Use when: Deep work on a specific feature

2. Layer-Based Compaction

Focus on architecture layer:

/compact --layer=ui
/compact --layer=data
/compact --layer=domain

What happens:

Layer Retain Summarize
UI Composables, ViewModels, navigation Repository details, data models
Data Repositories, data sources, models Compose code, UI state
Domain Use cases, domain models Implementation details

Use when: Working on cross-cutting concerns in a layer

3. Build Variant Focus

Narrow to specific build variant:

/compact --variant=debug

What happens:

  • Retain: Debug-specific configurations, test code
  • Summarize: Release configurations, ProGuard rules

Use when: Debugging or test development

4. Test Isolation

Compact around failing tests:

/compact --test=AuthViewModelTest
/compact --test-failing

What happens:

  • Retain: Test file, related source files
  • Summarize: Unrelated test discussions
  • Drop: Resolved test fix discussions

Use when: Fixing specific test failures

5. Pattern-Based Compaction

Compact based on architectural patterns:

/compact --pattern=compose
/compact --pattern=mvi
/compact --pattern=koin

What happens:

  • Retain: Files matching the pattern
  • Summarize: Non-matching files to pattern names only

Use when: Pattern-specific work (e.g., Compose optimization)

Compaction Levels

Level Retention Token Savings Use Case
Lite Current task only 70-80% Deep focus work
Medium Current + related 50-60% Feature development
Standard Project summary 30-40% Default compaction
Minimal Essential only 80-90% Context at limit

What Gets Preserved

Always Preserve (Critical)

  • Active task context (what we're doing now)
  • Recent code changes (last 5-10 files)
  • Current errors/failures
  • Mobile memory context
  • High-confidence instincts (>0.7)
  • Unresolved questions

Usually Preserve (Important)

  • Architecture decisions
  • Recent discussions (last 50 messages)
  • Related file contents
  • Test states

Summarize (Compressible)

  • Completed features
  • Resolved bugs
  • Working code explanations
  • Background discussions

Drop (Disposable)

  • Successful build outputs
  • Trivial operations
  • Duplicated information
  • Off-topic discussions

Compaction Commands

Basic Compaction

/compact                      # Auto-select strategy
/compact --level=medium       # Specify level
/compact --focus=compose      # Focus on specific area

Smart Compaction

/compact --smart              # AI chooses strategy
/compact --adaptive           # Adjusts based on usage

Manual Compaction

/compact --keep=file1.kt,file2.kt   # Keep specific files
/compact --drop=discussion-1        # Drop specific discussion
/compact --summarize=feature-x      # Summarize specific topic

Compaction Workflow

Before Compaction

1. /memory-save all              # Save current state to memory
2. /mobile-checkpoint save pre-compact  # Optional checkpoint
3. /compact --strategy=module --focus=feature:auth

After Compaction

1. /memory-summary              # Verify memory preserved
2. /instinct-status             # Verify instincts preserved
3. Continue work...

Integration

With Checkpoints

# Pre-compact hook automatically saves checkpoint
# Restore to recover if compaction removes needed context

With Memory

# Memory survives compaction
# Query memory to recover details:
/memory-query "What was the auth flow architecture?"

With Instincts

# Instincts survive compaction
# High-confidence instincts always retained
# Low-confidence may be summarized

Anti-Patterns

Don't Compact When:

  • In the middle of debugging
  • Unresolved errors exist
  • Active discussion ongoing
  • Task almost complete

Do Compact When:

  • Starting new task
  • Switching context
  • Token limit approaching
  • Task completed, keeping summary

Recovery

If compaction removed needed context:

1. /memory-query <topic>        # Query memory
2. /mobile-checkpoint list      # Check for checkpoints
3. /mobile-checkpoint restore <name>  # Restore if needed
4. Git history for file diffs

Examples

Example 1: Feature Development

Context: Working on auth feature, context contains old home feature discussions
Action: /compact --module=feature:auth
Result: Retains auth files, summarizes home feature

Example 2: Test Fixing

Context: Many files, focus on fixing LoginTest
Action: /compact --test=LoginTest
Result: Retains LoginTest, related auth files, summarizes rest

Example 3: Compose Optimization

Context: Large project, optimizing Compose performance
Action: /compact --pattern=compose --level=medium
Result: Retains Compose files, summaries of data/network layers

Remember: Compaction is reversible via checkpoints and memory. When in doubt, checkpoint first.