About customizing Copilot responses
GitHub Copilot can provide responses that are tailored to your preferences, the way your team works, the tools you use, and the specifics of your project. Instead of repeatedly adding the same context to your prompts, you can create custom instructions that automatically provide this information to Copilot to allow it to generate higher quality responses.
Prompt files provide another way to give Copilot task-specific instructions and context. Unlike custom instructions, you choose when to use them in a chat. For more information, see Prompt files for GitHub Copilot.
The types of custom instructions available, and the Copilot features that use them, vary by client and surface (GitHub.com, Visual Studio Code, Visual Studio, JetBrains IDEs, Xcode, and Eclipse). To check which types your environment supports, see Suporte para diferentes tipos de instruções personalizadas. For supported IDEs and versions, see matriz de recursos Copilot.
Observação
Devido à natureza não determinística da IA, Copilot pode nem sempre seguir suas instruções personalizadas exatamente da mesma maneira sempre que forem usadas.
Types of custom instructions
Custom instructions can apply at different levels:
| Type | Scope | Example uses |
|---|---|---|
| Personal instructions | Your conversations with Copilot | Specify your individual preferences, such as preferred language or response style. |
| Repository custom instructions | Conversations with Copilot performed in the context of a repository, project, path, or supported agent | Describe the languages, frameworks, tools, architecture, and coding conventions used in a project. |
| Organization custom instructions | Conversations with Copilot when used in the context of an organization | Provide organization-wide language, security, compliance, or response guidelines. |
Some clients (JetBrains IDEs and Xcode) provide additional global, workspace, or project instruction mechanisms. These mechanisms do not always map directly to personal, repository, and organization instructions in GitHub.
About personal instructions
Personal instructions configured on GitHub.com apply to GitHub Copilot Chat in GitHub. Other clients, such as Copilot CLI, use local files for personal instructions. See Adicionando instruções personalizadas para GitHub Copilot CLI.
You can customize how Copilot Chat responds to you on GitHub.com by adding personal instructions. These instructions apply only to you. For example, you can specify your preferred language, the level of detail you want, or how you want responses to be structured. See Adicionando instruções personalizadas pessoais para GitHub Copilot.
About repository custom instructions
Repository custom instructions provide project-specific context and guidance. For example, you can describe the repository's purpose, the frameworks and tools it uses, and the coding or testing conventions that contributors should follow.
There are three main types of repository custom instructions:
-
**Instruções personalizadas para todo o repositório**, que se aplicam a todas as solicitações feitas no contexto de um repositório.Elas são especificados em um arquivo
copilot-instructions.mdno diretório.githubdo repositório. -
**Instruções personalizadas específicas do caminho**, que se aplicam a solicitações feitas no contexto de arquivos que correspondem a um caminho especificado.Eles são especificados em um ou mais
NAME.instructions.mdarquivos dentro ou abaixo do.github/instructionsdiretório no repositório.Usando instruções específicas do caminho, você pode evitar sobrecarregar suas instruções em todo o repositório com informações que se aplicam apenas a arquivos de determinados tipos ou em determinados diretórios.
-
**Instruções do agente**, que são semelhantes às instruções personalizadas aplicáveis a todo o repositório, mas que atualmente não são suportadas por todos os recursos do Copilot.Eles são especificados em arquivos chamados
AGENTS.md,CLAUDE.mdouGEMINI.md.
Para obter detalhes sobre o suporte para cada um desses tipos de instruções personalizadas do repositório em diferentes recursos do Copilot, consulte Suporte para diferentes tipos de instruções personalizadas.
Para obter uma coleção de exemplos selecionada, consulte Instruções personalizadas.
Note that agent instruction files, such as AGENTS.md, provide instructions to supported AI agents. They are different from custom agent definition files stored in .github/agents, which define specialized agents and their configuration. For the agent instruction filenames that Copilot recognizes, see Suporte para diferentes tipos de instruções personalizadas.
Repository custom instructions across clients and surfaces
Which types of repository custom instructions you can use (repository-wide, path-specific, or agent instructions) depends on your environment and on the task, such as chatting, working in the cloud, or reviewing a pull request. For example, an environment may support path-specific instructions for one task but not another. To check support for your setup, see Suporte para diferentes tipos de instruções personalizadas. For supported IDEs and versions, see matriz de recursos Copilot.
About organization custom instructions
Observação
Apoio: No momento, as instruções personalizadas da organização só têm suporte para Copilot Chat on GitHub.com, Copilot code review on GitHub.com e Copilot cloud agent on GitHub.com.
Organization owners can add instructions to tailor Copilot to the needs and preferences of their organization. These instructions are used for all members of the organization, regardless of whether they receive their Copilot subscription from that organization.
Organization custom instructions can only be configured for organizations with a Copilot Business or Copilot Enterprise subscription.
For example, organization instructions can:
- Specify a language that should be used in responses.
- Provide organization-wide security or compliance guidance.
- Specify preferred response formats, such as not generating code blocks.
- Direct people to an internal knowledge base or support channel for particular topics.
For information about adding organization instructions, see Como adicionar instruções personalizadas de organização no GitHub Copilot.
Precedence of custom instructions
Precedence depends on the client and feature. Most surfaces and clients, including Copilot CLI, Visual Studio Code and Visual Studio, combine applicable instruction files without defining a general precedence order.
For Copilot Chat on GitHub.com, all relevant instructions are provided to Copilot. The order of precedence, from highest to lowest, is:
- Personal instructions
- Repository custom instructions:
- Path-specific instructions in any applicable
.github/instructions/**/*.instructions.mdfile - Repository-wide instructions in
.github/copilot-instructions.md - Agent instructions, such as instructions in an
AGENTS.mdfile
- Path-specific instructions in any applicable
- Organization custom instructions
Sempre que possível, tente evitar fornecer conjuntos conflitantes de instruções. Se você estiver preocupado com a qualidade da resposta, poderá desabilitar temporariamente as instruções do repositório. Confira Adicionando instruções personalizadas do repositório para GitHub Copilot.
Using custom instructions
Custom instructions consist of natural language instructions and are most effective when they are short, self-contained statements. Consider the scope over which you want an instruction to apply before deciding whether to add it at the personal, repository, or organization level.
Common use cases include:
- Response preferences. Specify a preferred language, response structure, tone, or level of explanation.
- Project context. Explain the purpose, architecture, or domain of a repository.
- Languages and frameworks. Identify the languages, libraries, frameworks, and versions used by a project.
- Coding and testing conventions. Describe naming, formatting, testing, error-handling, or documentation standards.
- Review and security guidance. Identify issues that should receive particular attention when a supported feature reviews or changes code.
- Organization requirements. Provide organization-wide language, security, compliance, or support guidance.
For example:
- Personal instruction:
Always respond in Portuguese. - Personal instruction:
Explain a single concept per line. Be clear and concise. - Repository instruction:
Use Vue with the PrimeVue library. - Repository instruction:
Use early returns whenever possible. - Organization instruction:
For questions related to security, use the Security Docs Knowledge Base. - Organization instruction:
Do not generate code blocks in responses.
Instructions about testing, commit messages, or code review can provide useful context. However, the Copilot features that use a particular instruction vary by client and surface, and custom instructions do not guarantee that generated content will comply with a policy.
Observação
Ao examinar uma pull request, Copilot leia instruções personalizadas de repositório, instruções de agente e habilidades de agente da ramificação principal (a ramificação com as alterações), e não a ramificação base. Por exemplo, ao mesclar my-feature-branch em main, Copilot usa as instruções e habilidades em my-feature-branch, para que você possa testar alterações nelas no mesmo pull request sem mesclá-las primeiro.
Como escrever instruções personalizadas eficazes
As instruções que você adiciona aos seus arquivos de instrução personalizados devem ser instruções curtas e autocontidas que fornecem Copilot informações relevantes para ajudá-lo a trabalhar neste repositório. Como as instruções são enviadas com cada mensagem de chat, elas devem ser amplamente aplicáveis à maioria das solicitações que você fará no contexto do repositório.
A estrutura exata usada para seus arquivos de instruções variará de acordo com o projeto e a necessidade, mas as diretrizes a seguir fornecem um bom ponto de partida:
- Forneça uma visão geral do projeto no qual você está trabalhando, incluindo a finalidade, as metas e demais informações contextuais relevantes.
- Especifique os padrões de codificação e as convenções que devem ser seguidas, como convenções de nomenclatura, regras de formatação e práticas recomendadas.
- Inclua outras ferramentas, bibliotecas ou estruturas específicas usadas no projeto, juntamente com números de versão ou configurações relevantes.
O arquivo de instruções a seguir é um exemplo dessas práticas em ação:
# Project Overview
This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.
## Libraries and Frameworks
- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.
## Coding Standards
- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.
## UI guidelines
- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.
Considere também o tamanho e a complexidade do repositório. Os seguintes tipos de instruções podem funcionar para um pequeno repositório com apenas alguns colaboradores, mas para um repositório grande e diversificado, isso pode causar problemas:
- Solicitações para referência a recursos externos ao formular uma resposta
- Instruções para resposta em um estilo específico
- Solicitações para sempre responder com determinado nível de detalhes
Por exemplo, as seguintes instruções podem não ter os resultados pretendidos:
Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.
Use @terminal when answering questions about Git.
Answer all questions in the style of a friendly colleague, using informal language.
Answer all questions in less than 1000 characters, and words of no more than 12 characters.
Next steps
- Adicionando instruções personalizadas pessoais para GitHub Copilot
- Adicionando instruções personalizadas do repositório para GitHub Copilot
- Adicionando instruções personalizadas de repositório para o GitHub Copilot em seu IDE
- Como adicionar instruções personalizadas de organização no GitHub Copilot