mpm-orchestration-demo
Claude MPMにおけるCommand → Agent → Skillオーケストレーションパターンの参照実装です。プリロード済みスキルと動的スキル呼び出しの両方のスタイルを実演しており、エージェントがコマンドを受け取ってスキルを組織的に実行する方法を示しています。
description の原文を見る
Reference implementation demonstrating the Command → Agent → Skill orchestration pattern in Claude MPM, showing both preloaded-skill and dynamic-skill-invocation styles
SKILL.md 本文
MPM オーケストレーション デモ
概要
このスキルは、Claude MPMにおけるコマンド → エージェント → スキルオーケストレーションパターンの標準的なリファレンスです。コードレビューワークフローを示し、コマンド、エージェント、スキルがいかに組み合わさるか、そしてスキルが呼び出される2つの異なる方法を実演します。
このパターンを理解することは、あらゆる非自明なMPMワークフローを構築するための基礎となります。
2つの呼び出しスタイル
スタイル1:プリロード済みスキル(フロントマター)
スキルはエージェントのskills:フロントマターにリストされます。スキルの完全な内容はスタートアップ時にエージェントのコンテキストに注入され、組み込まれたドメイン知識になります。
# .claude/agents/code-reviewer.md
---
name: code-reviewer
description: Reviews code for quality, security, and correctness
skills:
- code-review-checklist # Injected at startup
model: sonnet
---
**使用するタイミング:**エージェントがこの知識をいつも必要とします。エージェントの目的の中核であり、状況依存ではありません。
特徴:
- コンテンツは最初のターンから存在します
- ツール呼び出しのオーバーヘッドがありません
- 使用しない場合でもコンテキストトークンを消費します
- 1〜3つの必須ナレッジベースに最適です
スタイル2:動的呼び出し(スキルツール)
スキルはランタイムでSkillツールを使用して呼び出されます。コマンドまたはエージェントがその機能が必要な場合にSkill(skill: "skill-name")を呼び出します。
# In a command or agent's instructions
Skill(skill: "security-scanner")
**使用するタイミング:**機能が状況依存です。特定の条件下でのみ必要であるか、初期データを収集した後に必要です。
特徴:
- 必要な場合にのみ呼び出されます
- それ以外の場合はコンテキストトークンを保持します
- 条件付きロジック("セキュリティの問題が見つかった場合、スキャナを呼び出す")を有効にします
- オプション、条件付き、または重い操作に最適です
具体例:コードレビューオーケストレーション
このデモは3つのコンポーネントで構成されるコードレビューシステムを実装しています。
フロー
╔══════════════════════════════════════════════════════════════════╗
║ CODE REVIEW ORCHESTRATION ║
║ Command → Agent → Skill ║
╚══════════════════════════════════════════════════════════════════╝
┌─────────────────────┐
│ User invokes │
│ /code-review-demo │
└──────────┬──────────┘
│
▼
┌──────────────────────────────────────────────────┐
│ /code-review-demo — Command (Entry Point) │
│ 1. Accept file path argument │
│ 2. Invoke code-reviewer agent (Agent tool) │
│ 3. If issues found: Skill("issue-formatter") │
└──────────────────────┬───────────────────────────┘
│
Agent tool call
│
▼
┌──────────────────────────────────────────────────┐
│ code-reviewer — Agent │
│ skills: [code-review-checklist] ← Style 1 │
│ │
│ Uses preloaded checklist to review the file │
│ Returns: list of issues (or "no issues") │
└──────────────────────┬───────────────────────────┘
│
Returns issues
│
┌──────────────────────▼───────────────────────────┐
│ Command receives issues │
│ Conditionally invokes: │
│ Skill("issue-formatter") ← Style 2 │
└──────────────────────┬───────────────────────────┘
│
▼
┌─────────────────────┐
│ issue-formatter │
│ Formats and writes │
│ review-report.md │
└─────────────────────┘
コンポーネント定義
コマンド:/code-review-demo
---
# .claude/commands/code-review-demo.md
description: Demo orchestration command for code review workflow
model: haiku
---
# Code Review Demo
Accept a file path as $ARGUMENTS.
1. Use the Agent tool to invoke code-reviewer:
Agent(subagent_type="code-reviewer", prompt="Review $ARGUMENTS for quality and security issues")
2. If the agent returns any issues:
Skill(skill: "issue-formatter")
3. Report: file reviewed, issue count, report location (if written)
エージェント:code-reviewer
---
# .claude/agents/code-reviewer.md
name: code-reviewer
description: Reviews code files for quality, security, and correctness
tools: Read
model: sonnet
skills:
- code-review-checklist
---
You are a code reviewer. Use your preloaded code-review-checklist skill to
evaluate the file specified in the prompt. Return a structured list of issues,
or "NO_ISSUES" if the code is clean.
プリロード済みスキル:code-review-checklist
---
# .claude/skills/code-review-checklist/SKILL.md
name: code-review-checklist
user-invocable: false
---
# Code Review Checklist
Review code against these criteria:
1. Input validation — are all inputs validated before use?
2. Error handling — are errors caught and handled gracefully?
3. Null safety — are null/undefined values handled?
4. Security — SQL injection, XSS, hardcoded secrets?
5. Complexity — functions over 20 lines or cyclomatic complexity > 5?
Return findings as:
ISSUE: [line] [severity] [description]
動的スキル:issue-formatter
---
# .claude/skills/issue-formatter/SKILL.md
name: issue-formatter
description: Formats code review findings into a structured markdown report
---
# Issue Formatter
Format the issues from the current conversation into review-report.md.
Structure:
- Summary: total issues by severity
- Critical issues (fix before merge)
- Warnings (should fix)
- Suggestions (optional improvements)
パターンテンプレート
新しいMPMオーケストレーションワークフローを構築する際は、このテンプレートをコピーしてください:
COMMAND (.claude/commands/my-workflow.md)
├── Accepts user arguments
├── Invokes specialized AGENT via Agent tool
│ └── Agent has PRELOADED SKILL(s) for core knowledge (Style 1)
├── Receives structured result from agent
└── Conditionally invokes DYNAMIC SKILL via Skill tool (Style 2)
└── Skill formats or persists the result
新しいワークフロー用チェックリスト
- コマンドが単一のエントリーポイントかつオーケストレーターである
- エージェントが専門化されている(1つの責任)
- プリロード済みスキルが常に必要なドメイン知識を含む
- 動的スキルが条件付きまたは出力固有のロジックを含む
- エージェントが散文ではなく構造化されたデータを返す
- コマンドが「結果をどうするか」のロジックを処理する
アンチパターン
**すべてをプリロードしないでください。**5つのスキルをエージェントにロードすると、コンテキストトークンが無駄になり、スタートアップが遅くなります。コアドメイン知識のみをプリロードし、残りは動的に呼び出してください。
**オーケストレーションロジックをエージェントに入れないでください。**エージェントは1つのことを行い、データを返すべきです。判定ロジック("問題が見つかった場合、フォーマットする")はコマンドに属します。
**サブエージェントからサブエージェントを呼び出さないでください。**サブエージェントはbashを介して他のサブエージェントを呼び出すことはできません。すべてのエージェント呼び出しは、コマンドまたはオーケストレータコンテキストからAgentツールを通じて行われる必要があります。
**構造化された戻り値をスキップしないでください。**構造化されていない散文を返すエージェントは対応が困難です。コマンドが判定できるように、明確な戻り形式を定義してください(例:ISSUE: [line] [severity] [desc])。
**スキルコンテンツを複製しないでください。**2つのエージェントが同じ知識を必要とする場合、1つの共有スキルを作成し、両方にプリロードしてください。スキルコンテンツをエージェント定義にコピーペーストしないでください。
ナビゲーション
- Orchestration Patterns: ディープダイブリファレンス — 注釈付きの気象システム例、各スタイルを使用する時期、エージェント通信パターン、エラーハンドリング
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- bobmatnyc
- ライセンス
- MIT
- 最終更新
- 2026/4/15
Source: https://github.com/bobmatnyc/claude-mpm-skills / ライセンス: MIT