AI agent for software developers
Test Coverage Gap Closing Agent
Add tests to the riskiest untested code and prove that they catch real bugs
What it does
Coverage reports show a number but not which gaps matter. This agent runs the coverage tool, then ranks the untested code by risk: money, security, data changes and code that changed often. For the top items it drafts tests, runs them, and fixes tests that fail for the wrong reason, such as a missing setup or a wrong expected value. A passing test is not enough, so it then checks that each test catches a deliberate bug: it changes the code on purpose, confirms the test fails, then restores the code. Tests that do not notice the bug are rewritten. The developer approves committing the tests. Edge case: a test passes only because it mocks the function it is testing, so the agent rewrites it.
How it works
Follow the arrows from top to bottom. The orange dashed arrow is the loop: when a check fails, the agent goes back and tries again.
Read the steps as a list
- Weekly run or pre-release check
- Run the test suite with coverage
- Rank untested code by risk and change frequency
- Draft tests for the top items
- Run the new tests
- Do the tests pass for the right reason?If not: fix setup, expected values or mocks and run again. Back to step 4.
- Insert a deliberate bug and run the tests, then restore the code
- Does at least one test fail when the bug is inserted?If not: rewrite the test to assert the real behavior. Back to step 4.
- Developer approves committing the testsThe agent waits here for your OK.
- Coverage change report and committed tests
How it decides
It chooses code by risk and change frequency, and accepts a test only when it passes on correct code and fails when a bug is introduced.
- Rank code handling money, auth or data deletion first
- Rank files with the most commits in 90 days next
- Reject tests that mock the function under test
- Do not count a test until it fails on a deliberate bug
Make it yours
Every agent is a starting point. You choose these settings for your own situation.
- Risk rules and file priorities
- Test framework and style
- Number of tests per run (default 10)
- Coverage target
- Language and tools
What keeps you in control
It always asks you first
- Developer approves committing tests
- Developer approves any change to production code
Hard limits
- Never change production code to make tests pass
- Always restore code after a bug insertion
It stops when
- Done: top-risk code has tests that catch inserted bugs
- Stop: code cannot be tested without a refactor and is listed instead
Set it up
We guide you through the set-up, step by step
Members get the full set-up guide for this agent. No technical skills needed: you copy, paste and upload.
- One set of instructions to paste into your AI, with the clicks for ChatGPT, Claude, Microsoft 365 Copilot, Gemini and Grok
- The agent then walks you through connecting your own data, one source at a time
- A downloadable copy with the flow chart, the rules and the full guide