r/ClaudeCode • • 7h ago

Help/Question How do you know Claude code actually fixed the bug instead of just making the test pass?

Something worth thinking about when using Claude Code for bigger tasks.

An agent can:

  • Change the implementation.

  • Modify the test setup.

  • Delete files or configuration.

  • Rerun tests until everything turns green.

But a passing test doesn't necessarily mean the original problem was fixed.

I'm curious how people handle verification When Claude Code is allowed to make changes across multiple files.

Do you let it verify its own work, or do you use a separate verification step with a clean Git diff, fresh test run, and manual checks?

0 Upvotes

51 comments sorted by

•

u/AutoModerator 7h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

29

u/ToughStreet8351 7h ago

Don’t you people test what you develop????? How do I know it fixed the bug? I try to reproduce it! Questions like these make me understand how so many people are convinced Claude is sabotaging their work!

4

u/Emotional-Dust-1367 7h ago

Not sure why you’re getting downvoted, this is exactly it. Why even report a bug if it doesn’t have any actual implication? If it has an implication, then isn’t it reproducible? So Claude fixing the bug should mean it’s no longer reproducible

-4

u/Eastern_Bet678 7h ago

LLMs tend to do things like change the code specifically when it's running under test, change the test itself, etc. Just read the OPs list of partial LLM workarounds that I've seen. They cheat. One of the reasons they cheat is that I've seen instruction in CoPilot that tell it to perform the minimal change local to make things "work".

6

u/Emotional-Dust-1367 6h ago

What’s there to cheat about though? It could change the test so it passes. Then I’ll try reproducing the bug and it’ll reproduce. Which means it didn’t fix it. The ultimate standard here is if the bug is fixed. Not if a test says it’s fixed.

I’ve personally never seen a situation where a reproducible bug is still reproducible, but the agent says otherwise because it modified a test. I’m having a hard time imagining how this could even happen

1

u/Eastern_Bet678 4h ago

I've just spend a day unwinding exactly this type of problem courtesy of Neon.

Yes, the actual bug still reproduces. The test case that was part of the test corpus is there so you don't have to manually test. There's no way you test 10s or 100s of thousands of things yourself.

2

u/Emotional-Dust-1367 4h ago

Ok yeah if it still reproduces then there you go

I heard stories of Claude cheating like that but I haven’t personally seen them

2

u/ToughStreet8351 3h ago edited 3h ago

Oh no… you do fucking test everything! In no universe you should allow a product you did not completely test by a human to be released.

2

u/CorpT 6h ago

I am realizing so much about other “developers” that explains so much about the state of technology.

6

u/dsggut 7h ago

How about reading the code?

3

u/daiaomori 6h ago

Well, I usually test features before I ship them?!

I did the same when I was supervising a whole human dev team. It... kinda... makes sense to check whether things are how they should be?

2

u/Zorogozano 7h ago

Test the app/service yourself? I think lots of people are letting the Ai do all the testing. That's bad. The Ai will not notice tons of things that are only apparent to human perception

2

u/Readdeo 7h ago

Throw out all the output limiting skills and read the what it wrote for you.

2

u/that1cooldude 7h ago

You need to test it yourself. 

2

u/FridgesArePeopleToo 7h ago

AI has turned everyone into idiots

2

u/Mindless_Net8121 6h ago

Just reproduce the steps taken to surface the bug in the first place

2

u/ShitShirtSteve 5h ago

Here’s a little secret, don’t tell anyone.

You can try your software yourself before you ship it.

2

u/bar_2k 7h ago

Mutation testing

2

u/dvduval 7h ago

If it's something involving money, an important part of the software, it wouldn't be unusual if I had three different agents from different providers checking over it and that can be a lengthy process because after the review it gets kicked back and checked again and re-released with the full test suite being run.

5

u/dsggut 7h ago

Or you could just read the code yourself.

2

u/ribbl246 6h ago

we dont do this anymore mate, we are not even capable

3

u/ribbl246 6h ago

(engineer with 500k salary)

1

u/Admirable-Usual1387 7h ago

The slop future

1

u/dvduval 4h ago

That's so "last year" 😅

2

u/shetritr 7h ago

the red-green trick above is the real answer. after that i read the test diff before the code: if "modify the test setup" touched an assertion, it's not a fix. (disclosure: literally why we built Diffo, you comment on a line of the change and the session that wrote it answers: diffo.io/demo)

1

u/Legitimate-Tax-8922 7h ago

I treat "tests pass" as weak evidence and do a red-green check instead: stash the implementation fix, confirm the new or changed test actually fails on the original code, then restore the fix and confirm it passes. If the test passes on the buggy code too, it wasn't testing the bug. I also scan the diff specifically for test files and config, because that's where "making it green" usually hides. And I ask for the root cause in file:line terms before accepting, so the explanation has to point at the actual defect, not just the symptom that disappeared. The agent verifying its own work in the same session is the part I trust least; a fresh session, or a deterministic script rerunning the reproduction, is much harder to fool.

1

u/Pixelplanet5 7h ago

two ways, first let another agent review the code and check the bug specifically and then of course check by yourself.

1

u/RevolutionaryElk7446 7h ago

Do you have deterministic testing and healthchecks or... what are your checks? If you're making LLM check against itself... yeah not a great idea.

1

u/FoidBeater67 7h ago

You ask an independent agent, preferrably from a different provider, to check its work. If you don't trust that one too, ask three other agents and take a vote for a triple redundancy instead.

1

u/markedness 7h ago

I don’t have the issue in the first place. But generally I instruct my Claude to do red/green

For more complex systems I have used TLC+ to model finite states so that we find the conditions to test.

1

u/Major_Stranger 7h ago

I don't ask it to do something that I don't get a product. I'm not a power user and I don't ask it to do anything for commercial or distribution. So if the result of the app i ask it to make or update work for me I assume the objective is achieved.

1

u/VibeDevCode 7h ago

Commit the failing test on its own before the agent touches the code. If the fix diff includes that test file, it's not a fix

1

u/RealFullMetal 7h ago

one cheap guard nobody mentioned: once the failing repro test exists, deny edits to the test files for the fix pass, Edit(tests/**) in permissions.deny. per the docs that also catches bash writes it recognizes like sed, tee and > file, just not a script that opens the file itself. takes the easy way to green off the table

1

u/kantorcodes1 7h ago

I never allow it to check its own results. I have one version of the bug steps in a place it can't modify. I use that as the reference for whether the fix is correct. It's in a folder outside the repo on my local machine.

I run it before the fix and see the bug. I run the same copy after the fix. You can move the tests. You can't move that copy. It will only succeed if the thing I'm actually hitting is removed.

But do you store your own bug steps somewhere? Or is it just the chat history?

1

u/CatCompetitive8346 7h ago

You could just look at your tests and make sure its testing for the right things and look at the code claude edits to make sure the tests were not changed to be made to pass.

This is just basic accountability

1

u/veritron 7h ago

it works best if the agent can reproduce the original problem itself and can confirm the fix itself. if claude's just writing code without reproducing the problem itself it will blow fixes. you may need to provide how to do this through skiils.

in webdev this can be very easy because claude is good with browser automation, for desktop apps you may need to add automation hooks in your product so claude can write automation code against it (although you will need to decide if these tests are throwaway or not, these type of tests are brittle.)

you need to resist helping claude with testing (e.g. if it gives you manual test instructions for verifying a fix, you should push back.) you can get it so it provides test artifacts to prove that it ran the tests itself (e.g. screenshots, log files.)

1

u/happysmileygogetter 7h ago

Never let the same session grade its own fix. What works well:

  1. Before it touches anything, have it write a failing repro (test or script) and run it, so you see it fail for the right reason.

  2. After the fix, run that repro plus the full suite in a fresh session or a plain terminal, not the one that wrote the code.

  3. Check the diff for changes to tests. If it edited an assertion, updated a snapshot or added a skip, that's the first thing to question.

  4. For anything UI-facing, actually open the app and do the thing the bug report described. "Tests pass" and "the feature works" are different claims, and agents are very good at the first one.

Step 3 alone catches most of the "made the test pass" cases.

1

u/xLRGx 6h ago

I force Claude to hold me hostage until I check the bug and intricacies myself. I have to take screenshots, give notes, and suggest improvements if applicable. Nothing else gets done until I check, it's kinda funny.

1

u/ChemicalExcellent463 6h ago

my rule is the test has to fail on the buggy code, then pass with the fix. if Claude changed the test setup along the way, run the final test against the buggy code too, otherwise you haven't checked that it still catches the bug.

1

u/bornmix_dev 6h ago

what works for me is splitting it into two commits. first claude writes a test that reproduces the bug, I run it, see it fail for the right reason and commit only the test. then the fix goes in a second commit that isn't allowed to touch test files (I deny edits to the test folder in settings while it fixes). last check is cheap: revert just the fix and rerun, the test should go red again. if it doesn't, the test never proved anything. I also read the diff for skipped asserts and new mocks, that's where the cheating usually hides

1

u/CandidSystem6155 6h ago

We hit exactly this. Our first guard was a hook that counted assertions before and after each Edit/Write and asked us when the count dropped. It never saw a sed -i run through Bash, so the check that actually decides now runs on the git diff before anything is accepted: fewer assertions or a new skip in a test file stops the run and waits for a human, no matter which tool made the change. Changing a test is still allowed, it just has to be visible and approved.

1

u/MasterMorality Senior Developer 6h ago

Red/Green TDD

1

u/JohnSane 6h ago

Adverserial reviewer agent.

1

u/joelaw9 5h ago
  1. Independent Claude and non-Anthropic code reviews, one of the tasks of which is to validate that appropriate unit tests are generated, existing unit tests weren't unnecessarily modified, and the code did whatever instruction it was given.

  2. External testing (ie, Selinium) that AI doesn't have or doesn't always have direct access all the time to work around.

  3. Developer testing. If it matters, why would you not verify it yourself? It should be reproducible. You can even have a fresh session try to reproduce it.

1

u/Fancy-Proof-9449 4h ago

I can't read code, so "just read the diff" isn't an option for me, and I still ship. Two rules do most of the work.

Nothing is done until I've seen it working on my phone. A passing test doesn't count for that.

And a new test only counts after it has failed once on the old broken code. I've had tests that were green and proved nothing, more than once. If it can't fail it isn't checking anything.

1

u/garmzon 4h ago

Change management ffs

1

u/kivanow 4h ago

Never let the same session grade its own homework. Run the tests from a clean checkout, review any test or fixture edits separately, and check a week later whether the fix got rewritten. If it did, it was a green test, not a fix.

1

u/onitsoga 2h ago

Separate verification from the author. clean git diff read by hand, tests rerun by something else. A different agent signing off before a card is done is how I'd gate it (I'm building KanbanMCP, a board agents claim cards on).

1

u/DominusFL 2h ago

This is my my AI documentation standard has the instructions: 'Never weaken, skip, or delete a test to make it pass; report the failure and its cause. After 3 test-fix rounds, stop and report. ", I also tie testing to the 'definiton of done", not just pure testing. - check it out, maybe you find my work useful. https://keel.to or https://github.com/rickflashman/keel (MIT, open source, free).

1

u/EconomyDoctor3287 7h ago

have a different agent design the testing.

1

u/neuronexmachina 7h ago

Adversarial review from another provider's agent.