Menu

Path-specific Copilot custom instructions: a guide
📰

Path-specific Copilot custom instructions: a guide

DEV Community: github·Sascha Mirow-Stanitzok·12 days ago
#bthSw6Ya
Reading 0:00
15s threshold

Copilot custom instructions are, for me, the difference between “Copilot guesses” and “Copilot knows our repo”. Many teams create a .github/copilot-instructions.md at some point, put twenty rules in it and then wonder why the review still nitpicks formatting and the agent writes code in the CDK stack as if it were a Lambda handler. The reason is almost always the same: everything sits in one file, and everything applies everywhere.

Since Copilot also reads path-specific instructions, you can do better. You place small files under .github/instructions/ and use glob patterns to say which files they apply to. In this article I set this up step by step for a fictional TypeScript repo of a bike rental, including a small check script that finds broken patterns before they cost you a review.

In short

With files like .github/instructions/infra.instructions.md and an applyTo pattern, Copilot only gets the rules that match the changed file.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.