GitHub Copilot

Verified against GitHub Copilot Chat · 2026-07-28

Point Copilot Chat at the exact code with context variables instead of hoping it infers scope

A context-variable discipline for the Chat input box — #selection, #file, #codebase, and #sym — that tells Copilot precisely what it is being asked about instead of leaving scope to whatever tab happens to be open.

GitHub Copilot Chat (VS Code)5 fillable variables

The prompt

Ready to copy — highlighted parts are example details you can swap.

Ask Copilot Chat this question using explicit context variables rather than typing the question
alone and trusting it to infer what you mean by 'this' from whatever tab happens to be focused.

QUESTION OR TASK
Why does the discount total sometimes show one cent off from what the cart summary displays?

CONTEXT VARIABLE TO LEAD WITH, AND WHY
#selection on the calculateDiscount function — the question is about this one function's rounding, not the whole checkout module.
Pick deliberately, not automatically: #selection scopes to exactly the highlighted lines and
nothing else, which is right when the question is about a specific block and wrong when the
answer actually depends on a caller or a type defined elsewhere; #file scopes to the whole open
file, right for a question about that file's overall structure; #codebase triggers a
workspace-wide semantic search rather than a literal grep, which is the right choice when you do
not already know which file holds the answer, but the wrong choice when you do, since it is slower
and can miss an exact match that a scoped reference would have caught directly.

ADDITIONAL FILES TO INCLUDE EXPLICITLY
#file:lib/checkout/cart-summary.ts, since it independently recomputes a total that should match calculateDiscount's output.
Reference each one by name using its own file variable rather than describing it in prose and
hoping Copilot resolves the description to the right file — 'the file with the discount logic' is
a guess Copilot has to make; a named reference is not.

SYMBOL, IF THE QUESTION IS ABOUT ONE SPECIFIC FUNCTION OR TYPE ACROSS THE CODEBASE
#sym:calculateDiscount, to find every call site across the codebase, not just the one in the currently open file.
A symbol reference finds every real usage of that specific named export, which is a materially
different and more precise operation than asking a semantic question about 'how X is used' and
hoping the workspace search surfaces the same set of call sites.

WHAT TO LEAVE OUT
Ignore components/checkout/PromoBanner.tsx, which is open in another tab but only displays marketing copy, not the actual calculation.
If a file is open in another tab but is not actually relevant to this specific question, do not
rely on Copilot ignoring it correctly — an open tab is exactly the kind of ambient context that
gets folded in when nothing tells the model where the boundary of 'this' actually is, so state
explicitly when something visible is not what this question is about.

WHY THIS MATTERS FOR THE ANSWER YOU GET BACK
A vague 'explain this' question answered against whatever three tabs happen to be open produces an
answer scoped to an accident of your window layout, not to the actual boundary of the question —
the context variables exist specifically so that boundary is a deliberate choice attached to the
message, not an emergent property of which files you had open five minutes ago for an unrelated
reason.

Customize

Optional — swap in your own details for the highlighted parts above.

Why this works

#selection, #file, and #codebase are mechanically different retrieval operations, not just stylistic choices dressed up as options — #selection scopes to exactly the highlighted text and nothing else, #file expands that to the whole open document, and #codebase triggers an actual workspace-wide semantic search rather than a literal grep, which means picking between them is picking between three different and non-interchangeable ways Copilot gathers the material it will answer from. A named file reference resolves file identity deterministically, while a prose description of a file forces Copilot to guess which file the description points to — 'the file with the discount logic' might resolve correctly most of the time in a small codebase, but it is a guess every time, and a named reference removes that guess entirely rather than merely making it more likely to succeed. A symbol reference is a precision jump beyond even a named file: it finds every real usage of one specific named export across the workspace, which is a categorically different and more exact operation than asking a semantic question like how is X used and trusting a similarity-based search to surface the same complete set of call sites, since semantic search is optimized for relevance, not for exhaustiveness against one exact identifier. The ambient-context problem the exclusion_note addresses is a genuinely real default in Copilot Chat's context gathering: an open tab is part of the environment the model can see, and nothing about a plain-text question tells it that an open but irrelevant file should be excluded, so the boundary of what 'this' refers to in a loose question is set by an accident of your window layout rather than by a deliberate choice — which is exactly the gap explicit context variables exist to close.

Verified against

GitHub Copilot Chat Copilot Chat 1.270 (VS Code, #file/#selection/#codebase/#sym) · 2026-07-28

Changelog

  • 2026-07-28 Initial publish, verified against Copilot Chat 1.270 (VS Code) context variables.

Need this built into your business?

If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
Write a .github/copilot-instructions.md file Copilot actually followsA repository-wide custom-instructions file that Copilot loads automatically into every Chat request, code-review pass, coding-agent session, and commit or PR-description generation in this repo, written so each rule holds up standing alone instead of only in the context it was written in.GitHub Copilot Chat (VS Code)GitHub Copilot code review2026-07-20Scope Copilot's instructions to one directory with an applyTo instructions fileA path-scoped .github/instructions/*.instructions.md template using the applyTo frontmatter glob, so a directory-specific rule — a different test framework, a stricter API contract, a legacy pattern that must not spread — applies only where it is actually true instead of polluting the repo-wide instructions file.GitHub Copilot Chat (VS Code)GitHub Copilot coding agent2026-07-21Define a custom Copilot Chat mode instead of re-explaining your workflow every sessionA .github/chatmodes/*.chatmode.md definition — scoped tools, a fixed model, and a narrow system prompt — that turns a repeated review-and-plan style of conversation into a mode you switch into once, instead of a persona you re-describe in the first message every time.GitHub Copilot Chat (VS Code)2026-07-22Turn a prompt you keep retyping into a Copilot prompt file instead of pasting it againA .github/prompts/*.prompt.md reusable prompt file with input placeholders, invoked as a slash command from the Chat input box, so a well-tuned multi-paragraph prompt becomes one command instead of a paste you have to keep re-finding.GitHub Copilot Chat (VS Code)2026-07-22
All GitHub Copilot prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY