GitHub Copilot

Verified against GitHub Copilot Chat · 2026-07-15

Get an error explained in terms of your code, not a generic definition

/explain prompt for a terminal error or Problems-panel diagnostic that forces Copilot to trace the error to the specific line and state, instead of defining the error class in the abstract.

GitHub Copilot Chat (VS Code)GitHub Copilot Chat (JetBrains)

The prompt

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

/explain this error, but do not give me a generic definition of what this error class normally means — I need to know what is happening in this specific code.

ERROR
TypeError: undefined is not a function (evaluating 'cart.items.map')

WHEN IT HAPPENS
Happens only on the very first page load, before the cart has been fetched from the API.

RELEVANT CODE
The CartSummary component and the useCart() hook it calls, pasted below.

Answer in this order:
1. In one sentence, what value or state is wrong, named specifically, at the moment this error fires.
2. Why that value ended up wrong — trace it back one step, to where it was set, or where it should have been set and was not.
3. Whether this is a one-off input problem or a bug that will recur for any input matching the pattern in step 1.
4. Do not propose a fix unless I ask for one. I want to understand this first.
Customize the highlighted detailsoptional — the prompt above already works

Why this works

/explain is Copilot's built-in slash command for explaining a selection or a pasted error, but its default behavior for a common error type — a null reference, a type mismatch, an undefined is not a function — tends toward explaining what that class of error generally means in the language, because that is the more confident, more readily available answer without deep tracing into the specific code. That is genuinely useful to a beginner, but not to someone who already knows what a TypeError is and needs to know why this line hit one. Explicitly forbidding the generic definition and demanding the specific wrong value, named, forces it to actually use the pasted code rather than defaulting to a documentation-style answer. Asking it to trace back one step, to where the value was set, converts here's what a null reference is into here's the specific line that returned undefined. Separating diagnosis from fix, with fixes only on request, keeps the interaction from skipping past the step where you actually build a mental model of what went wrong — the difference between fixing an error and understanding it.

What you get back

1. cart.items is undefined at the moment CartSummary renders — not cart itself, cart.items specifically. 2. useCart() initializes cart as { items: null } until the fetch resolves, and CartSummary renders before that fetch completes on first load. 3. This will recur on every first page load for any user, not just an edge case — it is a race between initial render and the fetch, not a one-off bad input.

Verified against

GitHub Copilot Chat Copilot Chat 1.260 (VS Code) · 2026-07-15

Changelog

  • 2026-07-15 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
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