– Agent Sessions Day on Feb 19th

Customize AI for your project

This guide walks you through setting up AI customizations for your project in Visual Studio Code. You start with basic coding standards and progressively add more targeted capabilities.

By the end, your project will have:

  • Project-wide coding standards that apply to every chat request
  • File-specific instructions for frontend code
  • A reusable prompt file for a common task
  • A custom agent with restricted tools
  • An MCP server for external tool access

Prerequisites

Step 1: Set project-wide coding standards

Start by generating an instructions file that captures your project's coding standards. These instructions are automatically included in every chat request.

  1. Open the Chat view (⌃⌘I (Windows, Linux Ctrl+Alt+I)).

  2. Type /init and press Enter.

    /init
    
  3. VS Code analyzes your project structure and generates a .github/copilot-instructions.md file tailored to your codebase.

  4. Review the generated file and customize it. For example, add a rule about your preferred import style:

    ## Imports
    - Use named imports instead of default imports.
    - Group imports: external libraries first, then internal modules, then relative paths.
    
  5. Save the file.

Verify it works: Ask Copilot to generate some code (for example, "create a utility function for date formatting"). Check that the response follows your coding standards. Select the References section in the chat response to confirm that copilot-instructions.md was included.

Tip

Learn more about always-on instructions in Use custom instructions.

Step 2: Add file-specific instructions

When different parts of your codebase follow different conventions, use instructions files with applyTo patterns to target specific file types.

  1. In the Chat view, select Configure Chat (gear icon) > Instructions & Rules, and then select New instruction file.

  2. Select .github/instructions/ to store the instructions in your project.

  3. Enter a file name, such as react.

  4. Add the following content to the file:

    ---
    applyTo: "**/*.tsx,**/*.jsx"
    ---
    # React component guidelines
    
    - Use functional components with hooks.
    - Define prop types with TypeScript interfaces.
    - Use CSS modules for component styling.
    - Export components as named exports.
    
  5. Save the file.

Verify it works: Open a .tsx file and ask Copilot to "create a user profile card component". The response should follow your React-specific conventions. Check the References section to confirm the instructions file was applied.

Tip

You can create multiple instructions files for different file types, frameworks, or modules. Learn more in Use .instructions.md files.

Step 3: Create a reusable prompt file

Prompt files encode common tasks as slash commands you can invoke in chat. Create one for a task you perform regularly.

  1. In the Chat view, select Configure Chat (gear icon) > Prompt Files, and then select New prompt file.

  2. Select .github/prompts/ to store the prompt file in your project.

  3. Enter a file name, such as create-component.

  4. Add the following content to the file:

    ---
    description: Scaffold a new React component with tests
    agent: agent
    tools: ['editFiles', 'createFile']
    ---
    Create a new React component based on the user's description.
    
    For each component, generate:
    1. The component file in `src/components/`
    2. A test file in `src/components/__tests__/`
    
    Follow the conventions in [React guidelines](../instructions/react.instructions.md).
    
  5. Save the file.

Verify it works: In the Chat view, type /create-component a data table with sorting and filtering and press Enter. Copilot should scaffold the component and test file according to your conventions.

Tip

Type /create-prompt in chat to generate a prompt file with AI assistance. You can also extract a reusable prompt from an ongoing conversation by asking "save this workflow as a prompt". Learn more in Use prompt files.

Step 4: Build a custom agent

Custom agents let the AI adopt specialized personas with specific tool access. Create a code reviewer agent that can only read code, not modify it.

  1. In the Chat view, select Configure Chat (gear icon) > Custom Agents, and then select Create new custom agent.

  2. Select .github/agents/ to store the agent in your project.

  3. Enter a file name, such as reviewer.

  4. Add the following content to the file:

    ---
    description: Review code for quality, security, and best practices
    tools: ['search/codebase', 'search/workspace', 'githubRepo']
    ---
    You are a code reviewer. Analyze the provided code and identify:
    
    1. **Security issues**: SQL injection, XSS, hardcoded secrets, insecure dependencies
    2. **Code quality**: complex functions, duplicated logic, missing error handling
    3. **Best practices**: naming conventions, documentation, test coverage
    
    Provide specific, actionable feedback. Reference the relevant code locations.
    Do NOT modify any files. Only review and report findings.
    
  5. Save the file.

Verify it works: Select the Reviewer agent from the agents dropdown in the Chat view, then ask "review the authentication module". The agent should analyze the code without making changes.

Tip

You can add handoffs to your agent to create guided workflows. For example, hand off from a planning agent to an implementation agent. Learn more in Custom agents.

Step 5: Connect an external tool with MCP

MCP servers extend the AI with access to external tools and services. Add one from the built-in gallery.

  1. Open the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)) and type @mcp in the search field.

  2. Browse the available MCP servers and select Install for MarkItDown, a tool that converts files like PDFs, Word documents, and spreadsheets to Markdown.

  3. When prompted, confirm that you trust the server.

  4. Select the Configure Tools button in the chat input and then enable the MarkItDown tool to allow the agent to use it.

  5. Open the Chat view and enter a prompt that uses the server's tools. For example, with MarkItDown installed:

    Convert the file report.pdf in my workspace to Markdown.
    

Verify it works: The agent should invoke the MarkItDown tool and return the file content as Markdown.

Tip

You can also configure MCP servers manually by editing the .vscode/mcp.json file. Learn more in Add and manage MCP servers.

What you built

Your project now has a layered AI customization setup:

your-project/
  .github/
    copilot-instructions.md          # Project-wide coding standards (Step 1)
    instructions/
      react.instructions.md          # React-specific conventions (Step 2)
    prompts/
      create-component.prompt.md     # Reusable component scaffolding (Step 3)
    agents/
      reviewer.agent.md              # Read-only code reviewer (Step 4)
  .vscode/
    mcp.json                         # MCP server configuration (Step 5)

Next steps

  • Explore agent skills to create portable, multi-file capabilities with scripts and resources
  • Set up hooks to automate tasks at agent lifecycle points, such as running a formatter after every file edit
  • Browse agent plugins to install pre-packaged customizations from community marketplaces
  • Share customizations with your team by committing the .github/ directory to your repository
  • See all your customizations in one place with the Chat Customizations editor