jpskill.com
🛠️ 開発・MCP コミュニティ

parallel-execution

Patterns for parallel subagent execution using Task tool with run_in_background. Use when coordinating multiple independent tasks, spawning dynamic subagents, or implementing features that can be parallelized.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o parallel-execution.zip https://jpskill.com/download/17947.zip && unzip -o parallel-execution.zip && rm parallel-execution.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17947.zip -OutFile "$d\parallel-execution.zip"; Expand-Archive "$d\parallel-execution.zip" -DestinationPath $d -Force; ri "$d\parallel-execution.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して parallel-execution.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → parallel-execution フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

並列実行パターン

コアコンセプト

並列実行では、run_in_background: true を指定した Task ツールを使用して、複数のサブエージェントを同時に生成します。これにより、N 個のタスクを並行して実行でき、合計実行時間を大幅に短縮できます。

重要なルール: 真の並列処理を実現するには、すべての Task 呼び出しが単一のアシスタントメッセージ内にある必要があります。Task 呼び出しが別々のメッセージにある場合、それらは順番に実行されます。

実行プロトコル

ステップ 1: 並列化可能なタスクの特定

タスクを生成する前に、タスクが独立していることを確認します。

  • あるタスクが別のタスクの出力に依存していない
  • タスクが異なるファイルまたは関心事を対象としている
  • 競合することなく同時に実行できる

ステップ 2: 動的なサブエージェントプロンプトの準備

各サブエージェントは、その役割を定義するカスタムプロンプトを受け取ります。

You are a [ROLE] specialist for this specific task.

Task: [CLEAR DESCRIPTION]

Context:
[RELEVANT CONTEXT ABOUT THE CODEBASE/PROJECT]

Files to work with:
[SPECIFIC FILES OR PATTERNS]

Output format:
[EXPECTED OUTPUT STRUCTURE]

Focus areas:
- [PRIORITY 1]
- [PRIORITY 2]

ステップ 3: すべてのタスクを 1 つのメッセージで起動

重要: すべての Task 呼び出しを同じアシスタントメッセージで行います。

I'm launching N parallel subagents:

[Task 1]
description: "Subagent A - [brief purpose]"
prompt: "[detailed instructions for subagent A]"
run_in_background: true

[Task 2]
description: "Subagent B - [brief purpose]"
prompt: "[detailed instructions for subagent B]"
run_in_background: true

[Task 3]
description: "Subagent C - [brief purpose]"
prompt: "[detailed instructions for subagent C]"
run_in_background: true

ステップ 4: TaskOutput で結果を取得

起動後、各結果を取得します。

[Wait for completion, then retrieve]

TaskOutput: task_1_id
TaskOutput: task_2_id
TaskOutput: task_3_id

ステップ 5: 結果の統合

すべてのサブエージェントの出力を統合された結果に結合します。

  • 関連する調査結果をマージする
  • 推奨事項間の競合を解決する
  • 重大度/重要度で優先順位を付ける
  • 実行可能な概要を作成する

動的なサブエージェントパターン

パターン 1: タスクベースの並列化

実装する N 個のタスクがある場合は、N 個のサブエージェントを生成します。

Plan:
1. Implement auth module
2. Create API endpoints
3. Add database schema
4. Write unit tests
5. Update documentation

Spawn 5 subagents (one per task):
- Subagent 1: Implements auth module
- Subagent 2: Creates API endpoints
- Subagent 3: Adds database schema
- Subagent 4: Writes unit tests
- Subagent 5: Updates documentation

パターン 2: ディレクトリベースの並列化

複数のディレクトリを同時に分析します。

Directories: src/auth, src/api, src/db

Spawn 3 subagents:
- Subagent 1: Analyzes src/auth
- Subagent 2: Analyzes src/api
- Subagent 3: Analyzes src/db

パターン 3: 視点ベースの並列化

複数の視点から同時にレビューします。

Perspectives: Security, Performance, Testing, Architecture

Spawn 4 subagents:
- Subagent 1: Security review
- Subagent 2: Performance analysis
- Subagent 3: Test coverage review
- Subagent 4: Architecture assessment

TodoWrite の統合

並列実行を使用する場合、TodoWrite の動作は異なります。

逐次実行: 一度に 1 つのタスクのみが in_progress になります。 並列実行: 複数のタスクが同時に in_progress になる可能性があります。

# Before launching parallel tasks
todos = [
  { content: "Task A", status: "in_progress" },
  { content: "Task B", status: "in_progress" },
  { content: "Task C", status: "in_progress" },
  { content: "Synthesize results", status: "pending" }
]

# After each TaskOutput retrieval, mark as completed
todos = [
  { content: "Task A", status: "completed" },
  { content: "Task B", status: "completed" },
  { content: "Task C", status: "completed" },
  { content: "Synthesize results", status: "in_progress" }
]

並列実行を使用するタイミング

適切な候補:

  • 複数の独立した分析 (コードレビュー、セキュリティ、テスト)
  • ファイルが独立している複数ファイルの処理
  • さまざまな視点からの探索的タスク
  • さまざまなチェックによる検証タスク
  • 独立したコンポーネントによる機能実装

並列化を避ける場合:

  • タスクに依存関係がある場合 (Task B は Task A の出力を必要とする)
  • 順次ワークフローが必要な場合 (commit -> push -> PR)
  • タスクが同じファイルを変更する場合 (競合のリスク)
  • 正確さのために順序が重要な場合

パフォーマンス上の利点

アプローチ 5 Tasks @ 30s each Total Time
Sequential 30s + 30s + 30s + 30s + 30s ~150s
Parallel All 5 run simultaneously ~30s

並列実行は、N が独立したタスクの数である場合、約 Nx 倍高速です。

例: 機能実装

ユーザーリクエスト: 「ログイン、登録、パスワードリセットによるユーザー認証を実装する」

オーケストレーターが計画を作成:

  1. ログインエンドポイントを実装する
  2. 登録エンドポイントを実装する
  3. パスワードリセットエンドポイントを実装する
  4. 認証ミドルウェアを追加する
  5. 統合テストを作成する

並列実行:

Launching 5 subagents in parallel:

[Task 1] Login endpoint implementation
[Task 2] Registration endpoint implementation
[Task 3] Password reset endpoint implementation
[Task 4] Auth middleware implementation
[Task 5] Integration test writing

All tasks run simultaneously...

[Collect results via TaskOutput]

[Synthesize into cohesive implementation]

トラブルシューティング

タスクが順番に実行される場合

  • すべての Task 呼び出しが単一のメッセージにあることを確認する
  • 各タスクに run_in_background: true が設定されていることを確認する

結果が利用できない場合

  • 正しいタスク ID で TaskOutput を使用する
  • 取得する前にタスクが完了するのを待つ

出力に競合がある場合

  • タスクが同じファイルを変更しないようにする
  • 統合ステップで競合解決を追加する
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Parallel Execution Patterns

Core Concept

Parallel execution spawns multiple subagents simultaneously using the Task tool with run_in_background: true. This enables N tasks to run concurrently, dramatically reducing total execution time.

Critical Rule: ALL Task calls MUST be in a SINGLE assistant message for true parallelism. If Task calls are in separate messages, they run sequentially.

Execution Protocol

Step 1: Identify Parallelizable Tasks

Before spawning, verify tasks are independent:

  • No task depends on another's output
  • Tasks target different files or concerns
  • Can run simultaneously without conflicts

Step 2: Prepare Dynamic Subagent Prompts

Each subagent receives a custom prompt defining its role:

You are a [ROLE] specialist for this specific task.

Task: [CLEAR DESCRIPTION]

Context:
[RELEVANT CONTEXT ABOUT THE CODEBASE/PROJECT]

Files to work with:
[SPECIFIC FILES OR PATTERNS]

Output format:
[EXPECTED OUTPUT STRUCTURE]

Focus areas:
- [PRIORITY 1]
- [PRIORITY 2]

Step 3: Launch All Tasks in ONE Message

CRITICAL: Make ALL Task calls in the SAME assistant message:

I'm launching N parallel subagents:

[Task 1]
description: "Subagent A - [brief purpose]"
prompt: "[detailed instructions for subagent A]"
run_in_background: true

[Task 2]
description: "Subagent B - [brief purpose]"
prompt: "[detailed instructions for subagent B]"
run_in_background: true

[Task 3]
description: "Subagent C - [brief purpose]"
prompt: "[detailed instructions for subagent C]"
run_in_background: true

Step 4: Retrieve Results with TaskOutput

After launching, retrieve each result:

[Wait for completion, then retrieve]

TaskOutput: task_1_id
TaskOutput: task_2_id
TaskOutput: task_3_id

Step 5: Synthesize Results

Combine all subagent outputs into unified result:

  • Merge related findings
  • Resolve conflicts between recommendations
  • Prioritize by severity/importance
  • Create actionable summary

Dynamic Subagent Patterns

Pattern 1: Task-Based Parallelization

When you have N tasks to implement, spawn N subagents:

Plan:
1. Implement auth module
2. Create API endpoints
3. Add database schema
4. Write unit tests
5. Update documentation

Spawn 5 subagents (one per task):
- Subagent 1: Implements auth module
- Subagent 2: Creates API endpoints
- Subagent 3: Adds database schema
- Subagent 4: Writes unit tests
- Subagent 5: Updates documentation

Pattern 2: Directory-Based Parallelization

Analyze multiple directories simultaneously:

Directories: src/auth, src/api, src/db

Spawn 3 subagents:
- Subagent 1: Analyzes src/auth
- Subagent 2: Analyzes src/api
- Subagent 3: Analyzes src/db

Pattern 3: Perspective-Based Parallelization

Review from multiple angles simultaneously:

Perspectives: Security, Performance, Testing, Architecture

Spawn 4 subagents:
- Subagent 1: Security review
- Subagent 2: Performance analysis
- Subagent 3: Test coverage review
- Subagent 4: Architecture assessment

TodoWrite Integration

When using parallel execution, TodoWrite behavior differs:

Sequential execution: Only ONE task in_progress at a time Parallel execution: MULTIPLE tasks can be in_progress simultaneously

# Before launching parallel tasks
todos = [
  { content: "Task A", status: "in_progress" },
  { content: "Task B", status: "in_progress" },
  { content: "Task C", status: "in_progress" },
  { content: "Synthesize results", status: "pending" }
]

# After each TaskOutput retrieval, mark as completed
todos = [
  { content: "Task A", status: "completed" },
  { content: "Task B", status: "completed" },
  { content: "Task C", status: "completed" },
  { content: "Synthesize results", status: "in_progress" }
]

When to Use Parallel Execution

Good candidates:

  • Multiple independent analyses (code review, security, tests)
  • Multi-file processing where files are independent
  • Exploratory tasks with different perspectives
  • Verification tasks with different checks
  • Feature implementation with independent components

Avoid parallelization when:

  • Tasks have dependencies (Task B needs Task A's output)
  • Sequential workflows are required (commit -> push -> PR)
  • Tasks modify the same files (risk of conflicts)
  • Order matters for correctness

Performance Benefits

Approach 5 Tasks @ 30s each Total Time
Sequential 30s + 30s + 30s + 30s + 30s ~150s
Parallel All 5 run simultaneously ~30s

Parallel execution is approximately Nx faster where N is the number of independent tasks.

Example: Feature Implementation

User request: "Implement user authentication with login, registration, and password reset"

Orchestrator creates plan:

  1. Implement login endpoint
  2. Implement registration endpoint
  3. Implement password reset endpoint
  4. Add authentication middleware
  5. Write integration tests

Parallel execution:

Launching 5 subagents in parallel:

[Task 1] Login endpoint implementation
[Task 2] Registration endpoint implementation
[Task 3] Password reset endpoint implementation
[Task 4] Auth middleware implementation
[Task 5] Integration test writing

All tasks run simultaneously...

[Collect results via TaskOutput]

[Synthesize into cohesive implementation]

Troubleshooting

Tasks running sequentially?

  • Verify ALL Task calls are in SINGLE message
  • Check run_in_background: true is set for each

Results not available?

  • Use TaskOutput with correct task IDs
  • Wait for tasks to complete before retrieving

Conflicts in output?

  • Ensure tasks don't modify same files
  • Add conflict resolution in synthesis step