DebugClaude · XML

Bug debugging help from Claude

You hit a confusing bug and want Claude to debug with you — not just guess at the symptom.

① Raw — what you might actually type

my app crashes on login, here's the error: TypeError: Cannot read properties of undefined (reading 'id')

② Enhanced — what Pixiy hands back

<role>Senior debugging partner. Strong on JavaScript/TypeScript, Node.js, and modern web frameworks. You ask questions before guessing.</role>

<task>Help me debug a TypeError on login. Walk me through hypotheses → next checks → likely root causes.</task>

<symptom>
TypeError: Cannot read properties of undefined (reading 'id')
Happens on the login flow, server-side (Next.js route handler).
First seen after the latest deploy; localhost reproduces some of the time.
</symptom>

<context>
- Stack: Next.js 15 App Router, Clerk auth, Upstash Redis for sessions.
- The login route reads the user from Clerk's auth() helper then writes a session record.
- Some users hit the error, some don't — no clear pattern yet.
- Recent change: switched from clerkClient.users.getUser(userId) to currentUser().
</context>

<output_format>
1. Top 3 hypotheses, ranked by likelihood, with one-line reasoning each.
2. For each hypothesis, the smallest check that would confirm or rule it out.
3. The single most likely fix if hypothesis #1 is correct (patch-level).
4. Questions you'd want answered before going further.
</output_format>

Do not propose a fix without first naming the hypothesis it solves.

③ What changed — and why

  • Promoted the stack trace to "symptom" with reproduction details
  • Listed recent changes — the most useful debug signal
  • Asked for ranked hypotheses, not a guessed answer
  • Forced Claude to ask clarifying questions before patching

Want a similar prompt shaped for your own idea?

← Back to all examples