Verified against GitHub Copilot Chat · 2026-07-22
Chain Copilot's /explain, /fix, and /tests instead of running one cold
A three-step slash-command sequence for the Copilot Chat panel that gets a real explanation, a fix scoped to the actual concern, and matching tests out of one selection — in an order that makes each step check the last.
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 Copilot Chat, and run these three slash commands in order, treating each answer as input to the next rather than three unrelated questions. 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 Read the explanation before moving on. If it does not mention whether expired discount codes are rejected correctly when the cart total changes after the code was applied at all, ask a direct follow-up naming it before proceeding to step 2. STEP 2 — /fix Ask: /fix address whether expired discount codes are rejected correctly when the cart total changes after the code was applied specifically. Do not change anything the step 1 explanation described as working correctly. Check the proposed fix against the step 1 explanation — it should map directly onto the concern, not introduce an unrelated change. STEP 3 — /tests Ask: /tests 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, plus the existing passing behavior confirmed in step 1. Reject the /tests output if it only re-tests the happy path already covered — ask explicitly for the case covering whether expired discount codes are rejected correctly when the cart total changes after the code was applied if it is missing.
Customize the highlighted detailsoptional — the prompt above already works
Why this works
/explain, /fix, and /tests are Copilot Chat's built-in slash commands, each scoped to a fixed task against the current selection — used in isolation, each one starts from a blank slate. Running /fix cold on a selection means Copilot infers what is wrong with no stated concern, and it will often fix the most visible style issue rather than the one you actually opened chat about. Running /explain first, and requiring the answer to name the real concern before proceeding, forces Copilot to demonstrate it has located the right problem before it is allowed to touch the code — the same diagnose-before-fix discipline that matters in any debugging prompt. Feeding the concern explicitly into the /fix command, rather than trusting the model to carry it forward implicitly from the earlier turn, matters because slash commands are effectively single-turn task invocations and do not reliably preserve the full nuance of a prior explanation. Chaining into /tests last, and explicitly rejecting happy-path-only output, catches the well-documented pattern of AI-generated tests mirroring what the code does rather than probing the specific regression risk the session was actually about.
What you get back
Step 1 /explain output confirms calculateDiscount checks code.expiresAt against Date.now() at call time, so it does correctly reject an expired code — but it applies the discount to the cart total at the time the code was validated, not the total at checkout, which is the actual concern. Step 2 /fix re-reads the cart total immediately before applying the discount rather than caching it from validation. Step 3 /tests adds a case where the cart total changes between validation and checkout, alongside the existing valid-code and expired-code cases.
Verified against
GitHub Copilot Chat Copilot Chat 1.260 (VS Code) · 2026-07-22
Changelog
- 2026-07-22 — Initial publish, verified against Copilot Chat 1.260 (VS Code).
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

