Skip to content

Rules (custom instructions)

By the end of the modes chapter you had a habit you’d grown tired of. Every time you wanted Copilot’s first draft to already fit a repo — orders-service’s sort idiom, the way each shared-lib file is laid out — you typed it out by hand. “Match the existing style.” “Use the audit helper the way the other events do.” “Sort the way this file already sorts.” It worked, but you were saying the same things on every request, and the moment you forgot, Copilot guessed — and guessed differently than your team would.

That repetition is the signal this chapter answers. The conventions aren’t changing between requests; you are re-typing them between requests. Write them down once, in a file Copilot reads automatically, and they stop being something you remember to say and become something the tool already knows.

A rules file is persistent context. Instead of living in your head and getting re-typed into the chat, your conventions live in a file in the repo, and Copilot pulls them into the conversation on its own — every request, no reminder. The payoff isn’t that Copilot gets smarter. It’s that its first draft lands closer to mergeable, because the things it used to guess are now stated. Less back-and-forth, fewer “actually, we do it this way” corrections, more diffs that pass review on the first read.

And because you inherited two repos with two sets of baked-in conventions, you’ll write rules for each — and discover that shared-lib, the library a dozen services depend on, needs stricter, more specific rules than your own squad’s app.

This chapter walks from the simplest rules file to the judgment of what belongs in one:

Start with the file every surface supports. Repo-wide instructions with copilot-instructions.md.