Skip to content

commandWorkflow

Debug Error

Finds the root cause of an error message or stack trace in your code, shows the evidence and proposes a minimal fix.

npx workspacetemplates add debug-error --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/debug-error.md15 lines · 1.2 KBFile
---
description: Finds the root cause of an error message or stack trace in your code, shows the evidence and proposes a minimal fix.
argument-hint: "<error message or stack trace>"
---

Debug this error: $ARGUMENTS

1. Read the message and trace. Ignore framework and library frames; find the first frame inside this repository and open that file around the line.
2. Search the repo for the exact message text to see where it is raised, and check recent changes to those files with `git log -n 5 --oneline -- <file>`.
3. Write down two or three hypotheses ranked by likelihood. For each, name a quick check: print a value, read a config, run a failing test, query a log.
4. Run the cheapest checks. Do not change code to test a theory unless you can revert it at once.
5. Identify the root cause. Distinguish the line that crashed from the line that put bad data in place.
6. Propose the smallest fix and a test that would have caught it.

Report: **Cause** (one sentence), **Evidence** (file:line and what you saw), **Fix** (diff), **Test**. If you cannot reproduce or confirm the cause, say which information is missing instead of guessing. Ask "Apply this fix?" before editing.

What it does

Pasting an error and getting a guess back wastes time. This command locates the frames in your own code, reads the surrounding logic and tests its theory before proposing a change.

It states what it checked, separates cause from symptom and asks before applying anything.

Example

you › /debug-error TypeError: Cannot read properties of undefined (reading 'id') at mapOrder (orders.js:41)

agent › Cause: getOrders returns null for guests, then mapOrder reads order.customer.id. Evidence: orders.js:33 returns early without an object. Fix: return an empty list there. Apply this fix?

Questions

What if it cannot reproduce the error?
It lists what it checked and asks for the missing input, such as a request payload or log line.
Will it edit code while investigating?
Only temporary probes it can revert. The real fix waits for your approval.
  • Estimate Task

    CommandWorkflow

    Free
  • Explain Code

    CommandWorkflow

    Free
  • Plan Feature

    CommandWorkflow

    Free
  • Reproduce Bug

    CommandWorkflow

    Free