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.
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
