$ recombobulate _
home / tips / ask-claude-to-explain-code-before-editing-it
102

Ask Claude to Explain Code Before Editing It

recombobulate @recombobulate · Mar 25, 2026 · Prompting
ask-claude-to-explain-code-before-editing-it

Before you let Claude modify a function you don't fully understand, ask it to explain the code first. This one habit prevents a surprising number of silent regressions.

Explain what the `processPayment` function does and list any edge cases 
it currently handles. Do not make any changes yet.

Claude will walk through the logic, call out side effects, and flag any assumptions baked into the code. Once you're aligned on what it actually does, you can give a much more precise instruction for what to change — and Claude won't have to guess at your intent.

The "do not make any changes yet" is key. Without it, Claude might start optimistically refactoring while explaining, which defeats the whole point.

# Step 1: understand
Explain what `calculateShipping` does and what assumptions it makes 
about the input data. Do not edit anything.

# Step 2: change with confidence
Now update it to also handle international addresses, keeping all 
existing domestic logic intact.

This pattern is especially valuable when working with code you inherited, code that hasn't been touched in years, or anything with unclear naming.

Understanding before editing is the difference between a surgical fix and an accidental rewrite.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
1
Talk Through a Problem with Claude Before Writing Any Code — Pair Programming Style

Before jumping to implementation, describe the problem conversationally and let Claude be your thinking partner. It asks clarifying questions, surfaces tradeoffs you haven't considered, suggests approaches, and pokes holes in your plan — so by the time you say "ok, build it," both of you know exactly what to build and why.

recombobulate @recombobulate · 1 month ago
0
Ask "Why Did This Fail?" Instead of "Fix This Error"

Paste error messages with "why did this fail?" instead of "fix this" to get Claude to diagnose the root cause before applying a fix.

recombobulate @recombobulate · 1 month ago
0
Use Negative Constraints to Tell Claude What NOT to Touch

When you need Claude to make changes in one area without affecting another, add negative constraints — "fix the bug but don't change the public API", "refactor the internals but don't create new files", or "update the logic but don't modify any tests." Explicit exclusions prevent Claude from making well-intentioned changes you'll have to undo.

recombobulate @recombobulate · 1 month ago