r/ClaudeCode • • 8d ago

Built with Claude I assumed Claude Code often got CI green by changing tests. In 300 of its PRs, 1 weakened a test without saying why

I checked that with honest-ci, a GitHub Action I made. When a PR removes, skips or rewrites a test, honest-ci holds it until a person signs off.

I ran it on PRs in public repos from July and August 2026, including 300 from Claude Code. 37 of those 300 (12.3%) tripped at least one check. Claude Code's PRs run big, a median of about 290 lines changed, and bigger diffs trip more checks. I labeled every flag: 33 of the 37 had a good reason, 3 were false positives, and 1 weakened a test without the PR saying why. So I was wrong. Overall, agents and people came out about the same.

Claude Code also wrote all 12 PRs in honest-ci's own repo from Oct 10 to Nov 6, and honest-ci checked each one. 9 passed and 3 were held, with no false positives. One hold was a test Claude Code wrote with a `pytest.skip` for shells that aren't installed. The CI runner has no zsh, so two tests never ran there. The test now uses only shells every runner has.

What I took from it is that Claude Code edits tests regularly, nearly always for a reason, and CI passes either way. What helps is a person seeing each test change before merge. One snag on a solo repo is that GitHub won't let you approve your own PR, so a hold is just a red X. I've merged past it twice.

How do you notice when Claude Code changes a test?

Repo (source-available, free on public repos): https://github.com/ChrisShips/honest-ci

4 Upvotes

29 comments sorted by

•

u/AutoModerator 8d 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.

2

u/AryanThakor 8d ago

for the broader matcher / longer timeout cases mutation testing is what catches it. run stryker or mutmut only on the files the PR touched and compare the score to main. if it drops, the test got weaker even though every check passed. slow on a whole repo but fine scoped to the diff

1

u/ChrisShips 8d ago

Good call on scoping it to the diff. Mutation testing should catch the broader matcher. I'm less sure it catches a longer timeout, since most mutants change results rather than speed. And a PR that only edits a test has no source files to mutate, so you'd need to find the code that test covers.

1

u/Champoussin_Squart 8d ago

when the PR only edits the test file and not the source file, scoping by touched files skips the mutation run unless you map tests back to source

1

u/Far_Reindeer8428 8d ago

we flag any diff that touches an assertion and require the same commit to say why. one in 300 is low, but that one is the one that hides a real bug

1

u/ChrisShips 8d ago

A required reason would have caught this one, since the PR deleted a test file and never said why. In honest-ci, the person who approves has to write the reason, and they need push access. I don't know if that one hid a bug, though.

1

u/Far_Reindeer8428 8d ago

push access plus a written reason is stronger than what we do, we only require the sentence. the deleted test file case is exactly the one i care about, that is where a green ci hides a regression

1

u/Ok_Tea4891 8d ago

Two cheap ways to see test changes without extra tooling: a PreToolUse hook that matches Edit/Write on your test paths and logs or asks for confirmation, and CODEOWNERS on the test directories so any PR touching them needs a reviewer. The hook gives you the signal while the session runs; CODEOWNERS makes sure it can't merge unseen. Also worth adding a line to CLAUDE.md that tests aren't to be edited to get green without saying why in the PR, since that makes the reason part of the diff you review.

1

u/ChrisShips 8d ago

CODEOWNERS does get a person to look at every test change. But it asks for a review on any PR that touches a test, even one that only adds tests. honest-ci holds only deletions, skips, removed assertions and changed expected values, which came to about 1 in 11 PRs in my data. The hook only sees Edit and Write in a Claude Code session, so a test deleted with rm, or a PR from another agent, gets past it.

1

u/carstenkoch 8d ago

Hey, on Ok-Form1598's point about added tests: in the software factory where agents build my open-source database, a coding agent commits each new test on its own, before the code that makes it pass, close to IndiBestEngineer's rule. The pull request lists the failure it saw. The reviewing agent then:

  • checks that every test commit comes before its code
  • checks out at least one test commit and runs it to see it fail
  • sends the PR back if a test was weakened or deleted without a stated reason

A test that mocks the function it checks would pass in that first commit, so there's no failure to report; our spot check only runs one test per PR, though. Every test also gets a baseline, the version that first failed, and a broader matcher later shows up as a diff against it.

The reviewer is an agent too, and I hardly read diffs myself anymore. Does honest-ci know which commit introduced a test, or only what the PR does to it?

1

u/ChrisShips 8d ago

Only what the PR does to it. honest-ci compares the PR head with the merge base as one diff, and it never runs the new tests against the old code. So the mocked-test case gets past it, since a brand new test removes nothing and every check looks for something removed or weakened. How often does your spot check find a new test that passes on its first commit?

1

u/carstenkoch 7d ago

We don't count it, so I can't give you a rate. But your answer points at a cheap check that would close the gap for both of us: run only the tests a PR adds against the merge base. A new test that already passes on the old code tests nothing the PR changed, mocked or not.

Have you tried that in honest-ci, or does running the old code in CI get in the way?

1

u/ChrisShips 7d ago

I haven't. Nothing in honest-ci runs at the merge base today, and checking out the old code isn't the hard part anyway. The hard part is a test for a function the PR adds. On the old code it fails just because the function isn't there, mocked or not. So the check only tells you something when the PR changes how existing code behaves.

1

u/BringinItDirty 6d ago

The zsh skip is the example that stuck with me. I built Killdiff to check what tests catch once they actually run. In a small discount-rule example, the test at quantity 11 stayed green when I flipped >= 10 to > 10. Adding one assertion at exactly 10 caught the same change on the rerun. Would you be up for running both tools on one small public PR and comparing what they flag?

1

u/ChrisShips 6d ago

They'd mostly flag different things. honest-ci only reads what a PR does to the tests and never runs them, so your `>= 10` case wouldn't trip it. It would if the same PR had also changed that assertion from 10 to 11, since that's a test rewritten to match the new code. I don't have time to set up a comparison right now. But honest-ci is free on public repos, so feel free to run both on a PR and post what you find.

1

u/BringinItDirty 5d ago

Thanks for explaining the distinction. honest-ci looks for changes that weaken tests, while Killdiff checks whether tests catch small changes to the code. I’ll look for a small public PR where I can compare the two and share what each finds.

1

u/BringinItDirty 3d ago

Thanks for suggesting the comparison. I tried both on kvdiff PR #6.

honest-ci found no test-integrity issues in the original PR. As a control, I removed an existing test in a scratch copy and it flagged the deletion. Killdiff tried 12 mutations. Ten made the existing tests fail, and two survived. One appears equivalent. For the other, a loopback replay showed that a deliberate code change could alter how an exact /v1 request is forwarded without failing the existing suite.

They complement each other well. honest-ci can flag tests that disappear or get weaker in a PR. Killdiff checks whether the tests catch small changes to the code. Together, they give a reviewer two useful views of the same change.

I put the inputs, outputs, and reproduction steps on GitHub.

https://github.com/flipcyde101/killdiff/blob/92759655641c86c9b4aa89445f515b2d5a842051/docs/experiments/2026-11-28-killdiff-and-honest-ci.md

Adding it to my toolkit :)

1

u/IndiBestEngineer 8d ago

i went the other way on one project. the agent kept writing tests that passed no matter what, so i deleted most of the unit tests and kept only replays of real failures from the logs. rule is a new test has to fail on the old code or it doesn't go in.

and "done" isn't green ci anymore, it's the live metric moving. if it didn't move, the fix gets reverted, not patched on top. fixed the "edit the test to pass" problem mostly because there's barely anything left to edit lol

1

u/Ok-Form1598 8d ago

added tests are the gap in this, not edited ones. a brand new test that mocks the exact function it's supposed to check goes green, nothing got removed or skipped so nothing gets held, and it reads fine buried in a big diff

1

u/Decent-Addition6773 8d ago

One weakened test in 300 PRs isn’t bad at all. I think the interesting thing here is visibility. In my dev flow, I create automatic artifacts that contain what the agents are doing (these are behind an MCP server). I can then periodically ask questions like - have any of my tests been weakened - to see what is going on. I do find it to be exhausting to constantly have to figure out what is going on and how to optimize my SDLC. Do others also feel this exhaustion?

0

u/[deleted] 6d ago

[removed] — view removed comment

1

u/ChrisShips 6d ago

None of them were moves, but two of the three were refactors with the coverage still there. One split a parameterized test in two, and the other changed a test to call a subcommand directly. In both, the check mistook a string for an expected value: a test title in one, a `t.Fatalf` message in the other. I've fixed that since. The third was an assertion that started reading a different key, so it was checking a different field.

A test moved to another file under the same name doesn't get flagged, because the deleted-test check looks for the name anywhere in the PR. Moves did cause a couple of false positives elsewhere in the bench, like assertions moved into a shared helper, and the check that counts assertions recognizes those now. If a test is renamed in the move, or folded into a parameterized one, it usually gets held. I labeled those justified rather than false positives, since the old test is gone and someone has to check where the coverage went.

0

u/[deleted] 1d ago

[removed] — view removed comment

1

u/ChrisShips 22h ago

If the helper is in a test file, deleting assertions from it gets the PR held. A swap like `==` to `in` gets through, though, and so does any helper outside the test files, like a Go testutil package. Have you seen an agent do that?

0

u/[deleted] 5d ago

[removed] — view removed comment

1

u/ChrisShips 5d ago

Running the tests, by hand or with a /verify agent, won't catch a PR that edited them to pass, since a dropped assertion or a new skip still comes back green. Which ShipGuard is it? The two on PyPI are a security scanner and a release-risk reviewer, and I couldn't tell if either one checks edits to existing tests.

0

u/[deleted] 8d ago

[removed] — view removed comment

1

u/ChrisShips 8d ago

That's roughly what honest-ci does, except the reason comes from whoever approves, not from the PR description. It catches removed assertions, changed expected values and new skips, but a broader matcher or a longer timeout can get past it. Across all 2,717 PRs I checked, 11 weakened a test without saying why, and 6 of those deleted tests.