Add a feature to an existing project
Adding a feature means more than generating new code. The change needs to fit the project's structure, preserve existing behavior, and have test evidence that it works.
In this guide, you use an agent in VS Code to plan a small multi-file feature in your own repository, implement the reviewed plan with controlled tool approvals, review the diffs and test results, and prepare the change for a pull request. You don't need custom agents or instructions to follow this workflow.
Prerequisites
Project: Your repository. Harness: Copilot. Interface: Chat view.
- Set up GitHub Copilot.
- Open a trusted repository with a working development environment and existing tests.
- Choose a small feature with an observable result. If you're unfamiliar with the implementation, explore the codebase first.
- Preserve unrelated work and create a development branch using your team's normal workflow.
Review the recommended security baseline before letting an agent run commands or edit files in an existing project.
1. Plan the feature with /plan
Start by describing what should change, what must stay the same, and how you will test the result. Avoid vague requests such as "add filters" that leave important behavior for the agent to invent.
-
Open the Chat view and start a new chat.
-
Keep Copilot selected as the Session Target, Agent as the role, and Manual permissions enabled.
-
Optionally, select Maximize Secondary Side Bar in the Chat view title bar so you have more room to read the plan.
-
Run
/planwith concrete requirements, constraints, and test expectations. Adapt this prompt to a feature in your repository:/plan Add an author filter dropdown next to the destination search on the blog page, plus an empty state with a Clear filters button when no posts match. Requirements: - Filter posts by both destination text and selected author, ignoring case and leading or trailing spaces in the destination query. - Populate the author dropdown dynamically from the existing posts, with an "All authors" default option that preserves current behavior. - Reuse the existing filter helper module and add unit tests covering author filtering, combined destination and author filters, empty queries, and no matches. - Keep the existing styling patterns and do not add dependencies. -
Answer any clarifying questions the agent asks as it inspects your project.
-
When the Review Plan card appears, select Open Full Plan to inspect the affected files, approach, and verification steps in the editor.
-
Check that the plan names real files, reuses existing helpers, and covers both new behavior and regressions. If anything is missing or out of scope, enter revisions in the card's feedback box and select Submit Feedback before approving.
Learn more about refining and saving plans in Plan work with agents.
2. Implement the plan and approve tool calls
Once the plan matches your expectations, start implementation and stay in control of side effects such as terminal commands:
- Select Implement Plan on the Review Plan card.
- If you maximized the Chat view, select Restore Secondary Side Bar so you can watch edits and inspect files side by side.
- Review each tool approval prompt that appears under Manual permissions, such as running your project's unit tests or type checks. Inspect the exact command before selecting Allow Once or saving a scoped approval for the session.
If the agent proposes a broader refactor or changes unrelated behavior, send a focused correction rather than letting scope expand. For repeated failures or unwanted changes, see Get an agent back on track.
3. Review edits and verify behavior
A completion message isn't evidence that the feature works. Inspect the changed code, test output, and live behavior directly.
-
Select the inline file and symbol links in the chat response to jump directly to the updated helper logic, UI components, and tests in the editor.
-
Use the working set above the chat input to step through pending diffs across files and select Keep or Undo as you verify each change.
-
Check the actual test output and confirm that tests assert the agreed requirements rather than skipping cases or weakening existing assertions:
- Existing default behavior is unchanged when the new option isn't selected.
- New behavior and combined interactions work as specified.
- Edge cases such as empty inputs and zero matches are covered and render cleanly.
-
Run your project's required build, lint, or type checks, and exercise the feature yourself in the running app or API.
When a check fails, compare the output against your requirements before changing either the test or the implementation.
4. Prepare the change for review
-
Open the Source Control view to review the complete diff, including tests, documentation, and any untracked files. Confirm that every change supports the approved feature.
-
Optionally, ask the agent for a concise review summary grounded in the actual diff and checks:
Summarize this change for a pull request. Explain the user-visible behavior, how existing behavior is preserved, and the validation we ran. List any checks that were not run or remaining limitations. Base the summary on the actual diff and command output, not only the plan. Do not commit or publish anything. -
Commit the intended changes and open a pull request through your team's normal workflow.
You now have a reviewed, tested feature whose plan, code edits, and verification evidence all trace back to an explicit set of requirements.