🤖agent-development
- プラグイン
- plugin-dev
- ソース
- GitHub で見る ↗
説明
次のような場合に使用: ユーザーが「agentを作成する」「agentを追加する」「subagentを書く」「agent frontmatter」「descriptionをいつ使うか」「agentの例」「agentのツール」「agentの色」「autonomous agent」について質問する場合、またはClaude Code pluginにおけるagentの構造、システムプロンプト、トリガー条件、agentの開発ベストプラクティスに関するガイダンスが必要な場合。
原文を表示
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
ユースケース
- ✓agentを作成・追加するとき
- ✓subagentを書くとき
- ✓agent frontmatterについて質問されるとき
- ✓agentの構造やシステムプロンプトのガイダンスが必要なとき
- ✓agentの開発ベストプラクティスを知りたいとき
本文(日本語訳)
Claude Code プラグイン向け Agent 開発
概要
Agent とは、複雑な複数ステップのタスクを自律的に処理するサブプロセスです。 Agent の構造・起動条件・システムプロンプトの設計を理解することで、強力な自律機能を構築できます。
主要コンセプト:
- Agent は自律的な作業のためのもの。コマンドはユーザーが起動するアクションのためのもの
- ファイル形式は YAML フロントマター付き Markdown
descriptionフィールドとサンプルを使ったトリガー設定- システムプロンプトで Agent の振る舞いを定義
- モデルとカラーのカスタマイズが可能
Agent ファイル構造
完全なフォーマット
---
name: agent-identifier
description: 次のような場合に使用: [起動条件]。典型的なトリガーとして [シナリオ1(散文)]、[シナリオ2(散文)]、[シナリオ3(散文)] などがあります。詳細な具体例は Agent 本体の "When to invoke" セクションを参照してください。
model: inherit
color: blue
tools: ["Read", "Write", "Grep"]
---
あなたは [Agent の役割説明] です...
## When to invoke
[代表的なシナリオを2〜4個、散文形式で記述。例:]
- **[シナリオ名].** [状況の説明と Agent が行うべき内容。]
- **[シナリオ名].** [同上。]
**中核的な責務:**
1. [責務 1]
2. [責務 2]
**分析プロセス:**
[ステップバイステップのワークフロー]
**出力フォーマット:**
[返すべき内容]
フロントマターフィールド
name(必須)
名前空間の管理や呼び出しに使用する Agent の識別子。
フォーマット: 小文字・数字・ハイフンのみ使用可 長さ: 3〜50 文字 パターン: 先頭と末尾は英数字であること
良い例:
code-reviewertest-generatorapi-docs-writersecurity-analyzer
悪い例:
helper(汎用的すぎる)-agent-(ハイフンで始まり・終わっている)my_agent(アンダースコアは不可)ag(短すぎる。3 文字未満)
description(必須)
Claude がこの Agent をいつ起動すべきかを定義します。 このフィールドが最も重要です — Agent が登録されるたびにコンテキストへ読み込まれ、ハーネスがディスパッチのタイミングを判断するために使用されます。
必須の記載内容:
- 起動条件(「次のような場合に使用: ...」)
- 典型的な起動シナリオの簡潔な散文サマリー
- 詳細な具体例を記載した Agent 本体の "When to invoke" セクションへの案内
フォーマット:
次のような場合に使用: [条件]。典型的なトリガーとして [シナリオ1(散文)]、[シナリオ2(散文)]、[シナリオ3(散文)] などがあります。詳細な具体例は Agent 本体の "When to invoke" セクションを参照してください。
ベストプラクティス:
- 散文サマリーに 2〜4 個のトリガーシナリオを記載する
- 自発的トリガー(assistant 自身が起動)と受動的トリガー(ユーザーが要求)の両方をカバーする
- 同じ意図でも異なる表現のパターンを網羅する
- この Agent を使うべきでない場合を明確に記述する
- 詳細なシナリオは本体の "When to invoke" セクションに散文形式の箇条書きで記載する
model(必須)
Agent が使用するモデルを指定します。
選択肢:
inherit— 親と同じモデルを使用(推奨)sonnet— Claude Sonnet(バランス型)opus— Claude Opus(最高性能・高コスト)haiku— Claude Haiku(高速・低コスト)
推奨: 特定のモデル機能が必要な場合を除き、inherit を使用してください。
color(必須)
UI 上で Agent を視覚的に識別するための色。
選択肢: blue、cyan、green、yellow、magenta、red
ガイドライン:
- 同一プラグイン内の異なる Agent には互いに異なる色を選ぶ
- 類似した Agent タイプには一貫した色を使用する
- Blue / Cyan: 分析・レビュー系
- Green: 成功志向のタスク
- Yellow: 注意・バリデーション
- Red: クリティカル・セキュリティ系
- Magenta: クリエイティブ・生成系
tools(任意)
Agent が使用できるツールを制限します。
フォーマット: ツール名の配列
tools: ["Read", "Write", "Grep", "Bash"]
デフォルト: 省略した場合、Agent はすべてのツールにアクセスできます
ベストプラクティス: 最小権限の原則に従い、必要最低限のツールのみに絞る
よく使うツールセット:
- 読み取り専用の分析:
["Read", "Grep", "Glob"] - コード生成:
["Read", "Write", "Grep"] - テスト:
["Read", "Bash", "Grep"] - フルアクセス: フィールドを省略するか
["*"]を使用
システムプロンプトの設計
Markdown 本文が Agent のシステムプロンプトになります。 Agent に直接語りかける二人称("You are...")で記述してください。
構造
標準テンプレート:
あなたは [ドメイン] を専門とする [役割] です。
**中核的な責務:**
1. [主要な責務]
2. [副次的な責務]
3. [その他の責務...]
**分析プロセス:**
1. [ステップ 1]
2. [ステップ 2]
3. [ステップ 3]
[...]
**品質基準:**
- [基準 1]
- [基準 2]
**出力フォーマット:**
以下の形式で結果を提供してください:
- [含めるべき内容]
- [構造の仕方]
**エッジケース:**
以下の状況に対処してください:
- [エッジケース 1]: [対処法]
- [エッジケース 2]: [対処法]
ベストプラクティス
✅ 推奨事項:
- 二人称で記述する("You are..."、"You will...")
- 責務を具体的に記述する
- ステップバイステップのプロセスを提供する
- 出力フォーマットを定義する
- 品質基準を含める
- エッジケースに対処する
- 10,000 文字以内に収める
❌ 非推奨事項:
- 一人称で記述する("I am..."、"I will...")
- 曖昧・汎用的な記述をする
- プロセスのステップを省く
- 出力フォーマットを未定義のままにする
- 品質ガイダンスを省く
- エラーケースを無視する
Agent の作成方法
方法 1: AI アシストによる生成
以下のプロンプトパターンを使用します(Claude Code より抜粋):
Create an agent configuration based on this request: "[YOUR DESCRIPTION]"
Requirements:
1. Extract core intent and responsibilities
2. Design expert persona for the domain
3. Create comprehensive system prompt with:
- Clear behavioral boundaries
- Specific methodologies
- Edge case handling
- Output format
- A "When to invoke" section listing 2-4 trigger scenarios as prose bullets
4. Create identifier (lowercase, hyphens, 3-50 chars)
5. Write description with triggering conditions and a short prose summary of trigger scenarios
Return JSON with:
{
"identifier": "agent-name",
"whenToUse": "Use this agent when... Typical triggers include [...]. See \"When to invoke\" in the agent body.",
"systemPrompt": "You are..."
}
生成された JSON をフロントマター付きの Agent ファイル形式に変換してください。
完全なテンプレートは examples/agent-creation-prompt.md を参照してください。
方法 2: 手動作成
- Agent 識別子を決める(3〜50 文字、小文字、ハイフン使用)
- サンプルを含む description を記述する
- モデルを選択する(通常は
inherit) - 視覚的識別用のカラーを選択する
- ツールを定義する(アクセスを制限する場合)
- 上記の構造に従ってシステムプロンプトを記述する
agents/agent-name.mdとして保存する
バリデーションルール
識別子のバリデーション
✅ 有効: code-reviewer, test-gen, api-analyzer-v2
❌ 無効: ag(短すぎる)、-start(ハイフン始まり)、my_agent(アンダースコア)
ルール:
- 3〜50 文字
- 小文字・数字・ハイフンのみ使用可
- 先頭と末尾は英数字であること
- アンダースコア・スペース・特殊文字は不可
description のバリデーション
長さ: 10〜5,000 文字 必須: 起動条件とサンプルを含めること 推奨: サンプルを 2〜4 個含む 200〜1,000 文字
システムプロンプトのバリデーション
長さ: 20〜10,000 文字 推奨: 500〜3,000 文字 構造: 責務・プロセス・出力フォーマットを明確に記述すること
Agent の整理
プラグインの agents ディレクトリ
plugin-name/
└── agents/
├── analyzer.md
├── reviewer.md
└── generator.md
agents/ ディレクトリ内のすべての .md ファイルは自動的に検出されます。
名前空間
Agent には自動的に名前空間が付与されます:
- 単一プラグイン:
agent-name - サブディレクトリあり:
plugin:subdir:agent-name
Agent のテスト
トリガーのテスト
Agent が正しく起動されることを検証するテストシナリオを作成します:
- 特定の起動サンプルを含む Agent を記述する
- テストでサンプルと同様の表現を使用する
- Claude が Agent を読み込むことを確認する
- Agent が期待どおりの機能を提供することを検証する
システムプロンプトのテスト
システムプロンプトが完全であることを確認します:
- Agent に典型的なタスクを与える
- プロセスのステップに従っていることを確認する
- 出力フォーマットが正しいことを検証する
- プロンプトに記載されたエッジケースをテストする
- 品質基準が満たされていることを確認する
クイックリファレンス
最小構成の Agent
---
name: simple-agent
description: 次のような場合に使用: [条件]。典型的なトリガーとして [トリガー1] や [トリガー2] などがあります。詳細な具体例は Agent 本体の "When to invoke" セクションを参照してください。
model: inherit
color: blue
---
あなたは [X を行う] Agent です。
## When to invoke
- **[シナリオ A].** [説明。]
- **[シナリオ B].** [説明。]
プロセス:
1. [ステップ 1]
2. [ステップ 2]
出力: [提供すべき内容]
フロントマターフィールド一覧
| フィールド | 必須 | フォーマット | 例 |
|---|---|---|---|
| name | 必須 | 小文字-ハイフン | code-reviewer |
| description | 必須 | 散文形式のトリガー | 次のような場合に使用:... 典型的なトリガーとして... |
| model | 必須 | inherit/sonnet/opus/haiku | inherit |
| color | 必須 | カラー名 | blue |
| tools | 任意 | ツール名の配列 | ["Read", "Grep"] |
ベストプラクティスまとめ
推奨事項:
- ✅ description に 2〜4 個のトリガーシナリオを散文形式で記載する
- ✅ 詳細な具体例は本体の "When to invoke" セクションに散文形式の箇条書きで記載する
- ✅ 起動条件を具体的に記述する
- ✅ 特別な理由がなければモデルは
inheritを使用する - ✅ 適切なツールを選択する(最小権限)
- ✅ 明確で構造化されたシステムプロンプトを記述する
- ✅ Agent のトリガーを十分
原文(English)を表示
Agent Development for Claude Code Plugins
Overview
Agents are autonomous subprocesses that handle complex, multi-step tasks independently. Understanding agent structure, triggering conditions, and system prompt design enables creating powerful autonomous capabilities.
Key concepts:
- Agents are FOR autonomous work, commands are FOR user-initiated actions
- Markdown file format with YAML frontmatter
- Triggering via description field with examples
- System prompt defines agent behavior
- Model and color customization
Agent File Structure
Complete Format
---
name: agent-identifier
description: Use this agent when [triggering conditions]. Typical triggers include [scenario 1 in prose], [scenario 2 in prose], and [scenario 3 in prose]. See "When to invoke" in the agent body for worked scenarios.
model: inherit
color: blue
tools: ["Read", "Write", "Grep"]
---
You are [agent role description]...
## When to invoke
[Two to four representative scenarios written as prose, e.g.:]
- **[Scenario name].** [What the situation looks like and what the agent should do.]
- **[Scenario name].** [Same.]
**Your Core Responsibilities:**
1. [Responsibility 1]
2. [Responsibility 2]
**Analysis Process:**
[Step-by-step workflow]
**Output Format:**
[What to return]
Frontmatter Fields
name (required)
Agent identifier used for namespacing and invocation.
Format: lowercase, numbers, hyphens only Length: 3-50 characters Pattern: Must start and end with alphanumeric
Good examples:
code-reviewertest-generatorapi-docs-writersecurity-analyzer
Bad examples:
helper(too generic)-agent-(starts/ends with hyphen)my_agent(underscores not allowed)ag(too short, < 3 chars)
description (required)
Defines when Claude should trigger this agent. This is the most critical field — it is loaded into context whenever the agent is registered, so the harness can decide when to dispatch.
Must include:
- Triggering conditions ("Use this agent when...")
- A short prose summary of the typical trigger scenarios
- A pointer to a "When to invoke" section in the agent body for the detailed worked scenarios
Format:
Use this agent when [conditions]. Typical triggers include [scenario 1 in prose], [scenario 2 in prose], and [scenario 3 in prose]. See "When to invoke" in the agent body for worked scenarios.
Best practices:
- Name 2-4 trigger scenarios in the prose summary
- Cover both proactive (assistant invokes itself) and reactive (user requests) triggering
- Cover different phrasings of the same intent
- Be specific about when NOT to use the agent
- Put detailed scenarios in the body under "When to invoke" as a bullet list of prose descriptions
model (required)
Which model the agent should use.
Options:
inherit- Use same model as parent (recommended)sonnet- Claude Sonnet (balanced)opus- Claude Opus (most capable, expensive)haiku- Claude Haiku (fast, cheap)
Recommendation: Use inherit unless agent needs specific model capabilities.
color (required)
Visual identifier for agent in UI.
Options: blue, cyan, green, yellow, magenta, red
Guidelines:
- Choose distinct colors for different agents in same plugin
- Use consistent colors for similar agent types
- Blue/cyan: Analysis, review
- Green: Success-oriented tasks
- Yellow: Caution, validation
- Red: Critical, security
- Magenta: Creative, generation
tools (optional)
Restrict agent to specific tools.
Format: Array of tool names
tools: ["Read", "Write", "Grep", "Bash"]
Default: If omitted, agent has access to all tools
Best practice: Limit tools to minimum needed (principle of least privilege)
Common tool sets:
- Read-only analysis:
["Read", "Grep", "Glob"] - Code generation:
["Read", "Write", "Grep"] - Testing:
["Read", "Bash", "Grep"] - Full access: Omit field or use
["*"]
System Prompt Design
The markdown body becomes the agent's system prompt. Write in second person, addressing the agent directly.
Structure
Standard template:
You are [role] specializing in [domain].
**Your Core Responsibilities:**
1. [Primary responsibility]
2. [Secondary responsibility]
3. [Additional responsibilities...]
**Analysis Process:**
1. [Step one]
2. [Step two]
3. [Step three]
[...]
**Quality Standards:**
- [Standard 1]
- [Standard 2]
**Output Format:**
Provide results in this format:
- [What to include]
- [How to structure]
**Edge Cases:**
Handle these situations:
- [Edge case 1]: [How to handle]
- [Edge case 2]: [How to handle]
Best Practices
✅ DO:
- Write in second person ("You are...", "You will...")
- Be specific about responsibilities
- Provide step-by-step process
- Define output format
- Include quality standards
- Address edge cases
- Keep under 10,000 characters
❌ DON'T:
- Write in first person ("I am...", "I will...")
- Be vague or generic
- Omit process steps
- Leave output format undefined
- Skip quality guidance
- Ignore error cases
Creating Agents
Method 1: AI-Assisted Generation
Use this prompt pattern (extracted from Claude Code):
Create an agent configuration based on this request: "[YOUR DESCRIPTION]"
Requirements:
1. Extract core intent and responsibilities
2. Design expert persona for the domain
3. Create comprehensive system prompt with:
- Clear behavioral boundaries
- Specific methodologies
- Edge case handling
- Output format
- A "When to invoke" section listing 2-4 trigger scenarios as prose bullets
4. Create identifier (lowercase, hyphens, 3-50 chars)
5. Write description with triggering conditions and a short prose summary of trigger scenarios
Return JSON with:
{
"identifier": "agent-name",
"whenToUse": "Use this agent when... Typical triggers include [...]. See \"When to invoke\" in the agent body.",
"systemPrompt": "You are..."
}
Then convert to agent file format with frontmatter.
See examples/agent-creation-prompt.md for complete template.
Method 2: Manual Creation
- Choose agent identifier (3-50 chars, lowercase, hyphens)
- Write description with examples
- Select model (usually
inherit) - Choose color for visual identification
- Define tools (if restricting access)
- Write system prompt with structure above
- Save as
agents/agent-name.md
Validation Rules
Identifier Validation
✅ Valid: code-reviewer, test-gen, api-analyzer-v2
❌ Invalid: ag (too short), -start (starts with hyphen), my_agent (underscore)
Rules:
- 3-50 characters
- Lowercase letters, numbers, hyphens only
- Must start and end with alphanumeric
- No underscores, spaces, or special characters
Description Validation
Length: 10-5,000 characters Must include: Triggering conditions and examples Best: 200-1,000 characters with 2-4 examples
System Prompt Validation
Length: 20-10,000 characters Best: 500-3,000 characters Structure: Clear responsibilities, process, output format
Agent Organization
Plugin Agents Directory
plugin-name/
└── agents/
├── analyzer.md
├── reviewer.md
└── generator.md
All .md files in agents/ are auto-discovered.
Namespacing
Agents are namespaced automatically:
- Single plugin:
agent-name - With subdirectories:
plugin:subdir:agent-name
Testing Agents
Test Triggering
Create test scenarios to verify agent triggers correctly:
- Write agent with specific triggering examples
- Use similar phrasing to examples in test
- Check Claude loads the agent
- Verify agent provides expected functionality
Test System Prompt
Ensure system prompt is complete:
- Give agent typical task
- Check it follows process steps
- Verify output format is correct
- Test edge cases mentioned in prompt
- Confirm quality standards are met
Quick Reference
Minimal Agent
---
name: simple-agent
description: Use this agent when [condition]. Typical triggers include [trigger 1] and [trigger 2]. See "When to invoke" in the agent body.
model: inherit
color: blue
---
You are an agent that [does X].
## When to invoke
- **[Scenario A].** [Description.]
- **[Scenario B].** [Description.]
Process:
1. [Step 1]
2. [Step 2]
Output: [What to provide]
Frontmatter Fields Summary
| Field | Required | Format | Example |
|---|---|---|---|
| name | Yes | lowercase-hyphens | code-reviewer |
| description | Yes | Prose triggers | Use when... Typical triggers include... |
| model | Yes | inherit/sonnet/opus/haiku | inherit |
| color | Yes | Color name | blue |
| tools | No | Array of tool names | ["Read", "Grep"] |
Best Practices
DO:
- ✅ Name 2-4 trigger scenarios in the description (as prose)
- ✅ Put detailed worked scenarios in a "When to invoke" body section, as prose bullets
- ✅ Write specific triggering conditions
- ✅ Use
inheritfor model unless specific need - ✅ Choose appropriate tools (least privilege)
- ✅ Write clear, structured system prompts
- ✅ Test agent triggering thoroughly
DON'T:
- ❌ Use generic descriptions without trigger scenarios
- ❌ Omit triggering conditions
- ❌ Give all agents same color
- ❌ Grant unnecessary tool access
- ❌ Write vague system prompts
- ❌ Skip testing
Additional Resources
Reference Files
For detailed guidance, consult:
references/system-prompt-design.md- Complete system prompt patternsreferences/triggering-examples.md- Example formats and best practicesreferences/agent-creation-system-prompt.md- The exact prompt from Claude Code
Example Files
Working examples in examples/:
agent-creation-prompt.md- AI-assisted agent generation templatecomplete-agent-examples.md- Full agent examples for different use cases
Utility Scripts
Development tools in scripts/:
validate-agent.sh- Validate agent file structuretest-agent-trigger.sh- Test if agent triggers correctly
Implementation Workflow
To create an agent for a plugin:
- Define agent purpose and triggering conditions
- Choose creation method (AI-assisted or manual)
- Create
agents/agent-name.mdfile - Write frontmatter with all required fields
- Write system prompt following best practices
- Name 2-4 trigger scenarios in description (prose) and detail them in a "When to invoke" body section
- Validate with
scripts/validate-agent.sh - Test triggering with real scenarios
- Document agent in plugin README
Focus on clear triggering conditions and comprehensive system prompts for autonomous operation.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。