r/ClaudeCode • u/Few-Divide1870 • 4d 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 4d 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.
33
u/ToughStreet8351 4d 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!
9
u/dsggut 4d ago
How about reading the code?
4
u/ShitShirtSteve 4d ago
Here’s a little secret, don’t tell anyone.
You can try your software yourself before you ship it.
3
u/Zorogozano 4d 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
3
u/FridgesArePeopleToo 4d ago
AI has turned everyone into idiots
3
u/daiaomori 4d 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/Readdeo 4d ago
Throw out all the output limiting skills and read the what it wrote for you.
2
u/that1cooldude 4d ago
You need to test it yourself.
2
u/bar_2k 4d ago
Mutation testing
2
u/dvduval 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d 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 4d ago
Red/Green TDD
1
u/JohnSane 4d ago
Adverserial reviewer agent.
1
u/joelaw9 4d ago
1
u/Fancy-Proof-9449 4d 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 4d ago
Change management ffs
1
u/kivanow 4d 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 4d 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 4d 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/Curik 3d ago
There's something called a diff of the changes. Crazy, I know..
1
u/Outrageous_Band9708 3d ago
why do you think it just patches its tests rather than fixing the issue?
this isn't a lazy intern. opsu55 is kinda cracked at QA shit.
how do you do this? you just fucking say so
1
u/Waste-Text-7625 3d ago
So you need to set rules to ensure developed tests actually test the desired outcomes. You need to look at that test code yourself. You need to ensure you have a full QC/QA process that you have a coordinator agent not involved in coding but only involved in coordination and following your plan and contracts. You have a separate QC agent responsible for providing code review on difs for each step or each phase. That thins are sent back to fresh coding leads for fixes. That the coordinator is involved in tracking that process. That there is a QA phase of your plan that checks to make sure all QC was properly done. Even then you need to be vigilant a out monitoring that process, looking at the QC reports and test results. Making sure QC does not just use synthetic tests but real code testing. I usually pair that with using glance or other tools when doing UI/UX work. You need to do your own QC and test the code and results.
1
u/EconomyDoctor3287 4d ago
have a different agent design the testing.
1
u/neuronexmachina 4d ago
Adversarial review from another provider's agent.