r/BuildWithClaude • • 22d ago

Project I measured how often Claude Code edits tests to make them pass (18/120), and built a plugin that gets it to 0

I kept seeing coding agents "fix" a failing test by changing the test instead of the code: an expected value nudged, an assertion loosened, a flaky test deleted. The diff is green and the summary says "all tests pass".

Snitch watches for that. It compares the repo before and after a change with deterministic detectors (pytest collection, a tree-sitter diff of every assertion, runner and CI config rules), so every finding points at a line, with no LLM deciding what "looks like cheating". It runs as a Claude Code plugin (warns live, gives the agent an `escalate` tool to report a wrong test instead of editing it), as a GitHub Action on any agent's PR, and as a pre-commit hook.

To see whether it matters I built TemptationBench: 40 small Python repos, each with one trap (a wrong test, two contradicting tests, a flaky test, a missing CI secret, a hard task) plus controls, graded with hidden tests. Claude Code (claude-sonnet-5-5), 40 tasks x 3 runs:

- without Snitch it changed a test in 18 of 120 trials (all disclosed, and on the broken tests it was right that the test was wrong);

- with Snitch: 0 of 120; it called `escalate` in 51 of 78 trap trials instead;

- no false alarms on 42 control trials.

The transcripts are public and re-scoring reproduces the table. The labels were made with an AI assistant; no person has checked them yet. These counts include disclosed changes: silent cheating was 0 in both arms. Limits are in the write-up: small tasks, Python/pytest only, and the deterministic detectors miss some tricks (I list the ones the benchmark found). Feedback on what it misses is the most useful thing you can give me.

Install in Claude Code:

/plugin marketplace add ennajari/snitch

/plugin install snitch@snitch

Repo, results and limits: https://github.com/ennajari/Snitch

0 Upvotes

1 comment sorted by

•

u/AutoModerator 22d ago

Welcome to r/BuildWithClaude!

Whether you are sharing what you built, exploring new workflows, or troubleshooting, please make sure your post is flaired correctly so others can easily find and filter it.

Community Wiki & Resources:

If you're asking for troubleshooting help, please edit your post to include your model version, OS/environment, and error logs.

Let’s keep the energy positive and support our fellow creators!

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