Skip to main content
Skip to content

Custom instructions for GitHub Copilot

Customize GitHub Copilot responses to your preferences, project conventions, and organization requirements.

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 Поддержка различных типов пользовательских инструкций. For supported IDEs and versions, see Матрица функций Copilot.

Примечание.

Из-за недетерминированной природы ИИ Copilot может не всегда выполнять ваши пользовательские инструкции одинаково каждый раз, когда они используются.

Types of custom instructions

Custom instructions can apply at different levels:

TypeScopeExample uses
Personal instructionsYour conversations with CopilotSpecify your individual preferences, such as preferred language or response style.
Repository custom instructionsConversations with Copilot performed in the context of a repository, project, path, or supported agentDescribe the languages, frameworks, tools, architecture, and coding conventions used in a project.
Organization custom instructionsConversations with Copilot when used in the context of an organizationProvide 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 Добавление пользовательских инструкций для 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 Добавление персональных инструкций для 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:

  • Пользовательские инструкции на уровне репозитория, которые применяются ко всем запросам, сделанным в контексте репозитория.

    Они указаны в copilot-instructions.md файле в .github каталоге репозитория.

  • Пользовательские инструкции для конкретного пути, которые применяются к запросам, сделанным в контексте файлов, которые соответствуют указанному пути.

    Они указываются в одном или нескольких NAME.instructions.md файлах внутри или ниже .github/instructions каталога репозитория.

    С помощью инструкций, относящихся к пути, можно избежать перегрузки инструкций на уровне репозитория с информацией, которая применяется только к файлам определенных типов или в определенных каталогах.

  • Инструкции агента, которые аналогичны пользовательским инструкциям на уровне репозитория, но в настоящее время поддерживаются не всеми функциями Copilot.

    Они указываются в файлах с именами AGENTS.md, CLAUDE.mdили GEMINI.md.

Для подробностей поддержки каждого из этих типов пользовательских инструкций репозитория между различными функциями Copilot см. Поддержка различных типов пользовательских инструкций.

Для просмотра тщательно подобранной коллекции примеров см. AUTOTITLE.

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 Поддержка различных типов пользовательских инструкций.

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 Поддержка различных типов пользовательских инструкций. For supported IDEs and versions, see Матрица функций Copilot.

About organization custom instructions

Примечание.

Поддержка: В настоящее время пользовательские инструкции организации поддерживаются только для Copilot Chat на GitHub.com, Copilot code review на GitHub.com и Copilot cloud agent на 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 Добавление пользовательских инструкций по организации для 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:

  1. Personal instructions
  2. Repository custom instructions:
    1. Path-specific instructions in any applicable .github/instructions/**/*.instructions.md file
    2. Repository-wide instructions in .github/copilot-instructions.md
    3. Agent instructions, such as instructions in an AGENTS.md file
  3. Organization custom instructions

По возможности старайтесь избегать противоречивых наборов инструкций. Если вас беспокоит качество отклика, вы можете временно отключить инструкции репозитория. См . раздел AUTOTITLE.

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.

Примечание.

При проверке запроса Copilot на вытягивание считывает пользовательские инструкции репозитория, инструкции агента и навыки агента из головной ветви (ветвь с изменениями), а не базовую ветвь. Например, при слиянии my-feature-branch``mainс ними Copilot используются инструкции и навыки my-feature-branch, позволяющие протестировать изменения в одном запросе на вытягивание, не объединяя их в первую очередь.

Написание эффективных пользовательских инструкций

Инструкции, добавляемые в пользовательские файлы инструкций, должны быть короткими, автономными операторами, которые предоставляют Copilot соответствующие сведения, чтобы помочь ей работать в этом репозитории. Так как инструкции отправляются с каждым сообщением чата, они должны быть широко применимы к большинству запросов, которые вы будете делать в контексте репозитория.

Точную структуру, используемую для файлов инструкций, зависит от проекта и необходимости, но следующие рекомендации предоставляют хорошую отправную точку:

  • Предоставьте обзор проекта, над которым вы работаете, включая его назначение, цели и любую соответствующую справочную информацию.
  • Укажите стандарты кода и соглашения, которые следует соблюдать, такие как соглашения об именовании, правила форматирования и рекомендации.
  • Включите все определенные средства, библиотеки или платформы, используемые в проекте, а также любые соответствующие номера версий или конфигурации.

Следующий файл инструкций является примером этих практик в действии:

# 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.

Также следует учитывать размер и сложность репозитория. Следующие типы инструкций могут работать для небольшого репозитория только с несколькими участниками, но для большого и разнообразного репозитория могут вызвать проблемы:

  • Запросы на ссылки на внешние ресурсы при разработке ответа
  • Инструкции по ответу в определенном стиле
  • Запросы всегда отвечать на определенный уровень детализации

Например, следующие инструкции могут не иметь предполагаемых результатов:

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

Further reading