✏️ Exercise 1 - Refactor a File
To get the most out of this exercise, run it on an existing codebase that is more complex than the simple game from the previous step.
Time to practice! We're going to work through the full Ask → Plan → Agent workflow, but this time on an existing codebase of your choice.
To get started, open a codebase in VS Code and load the Copilot chat window.
Switch to Ask mode and drag and drop two files from your project that you think might be good candidates for refactoring.
Ask Copilot to summarize both files. This gets Copilot familiar with the code and makes sure the context was added correctly.
Ask Copilot which file is the better candidate for refactoring and why. It'll reason through and pick one.
Switch to Plan mode (consider bumping up to a more powerful model). Ask Copilot to plan out the refactor. It'll research the code base and come back with a step-by-step plan.
Switch to Agent mode and start the implementation. Copilot will make the changes, track its to-dos, and run tests if it detects a test suite.
Don't worry if it's not perfect on the first try — large refactors can be tricky. Just iterate in the chat to refine things. We'll also cover context engineering in another training, which will make this kind of work a lot more reliable.
Next Steps
Now that you've got the basics down, let's look at some more advanced workflows — running multiple agents at the same time to get more done in parallel.