DEV Community

Learn AI Resource
Learn AI Resource

Posted on

Use AI Like a Senior Engineer: Actually Fixing Bugs, Not Just Asking Questions

Use AI Like a Senior Engineer: Actually Fixing Bugs, Not Just Asking Questions

You're staring at a stack trace that makes no sense. Three console.logs in, still confused. So you copy-paste it into Claude and wait for an answer. Sometimes it works. Sometimes you get generic debugging advice you already knew.

Here's the thing: the devs who get the most from AI tools don't treat it like a search engine. They treat it like a senior engineer sitting next to them. Which means they do the prep work.

The Problem With Generic Debugging

When you dump a stack trace with zero context, you get zero-context answers. Claude might guess at what's happening, but it's flying blind. You get suggestions like "add console.logs" or "check your imports" — stuff you've probably done already.

The best debugging happens when you've already done 70% of the thinking.

How Senior Engineers Actually Debug

  1. Reproduce it consistently. Not "sometimes breaks." Exact steps.
  2. Narrow the scope. Is it the network? The parser? The database? One component or five?
  3. Check assumptions. Did the data actually load? Is the API returning what we think?
  4. Read the error. Not just the message — the stack trace, the context, what was happening before.

Then they ask smarter questions. Not "why is this broken?" but "I'm seeing X, expected Y, and here's what I've already tried."

Using AI for Real Debugging (With Examples)

Bad Approach:

My React form isn't updating. Help?

Error: 
TypeError: Cannot read property 'value' of null
Enter fullscreen mode Exit fullscreen mode

Claude gets: "Check if your ref is set up correctly."
You get: Frustrated.

Good Approach:

React form with controlled input. onChange updates state, form displays wrong value.

Here's my component:
[paste actual code]

When I type in the field:
- Input value changes visually
- React DevTools shows state DIDN'T update
- No errors in console

I've tried:
- Checked onChange is attached
- Logged the event object (it's there)
- Verified handleChange is defined in the class

What am I missing?
Enter fullscreen mode Exit fullscreen mode

Now Claude can see:

  • The actual code structure
  • What you've already eliminated
  • The specific disconnect between UI and state

Answers become specific. "Oh, you're binding the handler wrong" or "That's a closure issue" — actual solutions.

Real Example: API Race Condition

You've got a search input that fetches results. Sometimes you type fast, results come back in the wrong order.

Don't say: "My search is broken"

Say: "I fetch data in an onChange handler without canceling previous requests. When I type fast, response order doesn't match request order. I've tried [thing 1, thing 2]. Should I be using AbortController?"

Claude can now give you the exact pattern:

useEffect(() => {
  const controller = new AbortController();
  fetch(`/api/search?q=${query}`, { signal: controller.signal })
    .then(res => res.json())
    .then(setResults);

  return () => controller.abort(); // Cancel on cleanup
}, [query]);
Enter fullscreen mode Exit fullscreen mode

You didn't ask for it. You understood the problem first, then asked the smart question.

The Pattern

  1. Understand the symptom. Not "it's broken." What does broken actually look like?
  2. Narrow it down. Is it input, processing, or output?
  3. Show your work. Code + what you've tried.
  4. Ask specific questions. Not "fix this" but "does this pattern work for X?"

This works with every AI tool — Claude, Copilot, ChatGPT, whatever. The tool doesn't matter as much as the thinking.

Why This Matters

Senior engineers don't know everything. They're good at debugging because they isolate problems, eliminate assumptions, and ask answerable questions.

Using AI the same way doesn't make you dependent on it. It makes you sharper at the thing you're already supposed to do: actually understanding what's breaking.

Plus, the time you spend narrowing down a bug is never wasted. You learn your codebase better. You catch edge cases. You write better code next time.

Quick Checklist Before You Ask AI

  • [ ] Can I reproduce it consistently?
  • [ ] Have I narrowed the scope (component, function, data)?
  • [ ] Have I checked obvious stuff (typos, imports, bindings)?
  • [ ] Can I show a minimal example (or the actual code)?
  • [ ] Can I say specifically what I've already tried?
  • [ ] Am I asking a question, not just describing the problem?

If you hit all of those, Claude will give you answers that actually work.


More dev resources: Check out LearnAI Weekly for practical guides on AI tools, productivity hacks, and the kind of stuff that actually saves you time.

Top comments (0)