アイデアからプルリクエストへ:GitHub Copilot CLIで構築する実践ガイド
GitHubはターミナル上で自然言語による意図からプルリクエスト作成までを支援するCopilot CLIの実践的なワークフローと、ユーザーが最終決定権を持つ安全な運用原則を解説している。
キーポイント
Copilot CLIの定義と役割
ターミナル内で動作するGitHub対応のコーディングエージェントであり、自然言語での指示から計画立案(/plan)、ファイル生成、テスト作成までを支援するが、変更の適用にはユーザーの明示的な承認が必要。
意図ベースの開発ワークフロー
フレームワークの選択やテンプレートのコピーから始めるのではなく、空のディレクトリで「何を作りたいか」という意図(intent)を最初に記述し、AIが提案するスタックやコマンドを人間が検証・選択するプロセスを推奨。
GitHub Skillsによる実践的学習
Copilot CLIの使用方法を安全に習得するためのガイド付き演習(Skills exercise)を提供しており、Codespaces環境でNode.jsアプリの構築からテスト、PR作成までの一連の流れを体験できる。
人間の監督と制御の維持
AIは silently コマンドを実行したり、変更を適用したりせず、設計作業やレビューの必要性を排除するものではなく、最終的な実行と変更内容の決定権は常に開発者が持つことを明確にしている。
所有可能な範囲でのスケフォールディング
Copilot CLIはプロジェクト構造の提案を行うが、最終的な所有権と責任は開発者が持つ。出力はチームメイトからのコードとしてレビューし、編集または破棄する必要がある。
失敗地点での反復と検証
テスト実行、失敗原因の質問、差分表示による修正提案というサイクルをCLI内で完結させることで、抽象的なプロンプトではなく実際の出力に基づいた grounded な開発が可能になる。
CLIとIDEの使い分け
CLIは低儀式で計画立案や機械的な変更、迅速な実装に使い、IDEはエッジケースの検討やAPI設計など精度と判断が必要な段階で使用する。
影響分析・編集コメントを表示
影響分析
この記事は、AIコーディングアシスタントが「コード生成ツール」から「対話型開発パートナー」へと進化している現状を示しています。特に、ターミナルという開発者の主要作業空間に深く統合されつつある点は、開発体験(DX)の重要な転換点と言えます。また、「人間の監督」を強調することで、企業現場での採用障壁を下げるための信頼性確保策を示しており、実務への導入を後押しする内容となっています。
編集コメント
GitHub Blogの公式アナウンスであり、プレスリリース色の強いコンテンツであるため、革新性や実用性の評価には慎重な減点を適用しました。ただし、開発現場での実際の運用パターンを具体的に示している点は評価できます。
ほとんどの開発者は、実際の作業をターミナル上で行っています。
そこでプロジェクトの初期化を行い、テストを実行し、CI の失敗をデバッグし、レビューに耐えうる状態になる前に迅速で機械的な変更を加えます。GitHub Copilot CLI は、この現実に合わせて、ターミナル内で意図から直接レビュー可能な差分へ移行し、その作業をエディタやプルリクエストへと引き継ぐことを支援します。
本ブログでは、新しい GitHub Skills 演習に基づき、Copilot CLI を用いてアプリケーションを作成・進化させるための実践的なワークフローを紹介しています。Skills 演習はガイド付きの実践 walkthrough を提供しますが、本記事では各ステップがなぜ機能するのか、そして実際のプロジェクトでいつ使用すべきかに焦点を当てます。
GitHub Skills 演習でさらに深く掘り下げる
このワークフローの完全なガイド版(実践練習を含む)をお探しの場合は、「Copilot CLI でアプリケーションを作成する」という GitHub Skills 演習をご覧ください。
これは、事前に設定された GitHub Codespaces のインスタンス内で、これらのパターンを段階的に walkthrough します。本番環境のコードに適用する前に安全に実験するための良い方法です。この演習では以下の内容を取り扱います:
- Copilot CLI をインストールし、issue テンプレートを使用して issue を作成する
- Node.js CLI カルculator アプリを生成する
-追加の演算子で計算機能の拡張を行う
- 計算関数のためのユニットテストを書く
- プルリクエストを作成・レビュー・マージする
Copilot CLI とは何か(そして何ではないか)
Copilot CLI は、ターミナル内で動作する GitHub 対応のコーディングエージェントです。自然言語で何を望むかを記述し、コードに触れる前に /plan コマンドを使って作業の見通しを立てたり、実行前に具体的なコマンドや差分を確認したりできます。Copilot は内部で推論を行うこともありますが、明示的な承認がない限り、コマンドを実行したり変更を適用したりすることはありません。
実際には、Copilot CLI は以下のような支援を行います:
あなたの意図に基づいて問題を探索する
/plan(または Shift + Tab を押してプランニングモードに入る)を使用して構造化された計画を提案するか、確認可能な具体的なコマンドや差分を提示する
ファイルの生成または修正を行う
発生した失敗の原因を説明する
Copilot CLI が行わないこと:
あなたの承認なしにコマンドを黙って実行したり変更を適用したりすること
慎重な設計作業を代替すること
レビューの必要性を排除すること
実行されるもの、変更されるもの、そしてリリースされるもののコントロールは常にあなたが握っています。
ステップ 1: スキャフォールディングではなく意図から始める
フレームワークを選択したりテンプレートをコピーしたりすることから始めず、まず構築したいものを明確に述べることから始めましょう。
空のディレクトリから以下を実行します:
copilot
Create a small web service with a single JSON endpoint and basic tests
インタラクティブモードに入る代わりに、単一のプロンプトで提案を生成したい場合は、以下のように実行することもできます:
copilot -p "Create a small web service with a single JSON endpoint and basic tests"
スキル演習では、このパターンが繰り返し使用されます:まず意図を記述し、次に実際に実行したいと考える提案されたコマンドを選択します。
この段階では、Copilot CLI は問題領域の探索を行っています。以下のようなことが可能です:
スタックの提案
ファイルのアウトライン作成
セットアップコマンドの提案
何かが自動的に実行されることはありません。実行するかどうかを決定する前に、すべてを検証します。これにより、設計にコミットする前に実験を行うのに CLI が適した場所となります。
ステップ 2: 自分が責任を持てる範囲のみをスケフォールドする
あなたが納得できる方向性が見えたら、Copilot CLI にスケフォールドの支援を依頼してください:
テストランナーと README を含む最小限の Node.js プロジェクトとしてこれをスケフォールドしてください
ここで Copilot CLI が最も即座に役立ちます。以下が可能になります:
ディレクトリと設定ファイルの作成
基本的なプロジェクト構造の接続
手動で入力またはコピーする必要があるボイラープレートコードの生成
Copilot CLI はプロジェクト構造を「所有」するわけではありません。一般的な慣習に基づいてスケフォールドを提案しますが、これは処方箋ではなく、出発点として扱うべきです。
重要な制約は、常に結果に対する責任があなたにあるということです。出力はチームメイトからのコードのように扱い、レビューし、編集するか、あるいは却下してください。
ステップ 3: 失敗の地点で反復する
Copilot CLI の内部で直接テストを実行します:
すべてのテストを実行し、パスすることを確認してください
何かが失敗した場合、同じセッション内でその具体的な失敗について Copilot に問い合わせてください:
なぜこれらのテストは失敗しているのですか?
説明ではなく具体的な提案を望む場合は、以下を試してください:
このテストの失敗を修正し、差分を表示してください
このパターン(! コマンドの実行、検証、質問、差分の確認)により、エージェントが抽象的なプロンプトではなく、実際の出力に基づいて動作することが保証されます。
💡 プロのヒント:実際には、理解を得たい場合は「explain」コマンドが有用ですが、レビュー可能な具体的な提案が必要であれば「suggest」コマンドの方が適しています。Copilot CLI のスラッシュコマンドの詳細については、当社のガイドをご覧ください。
ステップ 4: 機械的またはリポジトリ全体の修正を行う
Copilot CLI は、説明は容易だが実行が面倒な変更にも非常に適しています:
リポジトリ内の X のすべてのインスタンスを Y にリネームし、テストを更新する
これらの変更は機械的で範囲が限定されているため、レビューもロールバックも容易です。CLI は生成されたテキストの壁ではなく、具体的な差分(diff)を提供します。
ステップ 5: コードの形状を作り始める必要がある場合はエディタへ移行する
最終的には、速度よりも正確性が重要になります。
これは、エディタや IDE に自然に引き継ぐポイントです。ここで以下が可能になります:
- エッジケースについて推論する
- API を洗練させる
- デザイン上の判断を下す
Copilot はここでも機能しますが、重要な点はなぜ環境を切り替えるのかという理由です。CLI は素早く実用的な成果物に到達するのに役立ちます。一方、IDE ではコードを望む通りの形に仕上げる作業が行われます。
良い目安となるルール:
- CLI: /plan を使用し、/diff で差分を生成して、儀式のような手順を省いて迅速に進める
- IDE: ロジックの洗練や、レビューで説明責任が求められる判断を下す必要がある場合に /IDE を使用する
- GitHub: コミットを行い、/delegate コマンドを使ってプルリクエスト(pull request)を開き、非同期で協力する
ステップ 6: GitHub でリリースする
変更が良好に見えるようになったら、コミットしてプルリクエストを開きます。これは自然言語を通じて Copilot CLI を使って行うことができます:
適用可能な説明的メッセージを付けてすべてのファイルをステージングし、コミットして変更点をプッシュしてください。
プルリクエストを作成し、Copilot をレビュアーとして追加してください。
これで作業が持続可能になります:
チームメンバーによるレビューが可能に
CI でのテスト実行が可能に
非同期での反復開発の準備が整う
こここそが Copilot の価値が単なる一つの機能ではなく、リリースに至るフローの一部として複合的に高まる瞬間です。このスキル演習は意図的にここで終わります。なぜなら、Copilot の真価が発揮されるのは、コミット、プルリクエスト、レビューというプロセスにおいてであり(単なる提案にとどまらない)からです。
一つのワークフロー、三つの局面
Copilot を理解するための有益なメンタルモデルは以下の通りです:
CLI: 低コストで迅速に価値を実証
IDE: コードの構成と洗練
GitHub: レビュー、共同作業、リリース
Copilot CLI が強力である理由はまさに、このシステムを置き換えるのではなく、その一部として組み込まれている点にあります。
Copilot で構築する際の注意:Copilot SDK について
開発者向けツールや内部システム、あるいはエージェント実行自体が製品の一部となる(単にターミナルで実行するだけのものではない)アプリケーションを開発している場合、現在技術プレビュー版である GitHub Copilot SDK を検討されることをお勧めします。
Copilot SDK を使用すれば、独自のオーケストレーション層を構築・維持する必要なく、Copilot CLI の基盤となる計画および実行エンジンへのプログラムによるアクセスが可能になります。プランナー、ツール、回復ロジックを手動で接続する代わりに、エージェントの動作を定義するだけでよく、Copilot が実行を担当します。
Copilot CLI は、自分のワークフロー内で高速かつ対話的な実行を望む場合に使用します。一方、Copilot SDK は、これらのエージェント機能をアプリケーション内部に埋め込みたい場合に使用します。SDK は Copilot CLI の背後にある実行エンジンを公開していますが、リポジトリスコープのメモリや委任されたプルリクエストワークフローといった GitHub 固有の機能は含まれません。
Copilot SDK を探索する >
このガイドから持ち帰るべきこと
Copilot CLI は、判断力を代替するものではなく、推進力のためのツールとして扱う場合に最も有用です。
適切に使用すれば、意図を具体的な変更へと迅速に変換するのに役立ちます:アイデアの探求、プロジェクトのスケーフォールディング、障害の診断、そしてターミナル内で直接機械的な作業の処理などです。精度が求められる場合はエディタに移行し、作業が共有の準備ができたら、それは GitHub 上でプルリクエストとして提出されます。レビュー可能で、テスト可能で、出荷可能な状態となります。
このフローは、単一のコマンドよりも重要です。
このガイドから得られるべき最も重要な教訓はこれです:Copilot は、開発者がすでにソフトウェアを構築している方法に自然に適合するときに最もよく機能します。CLI で始めてつまずきを解消したり素早く進んだりし、IDE で慎重になって判断を下せるようにし、GitHub に頼って作業の耐久性を確保してください。
GitHub Copilot CLI の利用を開始するか、スキルコースを受講する >
「アイデアからプルリクエストへ:GitHub Copilot CLI を活用した実践的ガイド」の記事は、The GitHub Blog で最初に公開されました。
原文を表示
Most developers already do real work in the terminal.
We initialize projects there, run tests there, debug CI failures there, and make fast, mechanical changes there before anything is ready for review. GitHub Copilot CLI fits into that reality by helping you move from intent to reviewable diffs directly in your terminal—and then carry that work into your editor or pull request.
This blog walks through a practical workflow for using Copilot CLI to create and evolve an application, based on a new GitHub Skills exercise. The Skills exercise provides a guided, hands-on walkthrough; this post focuses on why each step works and when to use it in real projects.
Go deeper with the GitHub Skills exercise
If you want a fully guided version of this workflow, including hands-on practice, check out the GitHub Skills exercise Create applications with the Copilot CLI.
It walks through these patterns step by step in a preconfigured instance of GitHub Codespaces and is a good way to experiment safely before applying them to production code. The exercise covers the following:
Install the Copilot CLI and use the issue template to create an issue
Generate a Node.js CLI calculator app
Expand calculator functionality with additional operations
Write unit tests for calculator functions
Create, review, and merge your pull request
What Copilot CLI is (and is not)
Copilot CLI is a GitHub-aware coding agent in your terminal. You can describe what you want in natural language, use /plan to outline the work before touching code, and then review concrete commands or diffs before anything runs. Copilot may reason internally, but it only executes commands or applies changes after you explicitly approve them.
In practice, Copilot CLI helps you:
Explore a problem based on your intent
Propose structured plans using /plan (or you can hit Shift + Tab to enter planning mode), or suggest concrete commands and diffs you can review
Generate or modify files
Explain failures where they occur
What it does not do:
Silently run commands or apply changes without your approval
Replace careful design work
Eliminate the need for review
You stay in control of what runs, what changes, and what ships.
Step 1: Start with intent, not scaffolding
Instead of starting by choosing a framework or copying a template, start by stating what you want to build.
From an empty directory, run:
copilot
Create a small web service with a single JSON endpoint and basic tests
If you want to generate a proposal in a single prompt instead of entering interactive mode, you can also run:
copilot -p "Create a small web service with a single JSON endpoint and basic tests"
In the Skills exercise, this pattern is used repeatedly: describe intent first, then decide which suggested commands you actually want to run.
At this stage, Copilot CLI is exploring the problem space. It may:
Suggest a stack
Outline files
Propose setup commands
Nothing runs automatically. You inspect everything before deciding what to execute. This makes the CLI a good place to experiment before committing to a design.
Step 2: Scaffold only what you’re ready to own
Once you see a direction you’re comfortable with, ask Copilot CLI to help scaffold:
Scaffold this as a minimal Node.js project with a test runner and README
This is where Copilot CLI is most immediately useful. It can:
Create directories and config,
Wire basic project structure,
Generate boilerplate you would otherwise type or copy by hand.
Copilot CLI does not “own” the project structure. It suggests scaffolding based on common conventions, which you should treat as a starting point, not a prescription.
The important constraint is that you’re always responsible for the result. Treat the output like code from a teammate: review it, edit it, or discard it.
Step 3: Iterate at the point of failure
Run your tests directly inside Copilot CLI:
Run all my tests and make sure they pass
When something fails, ask Copilot about that exact failure in the same session:
Why are these tests failing?
If you want a concrete proposal instead of an explanation, try:
Fix this test failure and show the diff
This pattern—run (!command), inspect, ask, review diff—keeps the agent grounded in real output instead of abstract prompts.
Pro tip: In practice, explain is useful when you want understanding, while suggest is better when you want a concrete proposal you can review. Learn more about slash commands in Copilot CLI in our guide.
Step 4: Make mechanical or repo-wide changes
Copilot CLI is also well suited to changes that are easy to describe but tedious to execute:
Rename all instances of X to Y across the repository and update tests
Because these changes are mechanical and scoped, they’re easy to review and easy to roll back. The CLI gives you a concrete diff instead of a wall of generated text.
Step 5: Move into your editor when you need to start shaping your code
Eventually, speed matters less than precision.
This is the natural handoff point to your editor or IDE, so it can:
Reason about edge cases
Refine APIs
Make design decisions
Copilot works there too, but the key point is why you switch environments. The CLI helps you quickly get to something real. The IDE is where you can shape your code into exactly what you want.
A good rule of thumb:
CLI: use /plan, generate a /diff, and move quickly with low ceremony
IDE: use /IDE when you need to refine logic and make decisions you’ll defend in review
GitHub: commit, open a pull request with the command /delegate, and collaborate asynchronously
Step 6: Ship on GitHub
Once the changes look good, commit and open a pull request which you can do through the Copilot CLI in natural language:
Add and commit all files with a applicable descriptive messages, push the changes.
Create a pull request and add Copilot as a reviewer
Now the work becomes durable:
Reviewable by teammates
Testable in CI
Ready for async iteration
This is where Copilot’s value compounds as part of a flow that ends with shipping versus just being a single surface. The Skills exercise intentionally ends here, because this is where Copilot’s value becomes durable: in commits, pull requests, and review (not just suggestions).
One workflow, three moments
A helpful mental model for Copilot looks like this:
CLI: prove value quickly with low ceremony
IDE: shape and refine your code
GitHub: review, collaborate, and ship
Copilot CLI is powerful precisely because it fits into this system instead of trying to replace it.
Building with Copilot? A note on the Copilot SDK
If you’re building a developer tool, internal system, or application where agentic execution itself is part of the product (not just something you run in a terminal), you may want to look at the GitHub Copilot SDK, now in technical preview.
The Copilot SDK gives you programmatic access to the same planning and execution engine that powers Copilot CLI, without requiring you to build or maintain your own orchestration layer. Instead of wiring planners, tools, and recovery logic yourself, you define agent behavior and let Copilot handle execution.
Use Copilot CLI when you want fast, interactive execution in your own workflow. Use the Copilot SDK when you want those same agentic capabilities embedded inside your application. The SDK exposes the execution engine behind Copilot CLI, but not GitHub-specific features like repository-scoped memory or delegated pull request workflows.
Explore Copilot SDK >
Take this with you
Copilot CLI is most useful when you treat it like a tool for momentum, not a replacement for judgment.
Used well, it helps you move from intent to concrete changes faster: exploring ideas, scaffolding projects, diagnosing failures, and handling mechanical work directly in the terminal. When precision matters, you move into your editor. When the work is ready to share, it lands on GitHub as a pull request—reviewable, testable, and shippable.
That flow matters more than any single command.
If you take one thing away from this guide, it’s this: Copilot works best when it fits naturally into how developers already build software. Start in the CLI to get unstuck or move quickly, slow down in the IDE to make decisions you can stand behind, and rely on GitHub to make the work durable.
Get started with GitHub Copilot CLI or take the Skills course >
The post From idea to pull request: A practical guide to building with GitHub Copilot CLI appeared first on The GitHub Blog.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み