GitHub Copilot

Verified against GitHub Copilot Chat · 2026-07-30

Chain /explain into /fix into /tests instead of running any of them cold

A three-step slash-command sequence for the Copilot Chat panel where each command's output becomes the explicit input to the next, so a fix maps to a stated concern instead of whichever issue looked most fixable, and the tests actually probe the regression risk that started the session.

GitHub Copilot Chat (VS Code)4 fillable variables

The prompt

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

Select the calculateDiscount function in lib/checkout/discount.ts in the editor, open the Copilot Chat panel, and run these
three slash commands in order, feeding each answer forward into the next rather than treating them
as three separate, unrelated questions against the same selection.

WHY THE SELECTION ITSELF MATTERS
Select only the calculateDiscount function in lib/checkout/discount.ts, not the whole file around it — a wider selection gives
all three commands more surface area to wander into, and /fix in particular is more likely to also
touch something adjacent and unrelated to whether expired discount codes are rejected correctly when the cart total changes after the code was applied the larger the selected block is.

STEP 1 — /explain
Ask: /explain what does this do, specifically with respect to whether expired discount codes are rejected correctly when the cart total changes after the code was applied, not a general summary
of the whole selection.

Before moving to step 2, read the answer and check one thing: does it actually address whether expired discount codes are rejected correctly when the cart total changes after the code was applied
by name, or did it summarize the selection in general terms without ever touching the specific
thing you are worried about? If it did not mention whether expired discount codes are rejected correctly when the cart total changes after the code was applied, ask a direct follow-up naming it
explicitly before proceeding — do not move to /fix on an explanation that never actually engaged
with the concern that brought you to this selection in the first place. Cross-check the answer
against calculateDiscount should re-validate against the cart total at checkout time, not the total from when the code was first applied. if you already have a hypothesis about what should happen.

STEP 2 — /fix
Ask: /fix address whether expired discount codes are rejected correctly when the cart total changes after the code was applied specifically, based on what step 1 just explained. Do not change
anything step 1 described as already working correctly.

Check the proposed diff against the step 1 explanation before accepting it: it should map directly
onto the concern step 1 confirmed exists, not an unrelated style change or a rewrite of a part step
1 said was fine. If the diff touches something step 1 explicitly called correct, reject it and ask
for a version scoped only to the confirmed concern.

STEP 3 — /tests
Ask: /tests using Vitest, matching the rest of lib/checkout/'s existing test files., add tests that would have caught whether expired discount codes are rejected correctly when the cart total changes after the code was applied before this fix
existed, in addition to the already-passing behavior step 1 confirmed.

Reject the /tests output if every generated test only re-covers the happy path that was already
working — that is testing what step 1 already confirmed was fine, not the actual regression risk
this whole session exists to close. If the case covering whether expired discount codes are rejected correctly when the cart total changes after the code was applied specifically is missing, ask
for it by name rather than accepting a suite that looks thorough but never actually exercises the
concern that started this.

IF ANY STEP'S ANSWER DOES NOT ACTUALLY BUILD ON THE PREVIOUS ONE
Stop and re-run that step with the previous answer explicitly pasted back in, rather than
continuing the chain on an answer that quietly dropped the thread — each slash command is
effectively a fresh, single-turn invocation, and nothing guarantees it fully carries forward the
nuance of an earlier turn's explanation just because the conversation looks continuous.

Customize

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

Why this works

/explain, /fix, and /tests are Copilot Chat's built-in slash commands, and each one is scoped to a fixed task against the current selection with no memory of why you opened chat in the first place beyond what is in that single message — used cold, /fix infers what is wrong with no stated concern at all, and it will reliably gravitate toward the most visible issue in the selection, which is very often a style inconsistency or an obvious inefficiency rather than the specific, less visible concern that actually prompted you to open the panel. Running /explain first and checking its answer against the stated concern before proceeding forces Copilot to demonstrate it has actually located the right problem before it is allowed anywhere near the code — the same diagnose-before-fix discipline that matters in any debugging workflow, made a hard gate here rather than a habit to remember. Feeding the concern explicitly into the /fix prompt, rather than trusting the model to carry it forward implicitly from the previous turn, matters because a slash command is close to a single-turn task invocation in how reliably it draws on the surrounding conversation — the visible chat history is there, but nothing guarantees the full nuance of an earlier explanation survives into how the next command interprets its own narrower instruction, so restating the concern explicitly at each step is cheap insurance against exactly that kind of drop. Chaining into /tests last and specifically rejecting happy-path-only output targets a well-documented pattern in AI-generated tests: a test suite generated from a fix, with no separate instruction about what it needs to probe, tends to mirror what the fixed code now does rather than actively hunting for the specific regression the fix was written to prevent, which means a suite that passes today can still miss the exact scenario that would catch this bug coming back after some unrelated future change. Keeping the selection itself narrow compounds all three of these effects, since a wider selection gives every step in the chain more surface area to drift toward something other than the stated concern, and drift compounds across three chained steps in a way it would not across one isolated command.

What you get back

Step 1 confirms calculateDiscount checks the expiry date correctly, but applies the discount to the cart total captured at validation time, not at checkout — the actual concern. Step 2's fix re-reads the cart total immediately before applying the discount instead of caching it from validation. Step 3 adds a test where the cart total changes between validation and checkout, alongside the existing valid- and expired-code cases.

Verified against

GitHub Copilot Chat Copilot Chat 1.270 (VS Code) · 2026-07-30

Changelog

  • 2026-07-30 Initial publish, verified against Copilot Chat 1.270 (VS Code) slash-command chaining.

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