A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://code.visualstudio.com/docs/copilot/copilot-customization below:

Customize AI responses in VS Code

Customize AI responses in VS Code

Chat in Visual Studio Code can give you responses and generate code that matches your coding practices and project requirements, if you give it the right context. Instead of repeatedly adding this information in every chat prompt, you can store this context in files and automatically include it in every chat request. In this article, you learn how to use custom instructions and prompt files to customize AI responses in VS Code.

There are three main ways to customize AI responses in Visual Studio Code:

Custom instructions

Custom instructions enable you to describe common guidelines or rules to get responses that match your specific coding practices and tech stack. Instead of manually including this context in every chat query, custom instructions automatically incorporate this information with every chat request.

Types of custom instructions

VS Code supports multiple ways to define custom instructions:

Custom instructions type Description .github/copilot-instructions.md file .instructions.md files VS Code settings

You can use a combination of these approaches to define custom instructions and the instructions are all included in the chat request. No particular order or priority is applied to the instructions, so make sure to avoid conflicting instructions in the files.

Custom instructions examples

The following examples demonstrates how to use custom instructions:

Example: general coding guidelines
---
applyTo: "**"
---
# Project general coding standards

## Naming Conventions
- Use PascalCase for component names, interfaces, and type aliases
- Use camelCase for variables, functions, and methods
- Prefix private class members with underscore (_)
- Use ALL_CAPS for constants

## Error Handling
- Use try/catch blocks for async operations
- Implement proper error boundaries in React components
- Always log errors with contextual information
Example: TypeScript and React coding guidelines

Notice how these instructions reference the general coding guidelines file. You can separate the instructions into multiple files to keep them organized and focused on specific topics.

---
applyTo: "**/*.ts,**/*.tsx"
---
# Project coding standards for TypeScript and React

Apply the [general coding guidelines](./general-coding.instructions.md) to all code.

## TypeScript Guidelines
- Use TypeScript for all new code
- Follow functional programming principles where possible
- Use interfaces for data structures and type definitions
- Prefer immutable data (const, readonly)
- Use optional chaining (?.) and nullish coalescing (??) operators

## React Guidelines
- Use functional components with hooks
- Follow the React hooks rules (no conditional hooks)
- Use React.FC type for components with children
- Keep components small and focused
- Use CSS modules for component styling
Use a .github/copilot-instructions.md file

You can store custom instructions in your workspace or repository in a .github/copilot-instructions.md file and describe your coding practices, preferred technologies, and project requirements by using Markdown. These instructions only apply to the workspace where the file is located.

VS Code automatically includes the instructions from the .github/copilot-instructions.md file in every chat request and applies them for generating code.

To use a .github/copilot-instructions.md file:

  1. Set the github.copilot.chat.codeGeneration.useInstructionFiles setting to true to instruct VS Code to automatically use the copilot-instructions.md file for every chat request.

  2. Create a .github/copilot-instructions.md file at the root of your workspace. If needed, create a .github directory first.

  3. Describe your instructions by using natural language and in Markdown format.

    Whitespace between instructions is ignored, so the instructions can be written as a single paragraph, each on a new line, or separated by blank lines for legibility.

Note

GitHub Copilot in Visual Studio and GitHub.com also detect the .github/copilot-instructions.md file. If you have a workspace that you use in both VS Code and Visual Studio, you can use the same file to define custom instructions for both editors.

Use .instructions.md files

You can also create one or more .instructions.md files to store custom instructions for specific tasks. For example, you can create instruction files for different programming languages, frameworks, or project types.

VS Code can automatically add instructions files to all chat requests, or you can specify for which files the instructions should be applied automatically. Alternatively, you can manually attach instructions files to a chat prompt.

VS Code supports two types of scopes for instruction files:

Instructions file structure

An instructions file is a Markdown file with the .instructions.md file suffix. The instructions file consists of two sections:

Create an instructions file

You can create instructions files in your workspace or user profile. Workspace instructions files are only available within the workspace, while user instructions files are available across multiple workspaces.

To create an instructions file:

  1. Select the Configure Chat button in the Chat view, select Instructions, and then select New instruction file.

    Alternatively, use the Chat: New Instructions File command from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)).

  2. Choose the location where the instruction file should be created.

  3. Enter a name for your instruction file.

  4. Author the custom instructions by using Markdown formatting.

    Specify the applyTo metadata property in the header to configure when the instructions should be applied automatically. For example, you can specify applyTo: "**/*.ts,**/*.tsx" to apply the instructions only to TypeScript files.

    To reference additional workspace files, use Markdown links ([index](../index.ts)) or #-reference them (#index.ts) within the instructions file.

To modify an existing instructions file, select the Configure Chat button in the Chat view, select Instructions, and then select an instructions file from the list. Alternatively, use the Chat: Configure Instructions command from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and select the instructions file from the Quick Pick.

Use an instructions file in chat

If you specified the applyTo metadata property in the instructions file, VS Code automatically applies the instructions to all files that match the glob pattern.

To manually attach an instructions file to a chat prompt:

Specify custom instructions in settings

You can configure custom instructions for specialized scenarios in your user or workspace settings.

* The codeGeneration and testGeneration settings are deprecated as of VS Code 1.102. We recommend that you use instructions files instead (.github/copilot-instructions.md or *.instructions.md).

You can define the custom instructions as text in the settings value (text property) or reference an external file (file property) in your workspace.

The following code snippet shows how to define a set of instructions in the settings.json file.

    "github.copilot.chat.pullRequestDescriptionGeneration.instructions": [
        { "text": "Always include a list of key changes." },
    "github.copilot.chat.reviewSelection.instructions": [
        { "file": "guidance/backend-review-guidelines.md" },
        { "file": "guidance/frontend-review-guidelines.md" }
  ]
Generate an instructions file for your workspace

VS Code can analyze your workspace and generate a matching .github/copilot-instructions.md file with custom instructions that match your coding practices and project requirements.

To generate an instructions file for your workspace:

  1. Select the Configure Chat button in the Chat view and select Instructions

  2. Select Generate instructions from the Quick Pick.

  3. Review the generated instructions file and make any necessary edits.

Tips for defining custom instructions Prompt files (experimental)

Prompt files are reusable prompts for common tasks like generating code or performing a code review. You define the prompt content in a Markdown file. A prompt file is a standalone prompt that you can run directly in chat. Optionally, you can also include guidelines about how the task should be performed.

Tip

Prompt files can take advantage of instruction files to reuse common guidelines and have task-specific instructions included in the prompt. For example, a security review prompt file can reference a custom instructions that describe general security practices, while also including specific instructions on how to report the findings of the review.

VS Code supports two types of scopes for prompt files:

Prompt file examples

The following examples demonstrate how to use prompt files:

Example: generate a React form component
---
mode: 'agent'
model: GPT-4o
tools: ['githubRepo', 'codebase']
description: 'Generate a new React form component'
---
Your goal is to generate a new React form component based on the templates in #githubRepo contoso/react-templates.

Ask for the form name and fields if not provided.

Requirements for the form:
* Use form design system components: [design-system/Form.md](../docs/design-system/Form.md)
* Use `react-hook-form` for form state management:
* Always define TypeScript types for your form data
* Prefer *uncontrolled* components using register
* Use `defaultValues` to prevent unnecessary rerenders
* Use `yup` for validation:
* Create reusable validation schemas in separate files
* Use TypeScript types to ensure type safety
* Customize UX-friendly validation rules
Example: perform a security review of a REST API
---
mode: 'ask'
model: Claude Sonnet 4
description: 'Perform a REST API security review'
---
Perform a REST API security review and provide a TODO list of security issues to address.

* Ensure all endpoints are protected by authentication and authorization
* Validate all user inputs and sanitize data
* Implement rate limiting and throttling
* Implement logging and monitoring for security events

Return the TODO list in a Markdown format, grouped by priority and issue type.
Prompt file structure

A prompt file is a Markdown file with the .prompt.md file suffix. It has the following two main sections:

You can reference other workspace files, prompt files, or instructions files by using Markdown links. Use relative paths to reference these files, and ensure that the paths are correct based on the location of the prompt file.

Within a prompt file, you can reference variables by using the ${variableName} syntax. You can reference the following variables:

Create a prompt file

You can create prompt files in your workspace or user profile. Workspace prompt files are only available within the workspace, while user prompt files are available across multiple workspaces.

To create a prompt file:

  1. Select the Configure Chat button in the Chat view, select Prompt Files, and then select New prompt file.

    Alternatively, use the Chat: New Prompt File command from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)).

  2. Choose the location where the prompt file should be created.

  3. Enter a name for your prompt file.

    Alternatively, you can directly create a .prompt.md file in the prompts folder of your workspace.

  4. Author the chat prompt by using Markdown formatting.

    Within a prompt file, reference additional workspace files as Markdown links ([index](../index.ts)), or as #index.ts references within the prompt file.

    You can also reference other .prompt.md files to create a hierarchy of prompts. You can also reference instructions files in the same way.

To modify an existing prompt file, select the Configure Chat button in the Chat view, select Prompt Files, and then select a prompt file from the list. Alternatively, use the Chat: Configure Prompt Files command from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and select the prompt file from the Quick Pick.

Use a prompt file in chat

You have multiple options to run a prompt file:

Sync user prompt files across devices

VS Code can sync your user prompt files across multiple devices by using Settings Sync.

To sync your user prompt files, enable Settings Sync for prompt and instruction files:

  1. Make sure you have Settings Sync enabled.

  2. Run Settings Sync: Configure from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)).

  3. Select Prompts and Instructions from the list of settings to sync.

Centrally manage instructions and prompt files in VS Code

Enable or disable instructions and prompt files in VS Code with the chat.promptFiles setting.

To centrally enable or disable this setting within your organization with device management, check Centrally Manage VS Code Settings in the enterprise documentation.

Settings Custom instructions settings Prompt files settings

07/09/2025


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4