Most developers debug after the fact. Something breaks, they trace it back, fix it, move on. That cycle is expensive. Not just in time, but in focus. Every context switch to fix a bug is a context switch away from building.
I stopped doing it that way. Now I debug the logic before the code exists. Claude is how I do that.
The Problem With Writing First
When you sit down and start writing code immediately, you're committing to an interpretation of the problem. You've made a hundred small assumptions without realizing it. The data shape, the flow order, the edge cases, the failure states. None of that got validated. You just started building.
Then something breaks at step four because step two had a flawed assumption. And now you're not debugging a bug. You're untangling a web of decisions made while you were in motion.
The fix isn't better code. It's a better thinking process before you write any.
What I Actually Do Instead
Before I open Cursor, before I write a function, I describe what I'm building to Claude like I'm explaining it to a smart engineer who's never seen my codebase. No code. Just logic.
Here's the format I use:
- What this thing is supposed to do
- What it receives as input
- What it should return or trigger as output
- The sequence of steps I think it'll take
- Where I think it might break
That last one matters most. If I can't name where it might break, I don't understand it well enough to build it yet.
Claude's job in this conversation isn't to write code. It's to poke holes. I explicitly tell it: don't write code yet, just find the problems in this logic.
What Comes Back Is Almost Always Useful
Usually Claude catches one of three things:
A sequence problem. I've got step three depending on something step three can't have yet. Classic async assumption error. Or I'm mutating something before I've verified it exists.
A missing state. I described the happy path. Claude asks what happens when the input is empty, or when the API returns a 200 with an error payload, or when the user hits the endpoint twice before the first call resolves.
A scope creep flag. Sometimes I describe something that's actually three things pretending to be one. Claude will surface that. "This sounds like two separate concerns, do you want them coupled?" That question alone has saved me from building tangled functions I'd have to refactor later.
