Skip to content
gajeshbhatPublic

About

Checks how well tests cover AI-written Python: CRAP scores, mutation testing and optional layer rules, with limits kept outside the repo. Supports, not replaces, code review.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

gauntlet

CI License: MIT

Do the tests your AI agent wrote check anything? gauntlet finds out, and the agent can't turn its checks off from the repo.

An agent can write code whose tests all pass and prove nothing. gauntlet runs your Python project's tests, plants small bugs to see whether the tests notice, and fails when risky code is poorly tested or could not be checked. It tells a reviewer where to look; it does not replace the review.

Use it

You need git and uv. In a git repository with at least one commit:

uv tool install git+https://github.com/gajeshbhat/gauntlet@v0.3.0
gauntlet run .                 # no config needed
gauntlet run . --changed main  # faster: only the functions that differ from main

Don't use uvx gauntlet: that is another project on PyPI. Coming from v0.2? See Upgrade.

A failing run says what to fix:

src/app/parse.py:12: parse CRAP 17.8 > 8 (complexity 5, coverage 20%)
src/app/grade.py:9: app.grade.x_grade__mutmut_5: survived [if score >= 80: -> if score > 80:]
mutation score 84.0% < 90%
src/app/api.py:30: create has 3 branches and no mutants

The second line is a planted bug no test noticed. The last is a function no bug could be planted in (here because it is decorated): move its logic into a plain function. If that can't help, allow it in your policy after review.

Exit codes: 0 passed, 1 a check failed, 2 gauntlet could not check. A run that exits 0 or 1 writes .gauntlet/EVIDENCE.md: the results, what was skipped, and what they do not prove.

Your tests run on your machine, in a copy of the repo, and are not isolated. For untrusted code, use an OpenShell sandbox.

In Claude Code

Needs Claude Code 2.1.275 or later.

/plugin install gauntlet --marketplace gajeshbhat/gauntlet
/gauntlet

What it checks

Check Fails when
CRAP score a function is too complex for how well it is tested: complexity² × (1 − coverage)³ + complexity is over 8
Mutation score the tests notice fewer than 90% of the planted bugs
Unmutated code a function has branches, but no bug could be planted in it
Pragmas code is hidden with # pragma: no mutate
Layers (optional) an inner layer imports an outer one, directly or through other modules

Why an agent can't turn it off from the repo

  • Your limits live outside the repo, in ~/.config/gauntlet/policy.toml. The repo can only make them stricter.
  • gauntlet supplies the settings for coverage.py, mutmut and the layer check. The repo's settings for them are ignored.
  • Results are judged as they are made. No old or outside report is read, and changing the source mid-run voids the run.
  • Checking nothing is never a pass.
  • Each known trick is a test: real projects that gauntlet must fail, next to ones it must pass.

It can't stop tests that forge their own results: they run in the same place as the tools. Other limits are in the security model.

How it compares

gauntlet builds on mutmut (mutation testing), coverage.py and grimp (the engine of import-linter). If you trust whoever edits your config, those tools on their own may be all you need. gauntlet is for when you don't.

Limits

  • Keep tests in a top-level tests/ folder. Elsewhere, they are checked like code.
  • Submodules and symlinks to folders are not supported.
  • It only supports Python, and can be slow: mutation testing reruns tests for each planted bug.
  • Projects that need their own mutmut or coverage settings (forkserver, gevent, coverage plugins) may score lower or exit 2.
  • mutmut can't plant bugs in most decorated functions, so web and command-line apps may need a max_unmutated budget.

Documentation

Guide · Architecture · Security model · Contributing

Credits

The idea comes from Robert C. Martin: surround the agent with strict constraints and make its work run a gauntlet. See his interview with Matt Pocock and this post. old-coder by AmazingAng applies it as an agent skill: gauntlet borrows its fail-closed checks, negative controls and evidence report. teeth inspired the check for unmutated code. No code or text comes from either.

License

MIT. Copyright © 2026 Gajesh Bhat.

About

Checks how well tests cover AI-written Python: CRAP scores, mutation testing and optional layer rules, with limits kept outside the repo. Supports, not replaces, code review.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages