Manuals / AI Coding with Cursor / Chapter 7

B · Review & Test · intermediate · ~30 min · Chapter 7 of 11

Debugging with AI: paste errors, not vibes

When stuck, paste the exact error, the relevant code, and what you already tried. "It does not work" produces garbage.

Path progress
59%

Step 1 of 2

Error sandwich prompt

Error message + relevant code + expected behavior + what you tried.

Error sandwich promptDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Error sandwich prodrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

## Error
TypeError: Cannot read properties of undefined (reading 'map')
  at UserList.jsx:14

## Code (UserList.jsx lines 1-20)
[paste]

## Expected
List renders user names from API response

## Tried
- Added optional chaining on line 14
- Still fails on first render before data loads

Do this now

Take a real error from your terminal. Use the sandwich. Compare to "fix this."

Was this step clear?
Chapter learning outcomes
  • Error-driven debugging
  • Minimal repro
  • Iterative fix loops

Clear these before you leave

Side quest

Debug log

Log 3 bugs you fixed with AI. Note which prompt structure worked best.