メインコンテンツまでスキップ

カスタム Agent の作成

Elftia では、カスタム Agent を作成する方法が 2 つあります。アプリ内 UI を使う方法と、.claude/agents/*.md 設定ファイルを直接記述する方法です。どちらの方法でも、最終的には Markdown 形式の Agent 設定ファイルが作成されます。

UI から作成する

手順

  1. Agent パネル(サイドバーの Agent アイコン)を開きます
  2. 「My Agents」タブに切り替えます
  3. 「Create Agent」 ボタンをクリックします
  4. 次の設定項目を入力します。
項目説明
名前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
  1. 「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.

全項目リファレンス

項目デフォルト説明
namestringファイル名Agent の表示名
descriptionstringAgent の説明
modelstringmainモデル選択(エイリアスをサポート)
permissionModestringdefault権限モード
toolsstring[]すべて継承許可するツールの許可リスト
skillsstring[]なし自動ロードするスキル

設定例

例 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シェルコマンドを実行する機密
WebSearchWeb 検索安全
WebFetchWeb コンテンツを取得する安全
spawn_agentサブ Agent を起動する機密
list_skills利用可能なスキルを一覧表示する安全
read_skillスキル内容を読み取る安全
Notifyデスクトップ通知を送信する安全
SessionsYieldAgent ループを終了する安全

:::tip すべてのツールを継承するには省略してください tools フィールドを設定しない場合、Agent は利用可能なすべてのツール(MCP ツールを含む)を継承します。ツールの範囲を制限する必要がある場合にのみ、許可リストを設定してください。 :::

モデルエイリアスの詳細

エイリアス動作
main / inherit現在のセッションのメインモデルを使用します
backgroundユーザーが設定で構成したバックグラウンドモデルを使用します(通常は Haiku などの軽量モデル)
sonnet親モデルのファミリー名を sonnet に置き換えます(例: claude-3-opusclaude-3-sonnet
opus親モデルのファミリー名を opus に置き換えます
haiku親モデルのファミリー名を haiku に置き換えます

バックグラウンドモデルは、次の用途に適しています。

  • WebFetch コンテンツの要約
  • サブ Agent 向けの単純な補助タスク
  • 高い推論能力を必要としないデータ処理

スキルの関連付け

skills フィールドにスキル名を列挙します。Agent の起動時に、その内容がシステムプロンプトへ自動的に注入されます。

skills:
- code-standards # Project coding standards
- architecture-index # Project architecture index

スキルの検索順序:

  1. プロジェクトディレクトリ .claude/skills/<name>/SKILL.md
  2. 個人ディレクトリ ~/.claude/skills/<name>/SKILL.md
  3. プラグインディレクトリ ~/.elftia/plugins/skills/<name>/SKILL.md
  4. 組み込みスキル

テストとデバッグ

Agent を作成した後は、次のテストを行うことを推奨します。

  1. 基本的な会話 — Agent が自身の役割と機能を理解していることを確認します
  2. ツール呼び出し — ツール許可リストが正しく設定されていることを検証します
  3. 権限確認 — 権限モードが期待どおりに動作することを確認します
  4. スキルのロード — スキルがシステムプロンプトへ正しく注入されていることを確認します
  5. 境界テスト — Agent に未許可のツールを使用させようとして、正しく拒否されることを検証します

FAQ

問題原因解決策
Agent が指定したツールを使用しないシステムプロンプトで使用方法が示されていないどのツールをいつ使用するかをシステムプロンプトに明示します
Agent がシステムプロンプトを無視するユーザーメッセージが指示を上書きしているより強い表現のシステムプロンプトを使用し、「must」などのキーワードを追加します
スキルが反映されないスキル名のスペルが間違っているlist_skills ツールを使用して、利用可能なスキル名を確認します
ファイルが誤った場所に保存されるパスが正しくないファイルが .claude/agents/ または ~/.claude/agents/ の下にあることを確認します
YAML frontmatter の解析に失敗する書式エラー--- 区切りが使用されており、YAML 構文が有効であることを確認します

関連リンク