Subagents are specialized AI assistants defined as Markdown files with YAML frontmatter. Each subagent runs in its own context window with a custom system prompt, specific tool access, and independent permissions. When a task matches a subagent's description, the parent conversation delegates to it automatically, preserving main context while enforcing constraints.
When to use: Isolating high-volume operations (tests, logs), enforcing read-only access for reviewers, routing simple tasks to cheaper models, running parallel research, creating reusable team workflows.
When NOT to use: Tasks requiring frequent back-and-forth, quick targeted changes, workflows needing nested delegation (subagents cannot spawn subagents), latency-sensitive operations where fresh context gathering is costly.
Markdown ファイル内の YAML フロントマター構成を使用して、Claude Code のカスタム サブエージェントを作成します。エージェントのスコープ設定 (プロジェクト、ユーザー、CLI、プラグイン)、ツールのアクセス制御、モデルの選択、権限モード、スキルのプリロード、ライフサイクル フックについて説明します。 特殊なサブエージェントの構築、ツール アクセスの構成、モデルの選択、権限モードの設定、または委任パターンの設計時に使用します。エージェントの作成、サブエージェントの構成、カスタム エージェントのセットアップに使用します。 ソース: oakoss/agent-skills。