sub-agents について
sub-agentsは、独立したコンテキストを持つ専門エージェントの作成・管理を扱うリファレンススキルです。設定、組み込みエージェント、モデル選択、連携のほか、メニュー、ファイル、コマンドラインでの操作を説明します。
主な機能
- 01独立コンテキストのエージェント作成
- 02ツールとモデルの設定
- 03組み込みエージェントの利用
- 04メニュー、ファイル、コマンドラインでの管理
- 05エージェントの再開と連携
活用シーン
- 01コードレビュー担当の設定
- 02タスクに応じたモデル選択
- 03エージェントの利用ツールを制限
- 04分析と実装のエージェントを連携
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ parcadei/ continuous-claude-v3 --skill sub-agentsインストール後、Claude Code で/sub-agentsを入力して読み込まれたか確認します。
詳細
サブエージェントのリファレンス
特定のタスク向けに、コンテキストが分離された専門的な AI エージェントを作成します。
使用するタイミング
- 「サブエージェントを作成するにはどうすればよいですか?」
- 「エージェントのツールを設定する」
- 「組み込みエージェントには何がありますか?」
- 「エージェントのモデル選択」
- 「エージェントのチェーン化パターン」
クイックスタート
対話形式(推奨)
/agents
エージェントの作成、編集、管理を行うメニューが開きます。
手動での作成
mkdir -p .claude/agents
cat > .claude/agents/reviewer.md << 'EOF'
---
name: reviewer
description: Code review specialist. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer focusing on quality and security.
## Review Checklist
- Code clarity and naming
- Error handling
- Security vulnerabilities
- Test coverage
EOF
CLI ベース
claude --agents '{
"reviewer": {
"description": "Code reviewer",
"prompt": "Review for quality and security",
"tools": ["Read", "Bash"],
"model": "sonnet"
}
}'
エージェントのファイル形式
---
name: agent-name
description: When/why to use this agent
tools: Read, Edit, Bash # Optional, inherits all if omitted
model: sonnet # sonnet, haiku, claude-opus-4-5-20251101, inherit
---
System prompt content here...
設定フィールド
| フィールド | 必須 | オプション |
|---|---|---|
name | はい | 小文字、ハイフン |
description | はい | 使用するタイミング |
tools | いいえ | ツール一覧(省略するとすべて継承) |
model | いいえ | sonnet、haiku、claude-opus-4-5-20251101、inherit |
組み込みエージェント
| エージェント | モデル | ツール | 用途 |
|---|---|---|---|
| 汎用 | Sonnet | すべて | 複雑な複数ステップのタスク |
| Plan | Sonnet | 読み取り専用 | 計画モードでの調査 |
| Explore | Haiku | 読み取り専用 | コードベースの高速検索 |
モデルの選択
| モデル | 速度 | 最適な用途 |
|---|---|---|
| Haiku | 最速 | 検索、簡単な情報確認 |
| Sonnet | 高速 | ほとんどのタスク(デフォルト) |
| Opus | 低速 | 複雑な推論 |
ツールの組み合わせ
# Code Reviewer (read-only)
tools: Read, Grep, Glob, Bash
# Debugger
tools: Read, Edit, Bash, Grep, Glob
# Implementer
tools: Read, Write, Edit, Bash, Glob
エージェントの例
コードレビュー担当
---
name: code-reviewer
description: Reviews code for quality and security. Use after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
Review code for:
- Security vulnerabilities
- Code quality issues
- Missing error handling
- Test coverage gaps
Output findings by priority: Critical > Warning > Suggestion
デバッガー
---
name: debugger
description: Debug errors and test failures.
tools: Read, Edit, Bash, Grep, Glob
model: inherit
---
Debugging process:
1. Capture error details
2. Identify failure location
3. Form hypotheses
4. Test and verify
5. Implement fix
ファイルの場所
| 種類 | 場所 | 優先度 |
|---|---|---|
| プロジェクト | .claude/agents/ | 最高 |
| ユーザー | ~/.claude/agents/ | 低 |
高度なパターン
再開可能なエージェント
[Agent returns agentId: "abc123"]
# Later: resume with context
claude -r "abc123" "Continue analysis"
エージェントのチェーン化
Use code-analyzer to find issues,
then use optimizer to fix them
ベストプラクティス
- 単一責任 - エージェントごとに明確な目的を1つ設定します
- ツールを制限する - 必要なものだけを許可します
- 明確な説明 - 行動を促す内容にし、「proactively」を含めます
- バージョン管理 -
.claude/agents/を git に追加します
コメント
Markdown 対応