GitHub Copilot CLI(コマンドラインインターフェース) では、 GitHub の問題を読み取り、実装計画を提案し、要件を満たすコード変更のドラフトを作成できます。 ワークフローは会話型であるため、前提条件を修正し、関連するファイルをポイントし、 GitHub Copilot CLI(コマンドラインインターフェース) 動作するようにアプローチを絞り込むことができます。
サンプル シナリオ
顧客のサブスクリプションをサポートする内部 Node.js 課金 API を維持するプラットフォーム チームで作業しているとします。 製品マネージャーは、特定のサブスクリプションにアタッチされたプランを返す新しい GET /subscriptions/{id}/plan エンドポイントを要求する問題を、単体テストと OpenAPI 仕様の更新と共に開きます。 この問題には、必要な応答の形状、サブスクリプションが見つからないか取り消された場合のエラー ケース、パターンとして従う既存の /subscriptions/{id} エンドポイントへのリンクが含まれます。 課題を GitHub Copilot CLI(コマンドラインインターフェース) に任せて、ルート、コントローラー、テストのひな形を生成させたうえで、プルリクエストを作成できます。
ワークフローの例
GitHub Copilot CLI(コマンドラインインターフェース) では、 GitHubから直接問題を読み取り、作業を計画し、コードを記述し、テストを実行し、pull request を開くことができます。
問題をコンテキストに取り込む
リポジトリのルートから開始し、URL または owner/repo#numberで問題を参照します。
GitHub Copilot CLI(コマンドラインインターフェース) では、 GitHub MCP サーバーを使用して問題の本文、コメント、およびリンクされた項目をフェッチし、そのコンテキストをセッションの残りの部分で使用できるようにします。
Read octo-org/billing-api#482 and any issues or PRs it links to. Summarize what needs to be implemented before we plan the work.
Read octo-org/billing-api#482 and any issues or PRs it links to.
Summarize what needs to be implemented before we plan the work.
/plan を使用して実装計画を作成する
プラン モードに切り替えて、 GitHub Copilot CLI(コマンドラインインターフェース) ファイルに触れる前に変更を考慮します。
/plan Implement the subscription lookup endpoint described in the issue.
Follow the same conventions as the existing GET /subscriptions/{id} endpoint.
/plan Implement the subscription lookup endpoint described in the issue.
Follow the same conventions as the existing GET /subscriptions/{id} endpoint.
メモ
次の応答は例です。 コパイロットチャット の応答は非決定的であるため、ここで示したものとは異なる応答が返される可能性があります。
GitHub Copilot CLI(コマンドラインインターフェース) は、次のようなプランを返します。
1. Add a `getPlanForSubscription` method in `src/services/subscriptionService.ts` that reuses the existing billing client, throws `NotFoundError` when the subscription or plan does not exist, and throws `CancelledSubscriptionError` when the subscription has been cancelled.
1. Add a `GET /subscriptions/:id/plan` route in `src/routes/subscriptions.ts`, mirroring the error handling in the sibling `GET /subscriptions/:id` route and mapping `CancelledSubscriptionError` to a `410` response.
1. Update `openapi/subscriptions.yaml` with the new path, response schema, and `404` and `410` responses.
1. Add unit tests in `test/services/subscriptionService.test.ts` and `test/routes/subscriptions.test.ts` covering the success case, missing subscription, cancelled subscription, and missing plan.
1. Run the test suite and update the changelog entry.
計画を確認し、気になる点があれば指摘し、承認する前に GitHub Copilot CLI(コマンドラインインターフェース) に修正を依頼します。 たとえば、 Use the existing error classes in src/errors—NotFoundError for missing subscriptions or plans and CancelledSubscriptionError for cancelled subscriptions rather than introducing new ones で返信し、影響を受ける手順を更新してもらう場合があります。
実装を開始し、必要に応じて操縦する
計画を承認してコーディングを開始します。 GitHub Copilot CLI(コマンドラインインターフェース) は、一度に 1 つずつ手順を実行し、適用する前に各編集を表示します。 間違った方向に進みそうになったら、中断して正しい方向に導いてください。
たとえば、チームで標準化された課金クライアントを再利用するのではなく、GitHub Copilot CLI(コマンドラインインターフェース) が getPlanForSubscription メソッドに新しいデータベースクエリを追加するとします。 停止して操縦することができます。
Don't add a new query here. The billing client in src/clients/billingClient.ts already exposes a getPlan method. Use that and update the service to handle its NotFound response.
Don't add a new query here. The billing client in
src/clients/billingClient.ts already exposes a getPlan method.
Use that and update the service to handle its NotFound response.
GitHub Copilot CLI(コマンドラインインターフェース) はコードを修正し、残りの計画手順を続行します。
単体テストを生成して実行する
GitHub Copilot CLI(コマンドラインインターフェース)テスト ステップに達すると、既存のテスト ファイル内のパターンに一致するテストがスキャフォールディングされます。 プラン エンドポイントでは、次のようなケースが追加される場合があります。
- 有効なサブスクリプションのプラン情報を返します。
- サブスクリプションが存在しない場合に
404を返します。 - サブスクリプションが取り消されたときの
410を返します。 - サブスクリプションにプランがアタッチされていない場合に
404を返します。
テストを記述した後、 GitHub Copilot CLI(コマンドラインインターフェース) はターミナルでテストを実行して、結果をすぐに確認できるようにします。
Run the test suite for the new endpoint and fix any failures.
Run the test suite for the new endpoint and fix any failures.
テストが失敗した場合、 GitHub Copilot CLI(コマンドラインインターフェース) はエラー出力を読み取り、実装を更新し、テスト スイートが緑色になるまで再実行します。 各修正プログラムを確認して、マスクするのではなく、根本原因に対処していることを確認します。
を使用して変更を確認します。 /diff
/diffを使用して、セッション全体で行われた変更の統合ビューを表示します。
/diff
/diff
問題が発生した場合は、コミットする前に GitHub Copilot CLI(コマンドラインインターフェース) に修正を依頼してください。 たとえば、 Revert the formatting changes in src/routes/subscriptions.ts to only keep the new route handler で返信して、差分のスコープを意図した変更に戻す場合があります。
pull request を開く
機能が実装、テスト、およびレビューされたら、pull request を開くように GitHub Copilot CLI(コマンドラインインターフェース) に依頼します。 GitHub MCP サーバーを使用してブランチをプッシュし、プル要求を作成します
Commit the changes on a new branch, push it, and open a pull request against main. Link it to octo-org/billing-api#482 and summarize the implementation, the tests added, and any follow-up work.
Commit the changes on a new branch, push it, and open a pull request
against main. Link it to octo-org/billing-api#482 and summarize the
implementation, the tests added, and any follow-up work.
GitHub Copilot CLI(コマンドラインインターフェース) はプルリクエストの URL を返し、そこから先に進められるようにします。