r/GithubCopilot • • 3d ago

Showcase ✨ .github/copilot-instructions.md gets injected into every Copilot Chat request. Here's a way to measure it

.github/copilot-instructions.md goes into every Copilot Chat request in VS Code, and Copilot's agent mode can edit it. That combination makes it the highest-leverage file in the repo and the one nobody measures.

The failure mode isn't that it gets wrong, it's that it gets long. Every addition is reasonable on the day it's added. Six months later the three rules that actually matter are sitting in the middle of forty that don't, and Copilot follows whichever is loudest. You can't tell from reading it whether it's 400 tokens or 4,000.

I built ctxcap to get the number. It's an offline token counter for context files, and .github/copilot-instructions.md is a default scan target alongside AGENTS.md, CLAUDE.md, .cursor/rules/**, and prompts/**. No API key, no network, no telemetry, no LLM. Two dependencies, MIT.

It tracks that delta against a committed git baseline, so growth shows up in review instead of in a surprise bill. Beyond counting, it emits a ranked plan of line ranges with a preserve list, so the agent splices by line number instead of rewriting the file from scratch, and --verify catches it if a preserved span gets cut. If the budget is unreachable it says so:

On the GitHub side there's an Action that posts a sticky PR comment (updated in place, not one per run) with the token table, and uploads SARIF to code scanning. Gating is opt-in — fail-on defaults to never, so you can watch the number for a month before you make it block anything.

https://github.com/Naeha-S/ctxcap

If you run it: I mostly want to hear where it misreads. Unusual layouts, spans it calls safe that aren't, paths it misses

0 Upvotes

Duplicates