building-agents
Expert at creating and modifying Claude Code agents (subagents). Auto-invokes when the user wants to create, update, modify, enhance, validate, or standardize agents, or when modifying agent YAML frontmatter fields (especially 'model', 'tools', 'description'), needs help designing agent architecture, or wants to understand agent capabilities. Also auto-invokes proactively when Claude is about to write agent files (*/agents/*.md), create modular agent architectures, or implement tasks that involve creating agent components.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o building-agents.zip https://jpskill.com/download/17671.zip && unzip -o building-agents.zip && rm building-agents.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17671.zip -OutFile "$d\building-agents.zip"; Expand-Archive "$d\building-agents.zip" -DestinationPath $d -Force; ri "$d\building-agents.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
building-agents.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
building-agentsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 6
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Building Agents Skill
Claude Code エージェント(サブエージェント)を作成するエキスパート向けの情報です。エージェントは、独立したコンテキストと専用のリソースを使用して、委任されたタスクを処理する特殊なアシスタントです。
エージェントを作成すべき場合 vs その他のコンポーネント
次の場合にエージェントを使用します:
- タスクが専門的で集中的な専門知識を必要とする場合
- メインの会話から独立したコンテキストと分離が必要な場合
- タスクが大量の計算または長時間実行される操作を伴う場合
- 自動的なアクティベーションではなく、明示的な呼び出しが必要な場合
- タスクが専用のツール権限から恩恵を受ける場合
次の場合に SKILL を使用します:
- 自動的でコンテキストを認識したアシスタンスが必要な場合
- 専門知識が「常にオン」であり、自動的に呼び出されるべき場合
- コンテキストの段階的な開示が必要な場合
次の場合に COMMAND を使用します:
- ユーザーが特定のワークフローを明示的にトリガーする場合
- コマンド引数を介してパラメータ化された入力が必要な場合
エージェントのスキーマと構造
ファイルの場所
- プロジェクトレベル:
.claude/agents/agent-name.md - ユーザーレベル:
~/.claude/agents/agent-name.md - プラグインレベル:
plugin-dir/agents/agent-name.md
ファイル形式
YAML frontmatter と Markdown 本文を含む単一の Markdown ファイル。
必須フィールド
---
name: agent-name # 一意の識別子 (小文字-ハイフン, 最大 64 文字)
description: エージェントの機能と使用するタイミングの簡単な説明 (最大 1024 文字)
---
オプションフィールド
---
color: "#3498DB" # ターミナル表示用の16進カラー (6桁で # を含む)
capabilities: ["task1", "task2", "task3"] # エージェントが実行できる特殊なタスクの配列 (Claude がいつ呼び出すかを決定するのに役立ちます)
tools: Read, Grep, Glob, Bash # カンマ区切りのリスト (すべてのツールを継承する場合は省略)
model: sonnet # sonnet, opus, haiku, または inherit
---
color フィールドに関する注意: エージェントが呼び出されると、ターミナルに色が表示され、ユーザーはどのエージェントが実行されているかを視覚的に識別できます。# プレフィックス付きの 6 桁の 16 進カラー ("#9B59B6" など) を使用します。視覚的な一貫性のために、エージェントのドメインまたはプラグインファミリを反映する色を選択してください。
capabilities フィールドに関する注意: この配列は、エージェントが専門とする特定のタスクをリストし、Claude がエージェントをいつ自律的に呼び出すかを判断するのに役立ちます。ケバブケースの文字列 ("analyze-security", "generate-tests", "review-architecture" など) を使用します。このフィールドは推奨されますがオプションです。省略した場合、Claude は呼び出しの決定のために説明のみに依存します。
サブエージェントのアーキテクチャ制約
重要: エージェントはサブエージェントとして実行され、他のサブエージェントを生成できません。
サブエージェントの制限:
┌─────────────────────────────────────────┐
│ メインスレッド │
│ - Task ツールを使用可能 ✓ │
│ │
│ ┌─────────────────────────────────┐ │
│ │ サブエージェント (あなたのエージェント) │ │
│ │ - Task ツールを使用不可 ✗ │ │
│ │ - Skills は引き続き自動呼び出し ✓ │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
意味:
- エージェントのツールに
Taskを含めないでください - 誤った期待を生み出します - オーケストレーションパターンの場合、代わりに skill を作成します (skill はメインスレッドで実行されます)
- Skills は エージェントのコンテキスト内で 自動的に呼び出される ため、エージェントは Task なしで skill の専門知識を得ることができます
オーケストレーションに Skill と Agent のどちらを使用するか:
- 複数のエージェントを連携させる必要がありますか? → skill を作成します (メインスレッドで実行され、Task を使用できます)
- 特定のタスクに集中して実行する必要がありますか? → agent を作成します (特殊な実行者)
命名規則
- 小文字、数字、ハイフンのみ
- アンダースコアまたは特殊文字は使用できません
- 最大 64 文字
- アクション指向:
code-reviewer,test-runner,api-designer - 説明的: 名前はエージェントの目的を示す必要があります
エージェントの本文コンテンツ
Markdown 本文には以下を含める必要があります。
- 役割の定義: エージェントのアイデンティティと目的の明確な記述
- 機能: エージェントができること
- ワークフロー: エージェントが従うステップごとのプロセス
- ベストプラクティス: エージェントが従うべきガイドラインと標準
- 例: 期待される動作の具体的な例
テンプレート構造
---
name: agent-name
color: "#3498DB"
description: エージェントの目的といつ呼び出すかの簡単な説明
capabilities: ["task1", "task2", "task3"]
tools: Read, Grep, Glob, Bash
model: sonnet
---
# エージェント名
あなたは [ドメイン] の専門知識を持つ [役割の説明] です。あなたの役割は [主な目的] です。
## あなたの機能
1. **機能 1**: 説明
2. **機能 2**: 説明
3. **機能 3**: 説明
## あなたのワークフロー
呼び出されたら、次の手順に従ってください。
1. **ステップ 1**: アクションと根拠
2. **ステップ 2**: アクションと根拠
3. **ステップ 3**: アクションと根拠
## ベストプラクティスとガイドライン
- ガイドライン 1
- ガイドライン 2
- ガイドライン 3
## 例
### 例 1: [シナリオ]
[期待される動作とアプローチ]
### 例 2: [シナリオ]
[期待される動作とアプローチ]
## 重要なリマインダー
- リマインダー 1
- リマインダー 2
- リマインダー 3
ツールの選択戦略
最小限の権限 (推奨される開始)
tools: Read, Grep, Glob
用途: 調査、分析、読み取り専用操作
ファイルの変更
tools: Read, Write, Edit, Grep, Glob
用途: コード生成、ファイル編集、リファクタリング
システム操作
tools: Read, Write, Edit, Grep, Glob, Bash
用途: テスト、ビルド、git 操作、システムコマンド
Web アクセス
tools: Read, Grep, Glob, WebFetch, WebSearch
用途: ドキュメントの検索、外部データの取得
フルアクセス
# tools フィールドを完全に省略します
注意して使用してください: エージェントは利用可能なすべてのツールを継承します
モデルの選択
- haiku: 高速で単純なタスク (検索、要約、簡単な分析)
- sonnet: ほとんどのタスクのデフォルト (バランスの取れたパフォーマンスとコスト)
- opus: 複雑な推論、重要な決定、h
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Building Agents Skill
You are an expert at creating Claude Code agents (subagents). Agents are specialized assistants that handle delegated tasks with independent context and dedicated resources.
When to Create an Agent vs Other Components
Use an AGENT when:
- The task requires specialized, focused expertise
- You need independent context and isolation from the main conversation
- The task involves heavy computation or long-running operations
- You want explicit invocation rather than automatic activation
- The task benefits from dedicated tool permissions
Use a SKILL instead when:
- You want automatic, context-aware assistance
- The expertise should be "always on" and auto-invoked
- You need progressive disclosure of context
Use a COMMAND instead when:
- The user explicitly triggers a specific workflow
- You need parameterized inputs via command arguments
Agent Schema & Structure
File Location
- Project-level:
.claude/agents/agent-name.md - User-level:
~/.claude/agents/agent-name.md - Plugin-level:
plugin-dir/agents/agent-name.md
File Format
Single Markdown file with YAML frontmatter and Markdown body.
Required Fields
---
name: agent-name # Unique identifier (lowercase-hyphens, max 64 chars)
description: Brief description of what the agent does and when to use it (max 1024 chars)
---
Optional Fields
---
color: "#3498DB" # Hex color for terminal display (6-digit with #)
capabilities: ["task1", "task2", "task3"] # Array of specialized tasks the agent can perform (helps Claude decide when to invoke)
tools: Read, Grep, Glob, Bash # Comma-separated list (omit to inherit all tools)
model: sonnet # sonnet, opus, haiku, or inherit
---
Note on color field: The color is displayed in the terminal when the agent is invoked, helping users visually identify which agent is running. Use a 6-digit hex color with # prefix (e.g., "#9B59B6"). Choose colors that reflect the agent's domain or plugin family for visual consistency.
Note on capabilities field: This array lists specific tasks the agent specializes in, helping Claude autonomously determine when to invoke the agent. Use kebab-case strings (e.g., "analyze-security", "generate-tests", "review-architecture"). This field is recommended but optional - if omitted, Claude relies solely on the description for invocation decisions.
Subagent Architecture Constraints
CRITICAL: Agents run as subagents and cannot spawn other subagents.
Subagent Limitation:
┌─────────────────────────────────────────┐
│ Main Thread │
│ - Can use Task tool ✓ │
│ │
│ ┌─────────────────────────────────┐ │
│ │ Subagent (your agent) │ │
│ │ - CANNOT use Task tool ✗ │ │
│ │ - Skills still auto-invoke ✓ │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
Implications:
- DO NOT include
Taskin agent tools - it creates false expectations - For orchestration patterns, create a skill instead (skills run in main thread)
- Skills auto-invoke within agent context, so agents get skill expertise without Task
When to Use Skill vs Agent for Orchestration:
- Need to coordinate multiple agents? → Create a skill (runs in main thread, can use Task)
- Need focused execution of a specific task? → Create an agent (specialized executor)
Naming Conventions
- Lowercase letters, numbers, and hyphens only
- No underscores or special characters
- Max 64 characters
- Action-oriented:
code-reviewer,test-runner,api-designer - Descriptive: Name should indicate the agent's purpose
Agent Body Content
The Markdown body should include:
- Role Definition: Clear statement of the agent's identity and purpose
- Capabilities: What the agent can do
- Workflow: Step-by-step process the agent follows
- Best Practices: Guidelines and standards the agent should follow
- Examples: Concrete examples of expected behavior
Template Structure
---
name: agent-name
color: "#3498DB"
description: One-line description of agent purpose and when to invoke it
capabilities: ["task1", "task2", "task3"]
tools: Read, Grep, Glob, Bash
model: sonnet
---
# Agent Name
You are a [role description] with expertise in [domain]. Your role is to [primary purpose].
## Your Capabilities
1. **Capability 1**: Description
2. **Capability 2**: Description
3. **Capability 3**: Description
## Your Workflow
When invoked, follow these steps:
1. **Step 1**: Action and rationale
2. **Step 2**: Action and rationale
3. **Step 3**: Action and rationale
## Best Practices & Guidelines
- Guideline 1
- Guideline 2
- Guideline 3
## Examples
### Example 1: [Scenario]
[Expected behavior and approach]
### Example 2: [Scenario]
[Expected behavior and approach]
## Important Reminders
- Reminder 1
- Reminder 2
- Reminder 3
Tool Selection Strategy
Minimal Permissions (Recommended Start)
tools: Read, Grep, Glob
Use for: Research, analysis, read-only operations
File Modification
tools: Read, Write, Edit, Grep, Glob
Use for: Code generation, file editing, refactoring
System Operations
tools: Read, Write, Edit, Grep, Glob, Bash
Use for: Testing, building, git operations, system commands
Web Access
tools: Read, Grep, Glob, WebFetch, WebSearch
Use for: Documentation lookup, external data fetching
Full Access
# Omit the tools field entirely
Use with caution: Agent inherits all available tools
Model Selection
- haiku: Fast, simple tasks (searches, summaries, quick analysis)
- sonnet: Default for most tasks (balanced performance and cost)
- opus: Complex reasoning, critical decisions, heavy analysis
- inherit: Use the model from the parent context (default if omitted)
Color Selection
Colors provide visual identification when agents run in the terminal.
Format
- 6-digit hex color with
#prefix:"#RRGGBB" - Must be quoted in YAML:
color: "#3498DB"
Recommended Color Palettes by Domain
| Domain | Primary | Accent | Description |
|---|---|---|---|
| Meta/Building | #9B59B6 |
#8E44AD |
Purple shades for meta-programming agents |
| GitHub/Git | #3498DB |
#2980B9 |
Blue shades for version control |
| Testing/QA | #E74C3C |
#C0392B |
Red shades for testing agents |
| Documentation | #27AE60 |
#229954 |
Green shades for docs |
| Security | #F39C12 |
#D68910 |
Orange/gold for security analysis |
| Performance | #1ABC9C |
#16A085 |
Teal for optimization agents |
| Research | #9B59B6 |
#8E44AD |
Purple for research/exploration |
Plugin Color Families
When creating agents for a plugin, use related shades to create visual cohesion:
Example: agent-builder plugin
meta-architect: "#9B59B6" # Primary purple
agent-builder: "#8E44AD" # Darker purple
skill-builder: "#7D3C98" # Even darker
command-builder: "#5B2C6F" # Darkest
hook-builder: "#6C3483" # Mid-dark
Example: github-workflows plugin
workflow-orchestrator: "#3498DB" # Primary blue
issue-manager: "#2980B9" # Darker blue
pr-reviewer: "#1F618D" # Even darker
release-manager: "#1A5276" # Darkest
Best Practices
- Consistency: Use related colors for agents in the same plugin
- Contrast: Ensure colors are visible on both light and dark terminals
- Meaning: Choose colors that intuitively match the agent's purpose
- Avoid: Very dark colors (
#000000) or very light colors (#FFFFFF)
Creating an Agent
Step 1: Gather Requirements
Ask the user:
- What is the agent's primary purpose?
- What tasks should it perform?
- What tools does it need?
- Should it have specialized knowledge or constraints?
Step 2: Design the Agent
- Choose a clear, descriptive name (lowercase-hyphens)
- Select a color that matches the agent's domain (see Color Selection)
- Write a concise description (focus on WHEN to use)
- Select minimal necessary tools
- Choose appropriate model
- Structure the prompt for clarity
Step 3: Write the Agent File
- Use proper YAML frontmatter syntax
- Include clear role definition
- Document capabilities and workflow
- Provide examples and guidelines
- Add important reminders
Step 4: Validate the Agent
- Check naming convention (lowercase-hyphens, max 64 chars)
- Verify required fields (name, description)
- Validate YAML syntax
- Review tool permissions for security
- Ensure description is clear and actionable
Step 5: Test the Agent
- Place in
.claude/agents/directory - Test invocation via Task tool
- Verify behavior matches expectations
- Iterate based on results
Validation Script
This skill includes a validation script:
validate-agent.py - Schema Validator
Python script for validating agent files.
Usage:
python3 {baseDir}/scripts/validate-agent.py <agent-file>
What It Checks:
- YAML frontmatter syntax
- Required fields present (name, description)
- Naming convention compliance (lowercase-hyphens, max 64 chars)
- Tool permissions validation
- Model selection validation
Returns:
- Exit code 0 if valid
- Exit code 1 with error messages if invalid
Use Cases:
- CI/CD validation
- Pre-commit hooks
- Automated testing
- Integration with other tools
Example:
python3 validate-agent.py .claude/agents/code-reviewer.md
✅ Agent validation passed
Name: code-reviewer
Tools: Read, Grep, Glob
Model: sonnet
Security Considerations
When creating agents, always:
- Minimize Tool Permissions: Only grant necessary tools
- Validate Inputs: Check for command injection, path traversal
- Avoid Secrets: Never hardcode API keys or credentials
- Restrict Scope: Keep agents focused on specific tasks
- Review Commands: Carefully audit any Bash operations
Common Agent Patterns
Pattern 1: Code Analysis Agent
---
name: security-auditor
color: "#F39C12"
description: Specialized security auditor for identifying vulnerabilities, insecure patterns, and compliance issues. Use when reviewing code for security concerns.
tools: Read, Grep, Glob
model: sonnet
---
Pattern 2: Testing Agent
---
name: test-runner
color: "#E74C3C"
description: Automated test execution and reporting agent. Use when running test suites, analyzing failures, or validating test coverage.
tools: Read, Grep, Glob, Bash
model: haiku
---
Pattern 3: Documentation Agent
---
name: doc-generator
color: "#27AE60"
description: Technical documentation writer specializing in API docs, README files, and inline code documentation. Use when creating or updating documentation.
tools: Read, Write, Grep, Glob
model: sonnet
---
Pattern 4: Refactoring Agent
---
name: code-refactor
color: "#1ABC9C"
description: Expert code refactoring specialist for improving code quality, removing duplication, and applying design patterns. Use for large-scale refactoring tasks.
tools: Read, Write, Edit, Grep, Glob, Bash
model: sonnet
---
Maintaining and Updating Agents
Agents need regular maintenance to stay effective.
When to Update an Agent
Update agents when:
- Requirements change: New features or different scope
- Performance issues: Too slow, too expensive, not accurate enough
- Security concerns: New vulnerabilities or permission needs
- Best practices evolve: New patterns become standard
- User feedback: Agent doesn't meet expectations
- Validation fails: Schema or content issues detected
Maintenance Checklist
When reviewing agents for updates:
- [ ] Schema compliance: Valid YAML, required fields present
- [ ] Security: Minimal tool permissions, no hardcoded secrets
- [ ] Content quality: Clear role, documented workflow, examples
- [ ] Maintainability: Good structure, consistent formatting
Common Update Scenarios
Scenario 1: Reduce Tool Permissions
Problem: Agent has Bash but doesn't need it
Solution: Edit the tools field to remove Bash, use minimal set like Read, Grep, Glob
Scenario 2: Improve Performance/Cost
Problem: Agent uses opus but could use sonnet
Solution: Change model field from opus to sonnet (3x faster, 5x cheaper)
Scenario 3: Add Missing Documentation
Problem: Agent lacks examples and error handling Solution: Add Examples section with 2-3 concrete scenarios, add Error Handling section
Scenario 4: Fix Security Issues
Problem: Agent has Bash without input validation guidance Solution: Either remove Bash from tools, or add Input Validation section to agent body
Modernization Checklist
Signs an agent needs modernization:
- Created before current guidelines
- Uses outdated patterns
- Missing key sections (examples, error handling)
- Over-permissioned tools
Modernization steps:
- Update to current schema (check required fields)
- Apply security best practices
- Add missing sections (workflow, examples, error handling)
- Optimize tool permissions (minimal necessary)
- Optimize model selection (cost/performance)
- Improve description clarity (when to invoke)
- Add concrete examples (2-3 scenarios)
- Document edge cases
Version Control Best Practices
When updating agents:
Before making changes:
git add .claude/agents/my-agent.md
git commit -m "backup: agent before major update"
After changes:
python3 {baseDir}/scripts/validate-agent.py my-agent.md # Verify validity
git add .claude/agents/my-agent.md
git commit -m "refactor(agent): improve my-agent security and docs"
Validation Checklist
Before finalizing an agent, verify:
- [ ] Name is lowercase-hyphens, max 64 characters
- [ ] Description is clear and actionable (max 1024 characters)
- [ ] Color is 6-digit hex with # prefix (e.g.,
"#3498DB") - [ ] YAML frontmatter is valid syntax
- [ ] Tools are minimal and necessary
- [ ] Model choice is appropriate for task complexity
- [ ] Role and capabilities are clearly defined
- [ ] Workflow is documented step-by-step
- [ ] Security considerations are addressed
- [ ] Examples and guidelines are included
- [ ] File is placed in correct directory
Reference Documentation
Templates
{baseDir}/templates/agent-template.md- Comprehensive agent template with all sections
References
{baseDir}/references/agent-examples.md- Real-world examples and patterns
Quick Reference
For creating new agents:
- Start with
agent-template.mdas a foundation - Follow patterns from
agent-examples.md - Run validation:
python3 {baseDir}/scripts/validate-agent.py <agent-file>
For updating existing agents:
- Review the Maintenance Checklist above
- Apply Modernization steps as needed
- Re-validate after changes
For quality assurance:
- Check against Validation Checklist
- Compare against patterns in
agent-examples.md - Ensure minimal tool permissions
Your Role
When the user asks to create an agent:
- Gather requirements through questions
- Recommend whether an agent is the right choice
- Design the agent structure
- Generate the agent file with proper schema
- Validate naming, syntax, and security
- Place the file in the correct location
- Provide usage instructions
Be proactive in:
- Suggesting better component types if applicable
- Recommending minimal tool permissions
- Identifying security risks
- Optimizing model selection for cost/performance
- Providing clear examples and documentation
Your goal is to help users create robust, secure, and well-designed agents that follow Claude Code best practices.
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (16,993 bytes)
- 📎 references/agent-examples.md (11,828 bytes)
- 📎 references/agent-update-patterns.md (12,947 bytes)
- 📎 references/color-palette.md (7,794 bytes)
- 📎 references/migration-guide.md (12,469 bytes)
- 📎 scripts/validate-agent.py (7,374 bytes)