カスタム Agent の作成
Elftia では、カスタム Agent を作成する方法が 2 つあります。アプリ内 UI を使う方法と、.claude/agents/*.md 設定ファイルを直接記述する方法です。どちらの方法でも、最終的には Markdown 形式の Agent 設定ファイルが作成されます。
UI から作成する
手順
- Agent パネル(サイドバーの Agent アイコン)を開きます
- 「My Agents」タブに切り替えます
- 「Create Agent」 ボタンをクリックします
- 次の設定項目を入力します。
| 項目 | 説明 | 例 |
|---|---|---|
| 名前 | Agent の表示名 | Frontend Code Reviewer |
| 説明 | Agent の機能を 1 文で要約したもの | Review React/TypeScript code quality |
| システムプロンプト | Agent の中心となる指示(Markdown 形式) | 下の例を参照 |
| モデル | 使用する LLM モデルまたはエイリアス | main, background |
| ツールリスト | 許可するツール(空欄 = すべて継承) | Read, Grep, Glob |
| スキル | 自動ロードするスキル | code-standards |
| MCP サーバー | 関連付ける MCP サーバー | github-mcp |
| 権限モード | ツール実行のセキュリティレベル | default |
- 「Save」をクリックして完了します
保存場所を選ぶ
作成時に保存先を選択できます。
- プロジェクトレベル — 現在のプロジェクトの
.claude/agents/ディレクトリに保存されます。このプロジェクト内でのみ利用できます - 個人レベル —
~/.claude/agents/に保存されます。すべてのプロジェクトで利用できます
ファイルから作成する
.claude/agents/ ディレクトリに Markdown ファイルを作成するだけです。ファイル名が Agent の識別子になります。
ファイル形式
---
name: Agent Name
description: Agent description
model: main
permissionMode: default
tools:
- Read
- Write
- Edit
- Bash
- Glob
- Grep
- ListDir
- WebSearch
- WebFetch
skills:
- code-standards
---
This is the body of the system prompt (Markdown format).
The Agent will follow these instructions when executing tasks.
全項目リファレンス
| 項目 | 型 | デフォルト | 説明 |
|---|---|---|---|
name | string | ファイル名 | Agent の表示名 |
description | string | 空 | Agent の説明 |
model | string | main | モデル選択(エイリアスをサポート) |
permissionMode | string | default | 権限モード |
tools | string[] | すべて継承 | 許可するツールの許可リスト |
skills | string[] | なし | 自動ロードするスキル |
設定例
例 1: プログラミングアシスタント
コーディングタスクに特化し、ファイルシステムとシェルへの完全なアクセス権を持ちます。
---
name: Full-Stack Programming Assistant
description: Full-stack development assistant, proficient in TypeScript/React/Node.js
model: main
permissionMode: acceptEdits
tools:
- Read
- Write
- Edit
- Bash
- Glob
- Grep
- ListDir
- WebSearch
- WebFetch
- spawn_agent
skills:
- code-standards
- architecture-index
---
You are a full-stack development assistant, proficient in TypeScript, React, and Node.js.
## Workflow
1. Understand the requirements first; ask clarifying questions if needed
2. Use Glob/Grep to find relevant code
3. Use Read to review key files
4. Formulate an implementation plan
5. Use Write/Edit to write code
6. Use Bash to run tests
## Coding Standards
- Follow the project's ESLint and Prettier configuration
- New files should not exceed 400 lines
- Use TypeScript strict mode
- Add JSDoc comments for public APIs
例 2: リサーチ分析 Agent
読み取り専用モードで、情報収集と分析に特化します。
---
name: Research Analyst
description: Gather information from the codebase and the web for in-depth analysis
model: main
permissionMode: plan
tools:
- Read
- Glob
- Grep
- ListDir
- WebSearch
- WebFetch
- list_skills
- read_skill
---
You are a research analyst skilled at gathering information from codebases and the web.
## Working Method
1. Carefully understand the research topic
2. Use Grep/Glob to search the codebase for relevant information
3. Use WebSearch to find external references
4. Use WebFetch to retrieve detailed web content
5. Synthesize all information into a structured analysis report
## Output Format
Use Markdown format for the report, including:
- Summary
- Key findings
- Detailed analysis
- Recommendations and conclusions
例 3: タスク自動化 Agent
バックグラウンドのサブ Agent を使用して、複数のサブタスクを並列に処理します。
---
name: Task Orchestrator
description: Break down complex tasks into subtasks and execute them in parallel
model: main
permissionMode: acceptEdits
tools:
- Read
- Write
- Edit
- Bash
- Glob
- Grep
- ListDir
- spawn_agent
- Notify
---
You are a task orchestrator skilled at breaking complex tasks into parallelizable subtasks.
## Workflow
1. Analyze the task and identify subtasks that can run in parallel
2. Use spawn_agent to launch sub-Agents for each subtask
3. Collect the results from sub-Agents
4. Integrate the results and verify consistency
5. Use Notify to signal task completion
## Sub-Agent Principles
- Each sub-Agent is responsible for one well-defined subtask
- Prefer background mode (background: true) for parallel execution
- Equip sub-Agents with the minimum necessary tool set
- Set a reasonable maxIterations to avoid infinite loops
ツール許可リストの設定
tools フィールドは、Agent が使用を許可されるツールを制御します。
利用可能なツール名
| ツール | 説明 | 機密度 |
|---|---|---|
Read | ファイル内容を読み取る | 安全 |
Write | ファイルを書き込む | 機密 |
Edit | ファイルを編集する(検索と置換) | 機密 |
ListDir | ディレクトリ内容を一覧表示する | 安全 |
Glob | ファイル名のパターンマッチング | 安全 |
Grep | 内容検索 | 安全 |
Bash | シェルコマンドを実行する | 機密 |
WebSearch | Web 検索 | 安全 |
WebFetch | Web コンテンツを取得する | 安全 |
spawn_agent | サブ Agent を起動する | 機密 |
list_skills | 利用可能なスキルを一覧表示する | 安全 |
read_skill | スキル内容を読み取る | 安全 |
Notify | デスクトップ通知を送信する | 安全 |
SessionsYield | Agent ループを終了する | 安全 |
:::tip すべてのツールを継承するには省略してください
tools フィールドを設定しない場合、Agent は利用可能なすべてのツール(MCP ツールを含む)を継承します。ツールの範囲を制限する必要がある場合にのみ、許可リストを設定してください。
:::
モデルエイリアスの詳細
| エイリアス | 動作 |
|---|---|
main / inherit | 現在のセッションのメインモデルを使用します |
background | ユーザーが設定で構成したバックグラウンドモデルを使用します(通常は Haiku などの軽量モデル) |
sonnet | 親モデルのファミリー名を sonnet に置き換えます(例: claude-3-opus → claude-3-sonnet) |
opus | 親モデルのファミリー名を opus に置き換えます |
haiku | 親モデルのファミリー名を haiku に置き換えます |
バックグラウンドモデルは、次の用途に適しています。
- WebFetch コンテンツの要約
- サブ Agent 向けの単純な補助タスク
- 高い推論能力を必要としないデータ処理
スキルの関連付け
skills フィールドにスキル名を列挙します。Agent の起動時に、その内容がシステムプロンプトへ自動的に注入されます。
skills:
- code-standards # Project coding standards
- architecture-index # Project architecture index
スキルの検索順序:
- プロジェクトディレクトリ
.claude/skills/<name>/SKILL.md - 個人ディレクトリ
~/.claude/skills/<name>/SKILL.md - プラグインディレクトリ
~/.elftia/plugins/skills/<name>/SKILL.md - 組み込みスキル
テストとデバッグ
Agent を作成した後は、次のテストを行うことを推奨します。
- 基本的な会話 — Agent が自身の役割と機能を理解していることを確認します
- ツール呼び出し — ツール許可リストが正しく設定されていることを検証します
- 権限確認 — 権限モードが期待どおりに動作することを確認します
- スキルのロード — スキルがシステムプロンプトへ正しく注入されていることを確認します
- 境界テスト — Agent に未許可のツールを使用させようとして、正しく拒否されることを検証します
FAQ
| 問題 | 原因 | 解決策 |
|---|---|---|
| Agent が指定したツールを使用しない | システムプロンプトで使用方法が示されていない | どのツールをいつ使用するかをシステムプロンプトに明示します |
| Agent がシステムプロンプトを無視する | ユーザーメッセージが指示を上書きしている | より強い表現のシステムプロンプトを使用し、「must」などのキーワードを追加します |
| スキルが反映されない | スキル名のスペルが間違っている | list_skills ツールを使用して、利用可能なスキル名を確認します |
| ファイルが誤った場所に保存される | パスが正しくない | ファイルが .claude/agents/ または ~/.claude/agents/ の下にあることを確認します |
| YAML frontmatter の解析に失敗する | 書式エラー | --- 区切りが使用されており、YAML 構文が有効であることを確認します |
関連リンク
- 組み込み Agent — プリセット Agent の設定を参照します
- ツール権限とセキュリティ — 権限モードの詳細な説明
- スキルシステム — スキルを作成および管理します