ダブルクリックで英日反転
Applied Sciences · Engineering
Claude Code Agent Layers: A Clear Breakdown
Claude Code ships five distinct "agent-ish" primitives. Conflating them makes orchestration impossible; each has a precise role and the right one depends on what you actually need.
The Five Layers
- Slash command — text expansion + permissions, triggered by typing `/foo`
- Skill — a how-to document auto-injected when its description matches a condition
- Sub-agent — an independent LLM call in a separate context window, spawned via the Task tool
- Hook — a shell script bound to tool events (PreToolUse / PostToolUse / Stop / SessionStart)
- MCP server — exposes an external API as a tool, connected at session start
What Makes a Sub-Agent Special
- Runs in a completely separate context window — cannot see the parent's history
- Returns a single message; the parent only sees that result
- Multiple sub-agents can be launched in parallel within one message
- "worktree" flag also creates a git worktree for physical file isolation
Skill vs Sub-Agent vs Hook
- Skill: injects a procedure into context — no code runs, no separate LLM call
- Sub-agent: actually does work in its own LLM call, for heavy or parallel tasks
- Hook: pure shell, not an LLM — rules that need certainty belong here
Open Questions
- Cost of deep sub-agent nesting grows exponentially — budget carefully
- Skill auto-triggering accuracy depends entirely on description quality
- Boundary between Hook and Skill (auto-commit = Hook; auto-review = Skill for now)
- Background job ≠ sub-agent: a bg job shares the parent's context; a sub-agent does not
→ Map each need to the right primitive: sub-agent for parallel/isolated work, Skill for reusable procedures, Slash command for fixed wording, Hook for tool-call automation, MCP for external APIs.
応用科学 · エンジニアリング
Claude Code エージェント層の整理
Claude Code には5種類の「エージェント的」プリミティブ(=基本構成要素)がある。混同すると orchestration(=複数エージェントの協調制御)の設計が破綻するため、それぞれの役割を明確に区別する。
5つの層
- Slash command — `/foo` と入力して起動するテキスト展開+権限付与
- Skill — 説明文が条件に一致したとき、手順書をコンテキストへ自動注入
- Sub-agent — Task ツールで起動する独立 LLM 呼び出し。別コンテキストウィンドウで動く
- Hook — ツールイベント(PreToolUse / PostToolUse / Stop 等)に紐づくシェルスクリプト
- MCP サーバー — 外部 API をツールとして公開し、セッション開始時に接続
Sub-agent の特徴
- 完全に独立したコンテキストウィンドウで動作し、親の会話履歴を参照できない
- 返り値は単一メッセージのみ。親が見るのはその結果だけ
- 1つのメッセージ内で複数の sub-agent を並列起動できる
- "worktree" 指定でgit worktreeも自動作成し、ファイル編集を物理的に分離可能
Skill / Sub-agent / Hook の違い
- Skill: 手順をコンテキストへ注入するだけ。コードを実行せず、LLM 呼び出しも起きない
- Sub-agent: 独自の LLM 呼び出しで実際の作業を行う。重処理・並列処理向き
- Hook: LLM でなく純粋なシェル。確実性が必要なルールはここに置く
未解決の課題
- Sub-agent を多段ネストするとコストが指数的に膨らむ——予算管理が重要
- Skill の自動起動精度は説明文の品質に完全依存
- Hook と Skill の責任境界(現時点: 自動コミット=Hook、自動レビュー=Skill)
- バックグラウンドジョブ ≠ sub-agent: bg job は親のコンテキストを共有する
→ 用途に合ったプリミティブを選ぶ: 並列・分離作業は sub-agent、手順の再利用は Skill、定型文は Slash command、ツール連動の自動処理は Hook、外部 API は MCP。
Applied Sciences · Engineering
Claude Code Agent Layers: A Clear Breakdown
Claude Code ships five distinct "agent-ish" primitives. Conflating them makes orchestration impossible; each has a precise role and the right one depends on what you actually need.
The Five Layers
- Slash command — text expansion + permissions, triggered by typing `/foo`
- Skill — a how-to document auto-injected when its description matches a condition
- Sub-agent — an independent LLM call in a separate context window, spawned via the Task tool
- Hook — a shell script bound to tool events (PreToolUse / PostToolUse / Stop / SessionStart)
- MCP server — exposes an external API as a tool, connected at session start
What Makes a Sub-Agent Special
- Runs in a completely separate context window — cannot see the parent's history
- Returns a single message; the parent only sees that result
- Multiple sub-agents can be launched in parallel within one message
- "worktree" flag also creates a git worktree for physical file isolation
Skill vs Sub-Agent vs Hook
- Skill: injects a procedure into context — no code runs, no separate LLM call
- Sub-agent: actually does work in its own LLM call, for heavy or parallel tasks
- Hook: pure shell, not an LLM — rules that need certainty belong here
Open Questions
- Cost of deep sub-agent nesting grows exponentially — budget carefully
- Skill auto-triggering accuracy depends entirely on description quality
- Boundary between Hook and Skill (auto-commit = Hook; auto-review = Skill for now)
- Background job ≠ sub-agent: a bg job shares the parent's context; a sub-agent does not
→ Map each need to the right primitive: sub-agent for parallel/isolated work, Skill for reusable procedures, Slash command for fixed wording, Hook for tool-call automation, MCP for external APIs.
応用科学 · エンジニアリング
Claude Code エージェント層の整理
Claude Code には5種類の「エージェント的」プリミティブ(=基本構成要素)がある。混同すると orchestration(=複数エージェントの協調制御)の設計が破綻するため、それぞれの役割を明確に区別する。
5つの層
- Slash command — `/foo` と入力して起動するテキスト展開+権限付与
- Skill — 説明文が条件に一致したとき、手順書をコンテキストへ自動注入
- Sub-agent — Task ツールで起動する独立 LLM 呼び出し。別コンテキストウィンドウで動く
- Hook — ツールイベント(PreToolUse / PostToolUse / Stop 等)に紐づくシェルスクリプト
- MCP サーバー — 外部 API をツールとして公開し、セッション開始時に接続
Sub-agent の特徴
- 完全に独立したコンテキストウィンドウで動作し、親の会話履歴を参照できない
- 返り値は単一メッセージのみ。親が見るのはその結果だけ
- 1つのメッセージ内で複数の sub-agent を並列起動できる
- "worktree" 指定でgit worktreeも自動作成し、ファイル編集を物理的に分離可能
Skill / Sub-agent / Hook の違い
- Skill: 手順をコンテキストへ注入するだけ。コードを実行せず、LLM 呼び出しも起きない
- Sub-agent: 独自の LLM 呼び出しで実際の作業を行う。重処理・並列処理向き
- Hook: LLM でなく純粋なシェル。確実性が必要なルールはここに置く
未解決の課題
- Sub-agent を多段ネストするとコストが指数的に膨らむ——予算管理が重要
- Skill の自動起動精度は説明文の品質に完全依存
- Hook と Skill の責任境界(現時点: 自動コミット=Hook、自動レビュー=Skill)
- バックグラウンドジョブ ≠ sub-agent: bg job は親のコンテキストを共有する
→ 用途に合ったプリミティブを選ぶ: 並列・分離作業は sub-agent、手順の再利用は Skill、定型文は Slash command、ツール連動の自動処理は Hook、外部 API は MCP。
Related notes
- Agentic Commerce — ACP and Visibility into Being 'Bought by AI'
- AI Search Evaluation: The 12 Metrics — Gateway
- AI Search Evaluation ①Citation Rate — How Many URLs Are Pulled In Per Answer
- AI Search Evaluation ②Source Diversity — How Unskewed the Cited Sources Are
- AI Search Evaluation ③Accuracy Score — How Often It Answers Factual Questions Correctly
- AI Search Evaluation ④Answer Length — How Many Characters It Returns to the User on Average