Text of code.visualstudio.com › docs › agents › agents-tutorial as Styx crawled it on Oct 9, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Tutorial: Agentic coding in VS Code

AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. 🎬 Watch The Story of VS Code! VS Code is now on Instagram, follow @vscode.ig for updates, tips, and more. Rewatch GitHub Copilot Day. Tutorial: Agentic coding in VS Code View as Markdown Ask in VS Code Ask in VS Code Insiders In this tutorial, you build a personal portfolio page with AI agents in Visual Studio Code.

You describe what you want in natural language, and an agent creates and edits files. You then review and test the result. The app uses HTML, CSS, and JavaScript, so you don't need to install any runtimes or build tools. You start in the Agents window to create the app, then continue the same session in the Chat view to refine it alongside your code. Along the way, you learn to open a project folder, preview your app in the integrated browser, and review and commit changes with Git.

Learn VS Code editor features Get familiar with the VS Code user interface, editing features, and key productivity tools. Start the VS Code editing tutorial Prerequisites Download and install Visual Studio Code . Enable AI features in VS Code If you use GitHub Copilot, learn more about AI credits and model costs and what happens when you reach a limit . Install Git 1. Create a project folder Agents work in the context of a folder, also referred to as a workspace in VS Code.

You start by creating a folder for your project. Start by creating an empty folder for the tutorial app and enabling Git version control to track your changes. On your computer, create a new folder named myportfolio . mkdir myportfolio Put the folder under Git version control to track changes. Open a terminal and run the following commands: cd myportfolio git init 2. Build features with the Agents window The Agents window is a dedicated window in VS Code that is optimized for working with agents across all your projects without needing to open a separate VS Code window for each one.

In this part, you open your folder in the Agents window and task an agent to build your portfolio page. Open the Agents window In VS Code, select the Open in Agents button in the VS Code title bar. You can also open the Agents window from the VS Code welcome page, or run the Chat: Open Agents window command from the Command Palette ( ⇧⌘P (Windows, Linux Ctrl+Shift+P ) ). If you're prompted to sign in, use the GitHub account that has access to GitHub Copilot.

This tutorial uses the Copilot agent harness. To use your own provider credentials for supported workflows, review the agent harness authentication options . Start an agent session Select New at the top of the left sidebar to start a new agent session. The sidebar shows your list of active agent sessions, grouped by workspace. You can use the sessions list to switch between sessions and their workspace context. Tip If you want to ask a general question, you can also start a chat session that is not tied to a specific workspace.

Because the Agents window can operate across different projects, select the myportfolio folder you created earlier from the dropdown. This folder becomes the primary execution workspace for the session. If VS Code asks whether you trust the folder, select Trust . Important When you download code from the internet, review the code before trusting it to make sure it's safe to run. Get more info about Workspace Trust . Configure the following settings for the session.

Keep the default values for any other options. Control Value Short description Session Target Copilot Uses the Copilot agent harness to run the session with the GitHub Copilot SDK on your machine. Agent Agent Uses tools to plan, edit files, run commands, and validate the result. Language model Auto Automatically selects a model based on task complexity and availability. Permissions Manual permissions Requests your approval for running tools or accessing resources.

The agent can make file edits in your project folder. Enter the following prompt in the chat input and press Enter : Create a personal portfolio page with HTML, CSS, and JavaScript in separate files. Include a header with my name and a short bio, a section for projects with cards, and a contact section. Use modern styling and add some sample content. The agent analyzes your request, plans the work, and then starts creating and editing files.

If it encounters errors, it self-corrects or asks for clarification and approval. The Copilot agent harness applies and saves edits directly to your project folder. Review the resulting diffs before you commit the changes. Tip If the agent heads in the wrong direction, steer or stop the request . Stopping doesn't undo completed actions. To undo workspace file changes from a request, restore a checkpoint . Preview and iterate on the design The Agents window is great for workflows where you hand off tasks to the agent and then validate the outcome, rather than the specific code changes.

With the integrated browser, you can preview the agent's work without having to leave VS Code. To preview the generated portfolio in the integrated browser: Select the Files tab in the left sidebar, right-click the index.html file and select Open in Integrated Browser . The Files tab shows all files in the workspace, similar to the Explorer view in the editor. The integrated browser opens in a new tab in the Agents window, and you can interact with the page as you would in a normal browser.

Let's make a design change to the page. In the integrated browser, select the Add Element to Chat button to enter selection mode. Hover over the page and select an element you want to change, for example select the main title. The agent adds the selected element to your prompt as context, including its HTML, CSS, and a screenshot. In the chat input, enter a prompt that describes the change you want, and press Enter . For example: Use a gradient color for the text and use cursive.

The agent applies the change to the element you selected. Refresh the page in the integrated browser to see the updates. Review and commit the changes Before you commit the agent's work, review the code changes that the agent applied. The Changes panel shows diffs for every file the agent created or modified during its session. To review and commit the file changes: Select the Changes panel to see the diffs of the files the agent added or modified.

Each item also shows change stats and an add/delete/update indicator. For keyboard and screen reader access to the diffs, use the Accessible Diff Viewer . Open the diff from the index.html file and select a block of text to open the inline feedback flow. Enter your feedback and then select Submit . Notice that your feedback is added to the chat conversation, and the agent processes it and applies the change to the file.

You can continue to provide feedback on other changes in the diff view. From the changes dropdown, select Uncommitted Changes to see the changes that have not yet been committed to your Git repository. Use the changes dropdown to switch between branch changes, uncommitted changes, all changes from the session, and changes made during the last agent turn. Now select Commit Changes in the Changes panel to save the agent's changes to your Git repository.

VS Code automatically creates a commit message based on the agent's prompt and the changes it made. After committing the changes, the branch changes and uncommitted changes are now empty because there are no pending changes. The change stats are also cleared from the session entry in the session list. 3. Continue working with agents in the editor For some changes, you might prefer a code-first approach, where your focus is on writing code and Copilot assists you in the process.

For example, you might want to add a theme switcher and fine-tune the styles as you go. For this approach, continue the same Copilot session in the Chat view. Open the editor for your work

The rest of this page is on the live site.