A Single Markdown File Can Make GitHub Copilot Follow Your Codebase Rules
GitHub Copilot's output improves less from better prompt phrasing and more from a committed instructions file at .github/copilot-instructions.md, which is prepended to every request. Unlike generic advice such as 'write clean code,' effective rules must be durable, specific, and checkable — for example, flagging that datetime.utcnow() returns a naive datetime rather than vaguely saying 'handle timezones correctly.' The article recommends keeping the file short, ideally under ten rules, since a bloated instruction file dilutes the rules that matter and adds overhead to every interaction. Rules should also avoid duplicating what automated tools like linters already enforce, reserving the file for non-obvious, codebase-specific facts the model cannot infer from source code alone. The author extends the pattern to infrastructure-as-code contexts like Terraform, Kubernetes, and GitHub Actions, where subtle mistakes are costlier and harder to catch in review.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in