r/ClaudeCode • u/Few-Divide1870 • 4h 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
•
u/AutoModerator 4h 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.
26
u/ToughStreet8351 4h 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!
5
u/dsggut 3h ago
How about reading the code?
3
u/daiaomori 3h 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 4h 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 4h ago
Throw out all the output limiting skills and read the what it wrote for you.
2
u/that1cooldude 4h ago
You need to test it yourself.
2
u/FridgesArePeopleToo 3h ago
AI has turned everyone into idiots
2
u/Mindless_Net8121 3h ago
Just reproduce the steps taken to surface the bug in the first place
2
u/ShitShirtSteve 1h ago
Here’s a little secret, don’t tell anyone.
You can try your software yourself before you ship it.
2
u/bar_2k 4h ago
Mutation testing
2
u/dvduval 4h 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.
2
u/shetritr 4h 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 4h 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 4h 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 4h 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 4h 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 4h 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 4h 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 4h 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 4h 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 likesed,teeand> file, just not a script that opens the file itself. takes the easy way to green off the table1
u/kantorcodes1 3h 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 3h 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 3h 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 3h ago
Never let the same session grade its own fix. What works well:
Step 3 alone catches most of the "made the test pass" cases.
1
u/xLRGx 3h 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 3h 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 3h 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 3h 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 3h ago
Red/Green TDD
1
u/JohnSane 2h ago
Adverserial reviewer agent.
1
u/joelaw9 1h ago
1
u/Fancy-Proof-9449 1h 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 1h ago
Change management ffs
1
u/kivanow 1h 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/EconomyDoctor3287 4h ago
have a different agent design the testing.
1
u/neuronexmachina 4h ago
Adversarial review from another provider's agent.