← All How-tos

How-to⁠ · ⁠ · GitHub Copilot · 4 steps

Copilot copilot-instructions.md: set repo rules in 4 steps

Write your repo’s rules down once and Copilot adds them to requests in that repository.

One Markdown file in .github carries how to build, test and style changes in that repository.

You need: Copilot on GitHub and a repository where you can add files.

Steps

  1. In the root of your repository, create .github/copilot-instructions.md. Create the .github folder first if it doesn’t exist.
  2. Write your instructions in plain Markdown, such as how to build, test and validate changes. Whitespace between instructions is ignored, so one rule per line works fine.
  3. Optional: for rules that only fit some files, add a NAME.instructions.md file under .github/instructions that starts with this frontmatter block.

    ---
    applyTo: "**/*.ts,**/*.tsx"
    ---
    
  4. Save the file and Copilot starts using it. In Copilot Chat on github.com, attach the repository, then expand the references at the top of a reply and look for .github/copilot-instructions.md.

Heads-up

  • On GitHub.com, path-specific .instructions.md files only apply to Copilot cloud agent and Copilot code review.
  • Personal instructions outrank repository instructions, and organization instructions come last. Copilot still gets all of them, so avoid rules that conflict.
  • Copilot code review reads instructions from the pull request’s head branch, so you can test an edit in the same pull request before you merge it.

Source: GitHub Docs: Adding repository custom instructions for GitHub Copilot