Copilot CLIの/fleetで複数のエージェントを同時実行
GitHub Copilot CLIの新機能「/fleet」は、オーケストレーターがタスクを依存関係付きに分解し複数のサブエージェントを並列実行することで、複数ファイルへの同時作業を可能にする。
キーポイント
並列実行アーキテクチャ
オーケストレーターがタスクを依存関係付きの作業項目に分解し、独立したサブエージェントを並列dispatchして実行する仕組みを採用。
CLI統合と非同期モード
/fleetコマンドで対話的に使用可能。--no-ask-userフラグによりスクリプトやCI/CD環境での非対話実行にも対応。
プロンプト設計の最適化
具体的な成果物(ファイル、テストスイート等)を明示し依存関係を定義することで、オーケストレータの並列化効率を最大化する。
コンテキスト分離とファイル共有
サブエージェントは独立したコンテキストウィンドウを持つが、同じファイルシステムを共有し、直接通信はせずオーケストレーター経由で調整される。
影響分析・編集コメントを表示
影響分析
GitHub Copilot CLIへの並列エージェント機能の追加は、単なるコード補完を超え、複雑なリファクタリングやドキュメント更新などの大規模タスクを自動化する実用ツールへと進化させた。これにより、開発者は手動でファイルを跨ぐ作業を効率化でき、マルチエージェントオーケストレーションの概念がCLI環境へ本格普及する兆候を示している。
編集コメント
マルチエージェントの並列処理をCLIという軽量環境に実装した点は、開発者の日常ワークフローへの浸透度を高める重要な一歩である。ただし、複雑な依存関係がある大規模プロジェクトではプロンプトの設計品質が成果を左右するため、運用時の検証体制が求められる。
もしGitHub Copilot CLIが1つのファイルではなく、5つのファイルを同時に処理できたらどうでしょうか? それを実現するのが/fleetです。
/fleetはCopilot CLIのスラッシュコマンドで、Copilotが複数のサブエージェントを並列に同時動作させることを可能にします。タスクを逐次処理する代わりに、Copilotは背後で動作するオーケストレーターを持ち、あなたの目的を計画し、独立した作業項目に分解して、複数のエージェントに同時にディスパッチします。コードベースの異なるファイル、異なる部分で、すべてを一度に行うのです。
/fleetの仕組み、そしてより重要なその効果的な使い方をさらに知りたいですか? それでは始めましょう。
仕組み
プロンプトと共に/fleetを実行すると、背後で動作するオーケストレーターは以下の処理を行います:
- タスクを依存関係を含む個別の作業項目に分解する。
- 並列実行可能な項目と、待機が必要な項目を識別する。
- 独立した項目をバックグラウンドのサブエージェントとして同時にディスパッチする。
- 完了をポーリングし、次の作業群をディスパッチする。
- 出力を検証し、最終的な成果物を合成する。
各サブエージェントは独自のコンテキストウィンドウを持ちますが、同じファイルシステムを共有します。サブエージェント同士が直接会話することはなく、調整を行うのはオーケストレーターのみです。
プロジェクトリーダーがチームに作業を割り当て、進捗を確認し、最終成果物を組み立てるようなものとお考えください。
始め方
/fleet <あなたの目的プロンプト> を送信してフリートモードを開始します。例:
/fleet 認証モジュールをリファクタリングし、テストを更新し、フォルダdocs/auth/内の関連ドキュメントを修正する
これだけです。オーケストレーターはあなたの目的を受け取り、並列化できる部分を見極めて、ディスパッチを開始します。
ターミナルで非対話的に実行することもできます:
copilot -p "/fleet <あなたのタスク>" --no-ask-user
--no-ask-userフラグは非対話モードでは必須です。プロンプトに応答する手段がないためです。それでは、良いプロンプトの条件を見ていきましょう。
並列化しやすいプロンプトを書く
/fleetプロンプトの質は、作業の分散効率を決定します。鍵は、オーケストレーターがタスクを明確に分解できるだけの構造をプロンプトに与えることです。
効果的な方法の一つは、成果物を具体的に示すことです。全ての作業項目を、ファイル、テストスイート、ドキュメントのセクションといった具体的な成果物に対応させます。曖昧なプロンプトでは、オーケストレーターが独立した部分を識別できないため、逐次実行になってしまいます。
例えば、/fleet ドキュメントを構築する とする代わりに、以下のようにしてみてください:
/fleet APIモジュールのドキュメントを作成する:
- トークンフローと例を記載した docs/authentication.md
- 全RESTエンドポイントのリクエスト/レスポンススキーマを記載した docs/endpoints.md
- エラーコードとトラブルシューティング手順を記載した docs/errors.md
- 上記3ページへのリンクを記載した docs/index.md(他のファイルの完了に依存)
2番目のプロンプトでは、オーケストレーターに4つの明確な成果物が示され、そのうち3つは並列実行可能で、1つは他の成果物に依存しています。
明示的な境界を設定する
サブエージェントは、自身のスコープがどこから始まりどこで終わるかを正確に把握している時に最も効果的に動作します。プロンプトを作成する際には以下を含めましょう:
- ファイルまたはモジュールの境界:各トラックが担当するディレクトリやファイル
- 制約:変更を加えない部分(例:テスト変更なし、依存関係のアップグレードなし)
- 検証基準:合格が必須のリンター、型チェック、テスト
これらの境界を示すプロンプトの例:
/fleet 3つのトラックで機能フラグを実装する:
1. APIレイヤー:src/api/middleware/ にフラグ評価を追加し、フラグ評価の成功を確認する単体テストとAPIエンドポイントのテストを含める
2. UI:src/components/flags/ にトグルコンポーネントを配線し、新たな依存関係を導入しない
3. 設定:config/features.yaml にフラグ定義を追加し、スキーマに対して検証する
独立したトラックを並列で実行する。割り当てられたディレクトリ外は変更しない。
依存関係が存在する場合は宣言する
ある作業が別の作業に依存している場合は、それを明記してください。オーケストレーターはそれらの項目を直列化し、残りを並列化します。例:
/fleet データベースレイヤーを移行する:
1. migrations/005_users.sql に新しいスキーマを記述する
2. src/models/user.ts のORMモデルを更新する(1に依存)
3. src/api/users.ts のAPIハンドラーを更新する(2に依存)
4. tests/users.test.ts に統合テストを記述する(2に依存)
項目3と4は、項目2の完了後に並列実行可能。
異なる作業にカスタムエージェントを使用する
.github/agents/ に専門的なエージェントを定義し、/fleetプロンプト内で参照できます。各エージェントは独自のモデル、ツール、指示を指定できます。使用するモデルを指定しない場合、エージェントは現在のデフォルトモデルを使用する点に注意してください。
# .github/agents/technical-writer.md
---
name: technical-writer
description: ドキュメント専門家
model: claude-sonnet-4
tools: ["bash", "create", "edit", "view"]
---
あなたは明確で簡潔な技術ドキュメントを書きます。/docs/styleguide.md のプロジェクトスタイルガイドに従ってください。
その後、プロンプト内でこのカスタムエージェントを参照します:
/fleet すべてのドキュメントタスクには @technical-writer.md をエージェントとして使用し、コード変更にはデフォルトエージェントを使用する。
これは、複雑なロジックには高性能なモデルを、定型文的なドキュメント作成には軽量なモデルを使用するなど、異なるトラックが異なる特性を必要とする場合に便利です。
サブエージェントの展開を確認する方法
オーケストレーターがサブエージェントをどのように展開するかを観察することは、並列化しやすいプロンプトの書き方を学ぶ最速の方法です。
以下のクイックチェックリストを使用してください:
- 分解が表示される:作業開始前に、Copilotが共有する計画を確認し、単一の長い直列計画ではなく、複数のトラックに作業が分解されているか見る。
- バックグラウンドタスクUIが活動を確認する:作業開始後、
/tasksを実行してタスクダイアログを開き、実行中のバックグラウンドタスクを検査する。 - 並列進行が表示される:更新メッセージが、同時に進行している別々のトラックについて言及する。
フリートが並列化していないように見える場合は、Copilotの作業を停止し、明示的な分解を要求してみてください:
このタスクをまず独立したトラックに分解し、その後トラックを並列で実行せよ。各トラックのステータスとブロッカーを個別に報告せよ。
一般的な落とし穴を避ける
フリートは強力ですが、いくつかの注意点を知っておく価値があります。
ファイルを分割する
サブエージェントはファイルロックなしで同じファイルシステムを共有します。2つのエージェントが同じファイルに書き込む場合、最後に終了したものが「勝ち」ます。エラーもマージもなく、単純に上書きされます。
対策は、プロンプトで各エージェントに異なるファイルを割り当てることです。複数のエージェントが単一のファイルに貢献する必要がある場合は、各エージェントに一時パスに書き込ませ、最後にオーケストレーターがそれらをマージすることを検討するか、エージェントが従うべき明示的な順序を設定してください。
プロンプトを自己完結型に保つ
サブエージェントはオーケストレーターの会話履歴を見ることはできません。オーケストレーターがサブエージェントをディスパッチする際に渡すプロンプトには、サブエージェントが必要とするすべての情報を含める必要があります。セッションの早い段階で有用なコンテキストを既に収集している場合は、それを/fleetプロンプトに含めるか、サブエージェントが読み取れるファイルを参照させるようにしてください。
進行中のフリートを操縦する
ディスパッチ後も、フォローアッププロンプトを送信してオーケストレーターを導くことができます:
失敗しているテストを最優先し、残りのタスクを完了せよ。
アクティブなサブエージェントと、各々が現在行っていることをリストせよ。
リンター、型チェック、すべてのテストが合格したときのみ完了とマークせよ。
/fleetを使用するタイミング(と使用しないタイミング)
/fleetは、タスクに自然な並列性—複数のファイル、独立したモジュール、分離可能な関心事—があるときに真価を発揮します。特に効果的なのは以下の場合です:
- 複数のファイルを同時にリファクタリングする。
- 複数のコンポーネントのドキュメントを一度に生成する。
- API、UI、テストにまたがる機能を実装する。
- 状態を共有しない独立したコード変更を実行する。
厳密に線形的で単一ファイルの作業には、通常のCopilot CLIプロンプトの方がよりシンプルで、同等に高速です。フリートは調整のオーバーヘッドが生じるため、実際に分散可能な作業がある場合に効果を発揮します。
/fleetは、魔法のトリックではなく、チームのように扱うときに最も有用です。小さく始めましょう。明確な成果物、明確なファイル境界、明らかな並列性を持つタスクを選びます。オーケストレーターが作業をどのように分解するか、どこで役立ち、どこで足かせになるかを観察してください。より慣れてきたら、より大規模なリファクタリング、マルチトラック機能開発、ドキュメントとテストの並列実行などに挑戦してみてください。/fleetが効果を発揮するタイミングを学ぶ最速の方法は、実際の作業で試し、観察結果に基づいてプロンプトを調整することです。
この投稿「Copilot CLIの/fleetで複数のエージェントを同時に実行する」はThe GitHub Blogで最初に公開されました。
原文を表示
What if GitHub Copilot CLI could work on five files at the same time instead of one? That’s where /fleet comes in.
/fleet is a slash command in Copilot CLI that enables Copilot to simultaneously work with multiple subagents in parallel. Instead of working through tasks sequentially, Copilot now has a behind the scenes orchestrator that plans and breaks your objective into independent work items and dispatches multiple agents to execute them simultaneously. On different files, in different parts of your codebase, all at once.
Want to learn more about how /fleet works, and more importantly, how to use it most effectively? Let’s jump in.
How it works
When you run /fleet with a prompt, the behind-the-scenes orchestrator:
Decomposes your task into discrete work items with dependencies.
Identifies which items can run in parallel versus which must wait.
Dispatches independent items as background sub-agents simultaneously.
Polls for completion, then dispatches the next wave.
Verifies outputs and synthesizes any final artifacts.
Each sub-agent gets its own context window but shares the same filesystem. They can’t talk to each other directly; only the orchestrator coordinates.
Think of it as a project lead who assigns work to a team, checks in on progress, and assembles the final deliverable.
Getting started
Start fleet mode by sending /fleet <YOUR OBJECTIVE PROMPT>. For example:
/fleet Refactor the auth module, update tests, and fix the related docs in the folder docs/auth/
That’s it. The orchestrator takes your objective, figures out what can be parallelized, and starts dispatching.
You can also run it non-interactively in your terminal:
copilot -p "/fleet <YOUR TASK>" --no-ask-user
The --no-ask-user flag is required for non-interactive mode, since there’s no way to respond to prompts. Now let’s look at what makes a good prompt.
Write prompts that parallelize well
The quality of your /fleet prompt determines how effectively work gets distributed. The key is giving the orchestrator enough structure to cleanly break down your task.
A good way to do that is being specific about deliverables. Map every work item to a concrete artifact like a file, a test suite, or a section of documentation. Vague prompts lead to sequential execution because the orchestrator can’t identify independent pieces.
For example, instead of: /fleet Build the documentation, you could try:
/fleet Create docs for the API module:
- docs/authentication.md covering token flow and examples
- docs/endpoints.md with request/response schemas for all REST endpoints
- docs/errors.md with error codes and troubleshooting steps
- docs/index.md linking to all three pages (depends on the others finishing first)
The second prompt gives the orchestrator four distinct deliverables, three of which can run in parallel, and one that depends on them.
Set explicit boundaries
Sub-agents work best when they know exactly where their scope starts and ends. When writing your prompt include:
File or module boundaries: Which directories or files each track owns
Constraints: What not to touch (e.g., no test changes, no dependency upgrades)
Validation criteria: Lint, type checks, tests that must pass
Here’s a prompt that showcases these boundaries:
/fleet Implement feature flags in three tracks:
- API layer: add flag evaluation to src/api/middleware/ and include unit tests that look for successful flag evaluation and tests API endpoints
- UI: wire toggle components in src/components/flags/ and introduce no new dependencies
- Config: add flag definitions to config/features.yaml and validate against schema
Run independent tracks in parallel. No changes outside assigned directories.
Declare dependencies when they exist
If one piece of work depends on another, say so. The orchestrator will serialize those items and parallelize the rest. For example:
/fleet Migrate the database layer:
- Write new schema in migrations/005_users.sql
- Update the ORM models in src/models/user.ts (depends on 1)
- Update API handlers in src/api/users.ts (depends on 2)
- Write integration tests in tests/users.test.ts (depends on 2)
Items 3 and 4 can run in parallel after item 2 completes.
Use custom agents for different jobs
You can define specialized agents in .github/agents/ and reference them in your /fleet prompt. Each agent can specify its own model, tools, and instructions. Be aware that if you don’t specify which model to use, agents will use the current default model.
.github/agents/technical-writer.md
name: technical-writer
description: Documentation specialist
model: claude-sonnet-4
tools: ["bash", "create", "edit", "view"]
You write clear, concise technical documentation. Follow the project style guide in /docs/styleguide.md.
Then reference the custom agent in your prompt:
/fleet Use @technical-writer.md as the agent for all docs tasks and the default agent for code changes.
This is useful when different tracks need different strengths such as using a heavier model for complex logic and a lighter one for boilerplate documentation.
How to verify subagents are deploying
Watch how the orchestrator deploys subagents, it’s the fastest way to learn how to write prompts that parallelize well.
Use this quick checklist:
Decomposition appears: Before it starts working, review the plan Copilot shares with you to see if it breaks work into multiple tracks, instead of one long linear plan.
Background task UI confirms activity: Once it begins working, run /tasks to open the tasks dialog and inspect running background tasks.
Parallel progress appears: Updates reference separate tracks moving at the same time.
If the fleet doesn’t seem to be parallelizing, try stopping Copilot’s work and asking for an explicit decomposition:
Decompose this into independent tracks first, then execute tracks in parallel. Report each track separately with status and blockers.
Avoiding common pitfalls
Fleet is powerful, but a few gotchas are worth knowing upfront.
Partition your files
Sub-agents share a filesystem with no file locking. If two agents write to the same file, the last one to finish wins—silently. No error, no merge, just an overwrite.
The fix is to assign each agent distinct files in your prompt. If multiple agents need to contribute to a single file, consider having each write to a temporary path and let the orchestrator merge them at the end. Or set an explicit order for the agents to follow.
Keep prompts self-contained
Sub-agents can’t see the orchestrator’s conversation history. When the orchestrator dispatches a sub-agent, it passes along a prompt, but that prompt needs to include everything the sub-agent needs. If you’ve already gathered useful context earlier in the session, make sure your /fleet prompt includes it (or references files the sub-agents can read).
Steering a fleet in progress
After dispatching, you can send follow-up prompts to guide the orchestrator:
Prioritize failing tests first, then complete remaining tasks.
List active sub-agents and what each is currently doing.
Mark done only when lint, type check, and all tests pass.
When to use /fleet (and when not to)
/fleet shines when your task has natural parallelism—multiple files, independent modules, or separable concerns. It’s particularly effective for:
Refactoring across multiple files simultaneously.
Generating documentation for several components at once.
Implementing a feature that spans API, UI, and tests.
Running independent code modifications that don’t share state.
For strictly linear, single-file work, regular Copilot CLI prompts are simpler and just as fast. Fleet adds coordination overhead, so it pays off when there’s real work to distribute.
/fleet is most useful when you treat it like a team, not a magic trick. Start small. Pick a task with clear outputs, clean file boundaries, and obvious parallelism. See how the orchestrator decomposes the work, where it helps, and where it gets in the way. As you get more comfortable, push it further with larger refactors, multi‑track features, or docs and tests in parallel. The fastest way to learn when /fleet pays off is to try it on real work and adjust your prompts based on what you see.
The post Run multiple agents at once with /fleet in Copilot CLI appeared first on The GitHub Blog.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み