Pular para o conteúdo

Lesson 3 - Agent modes: Plan and Autopilot

Este conteúdo não está disponível em sua língua ainda.

We started by adding a small feature into our project. But larger changes require a more robust process. Fortunately, GitHub Copilot CLI is built to work with an organization’s existing flow, ensuring we build the right things the right way. This is the first of several lessons where you will follow a typical agent-driven development process, starting by using an issue to generate a new feature, ensuring the code is valid, the feature behaves as expected, and eventually merged successfully into the project.

You’ll use the same conversation and branch as you continue through the feature workflow. Typically you’d have different branches or PRs for the different file types you’d be working with, but we’ll be taking a shortcut to help us focus on the core concepts.

To start, in this lesson, you will:

  • start a new Copilot conversation from a GitHub issue.
  • define requirements in Plan mode.
  • implement the new feature using Autopilot mode.
  • review the code.
  • validate the feature manually in a forwarded browser.

As you continue this feature, you’ll update the repository instructions, customize the existing quality-checks skill, add MCP validation, create a QA agent, and open the feature PR.

Scenario

Tailspin Toys’ catalog is growing, and visitors need to narrow the games by category and publisher. The backlog issue describes the feature, but details such as combining categories need agreement before coding. You’ll use Plan mode to resolve those decisions, then authorize a bounded implementation with Autopilot.

Background

Introducing AI coding agents to your development flow doesn’t change the fundamentals. If anything, they become even more important! Most developers follow a flow that resembles:

  1. Start from a filed issue that describes what needs to be done.
  2. Create a plan of what needs to be built.
  3. Build and review the code.
  4. Run the tests to validate the code.
  5. Manually validate the new functionality.
  6. Create a pull request (PR).
  7. Once the code has been reviewed and the continuous integration process succeeds, merge the code.

Depending on your team and organization, the exact specifics will vary. But most will be a variation on the theme listed above.

By sticking to this standard approach, you ensure the code generated by AI meets the requirements set forth and goes through the same vetting process as code written by hand.

Conversation modes

The conversation mode controls how much autonomy the agent has. Press Shift+Tab to cycle between modes:

  • Interactive: You and the agent work together. The agent suggests changes and waits for your input before proceeding.
  • Plan: The agent creates a plan first and is blocked from editing project files.
  • Autopilot: The agent works autonomously — writing code, running tests, and iterating until the task is complete.

Start in Plan mode, review the plan, then use Autopilot to implement it.

Start from the issue

Before starting the filtering work, return to your Codespace and make sure the repository and terminal are ready.

  1. Return to your Codespace. If it is stopped, restart it before continuing.

  2. Confirm the star-rating PR is merged.

  3. If the terminal isn’t open, press Control+` (Mac) or Ctrl+` (Windows/Linux).

  4. Update main, then create a branch for the filtering work:

    Terminal window
    git checkout main
    git pull --ff-only
    git checkout -b game-filters-cli
  5. Start Copilot CLI:

    Terminal window
    copilot --yolo
  6. Press Tab twice to open the Issues tab.

  7. Press A to display all issues.

  8. Use the arrow keys to highlight the issue titled Allow users to filter games by category and publisher.

  9. Press C to add the issue to the prompt and return to the Session tab.

Notice how the prompt now starts with #7 (or a similar number). The # allows you to bring an issue or pull request (PR) on GitHub into context.

Plan the filtering feature

Planning gives you a chance to define the approach to be taken for implementing a feature or performing tasks before handing it over to Copilot. It’s always a good idea for anything complex to spend a bit of time planning. Let’s switch to plan mode, and ask Copilot to create the plan.

  1. Press Shift+Tab to switch to Plan mode. Confirm the mode indicator below the prompt displays Plan.

  2. After the issue reference added in the prior step, enter the following prompt:

    Create a plan for implementing this feature.

Copilot gets to work on building out the plan! It’ll start by exploring the project, then determining the best approach.

  1. Along the way, Copilot may ask questions about how the filtering capabilities should work. Answer them based on your preferences. There are no wrong answers here!
  2. Once the plan is complete, press Control+E (Mac) or Ctrl+E (Windows/Linux) to expand the plan.
  3. Scroll up and down to review the plan.
  4. Ask Copilot to revise any part of the plan that does not match your decisions.

Approve Autopilot

With the plan written and reviewed, it’s time to implement it! Let’s let Copilot do its thing by using autopilot.

Autopilot will allow Copilot to iterate on the problem until it believes it’s complete.

  1. Select Accept plan and build on autopilot (recommended), or the similarly labeled option in your installed version.
  2. Confirm the mode indicator below the prompt displays Autopilot.
  3. Watch as Copilot iterates through the established plan, generates code, and runs tests.

Approval can start implementation immediately, so review the plan first. If Copilot reports missing dependencies or a port conflict, resolve the setup issue before treating the checks as complete.

Review and verify the implementation

Once the code is generated, it needs to be reviewed before it’s merged, just like any other code. Let’s both review the code and run the site to ensure everything looks good.

  1. Press Shift+Tab to enter Interactive mode. Confirm the mode indicator no longer displays Plan or Autopilot.
  2. Enter /diff and inspect the filtering implementation and tests.
  3. Compare the result with the issue and the decisions you made during planning.
  4. Once the code is reviewed, press Esc to exit the diff view.
  5. Review the output from the project’s checks and ask Copilot to resolve any failures.

Explore the new functionality

OK, the code looks good — but does it run? Let’s start the app like we did before and open the site through the Codespaces forwarded port.

  1. Ask Copilot to start the app:

    Start the app so I can try the filtering feature in my browser. Tell me the URL and leave the server running.
  2. When Codespaces reports that port 4321 is available, select Open in Browser.

  3. Try category filtering, publisher filtering, and the combinations you agreed on in the plan.

  4. Confirm reset and empty-result behavior match the issue and your decisions.

  5. Return to your Codespace and ask Copilot to stop the development server it started.

Summary and next steps

You’ve used different conversation modes to build and review a feature. In this lesson, you:

  • started a new Copilot conversation from a GitHub issue.
  • defined requirements in Plan mode.
  • implemented the new feature using Autopilot mode.
  • reviewed the code.
  • validated the feature manually in a forwarded browser.

Next, let’s dig a little deeper into how code is generated, ensuring it follows documented practices, by using custom instructions.

Resources