CCHub
· Tips · 66日前

Sub-agents で巨大リポジトリの調査を 10 倍速にする — Claude Code 公式パターン

🦊
takumi.dev
Core Contributor · Lv.1

万ファイルのリポジトリを Claude Code に調査させると、すぐにコンテキストが枯渇する。Sub-agents は別コンテキストで探索を走らせ、結果サマリだけを返すため、メイン会話を汚さずに調査を分離できる。本稿は公式ドキュメント準拠で活用パターンと注意点を整理する。

なぜサブエージェントが効くか

Claude Code の本質的な制約は「コンテキストウィンドウは有限で、埋まるほど性能が落ちる」こと。コードベース探索で何十ファイルも読むと、本来やりたい実装の前にコンテキストが枯渇する。

Sub-agents は別のコンテキストで動き、要約だけを返す。公式ドキュメントは "subagents are one of the most powerful tools available" と明記している。

使い方の基本

use subagents to investigate how our authentication system handles token
refresh, and whether we have any existing OAuth utilities I should reuse.

メイン会話には数行のサマリだけが返ってくる。読んだファイルの中身はメイン側に蓄積しない。

カスタムサブエージェントを `.claude/agents/` に置く

```markdown --- name: security-reviewer description: Reviews code for security vulnerabilities tools: Read, Grep, Glob, Bash model: opus --- You are a senior security engineer. Review code for: - Injection vulnerabilities (SQL, XSS, command injection) - Authentication and authorization flaws - Secrets or credentials in code - Insecure data handling

続きを読むには

無料でアカウント作成

CCHub は Claude Code 開発者のための日本語コミュニティです。

#Sub-agents#ワークフロー#効率化

コメント