Test Coverage Loop

Adds meaningful tests pass after pass until the suite reaches a target coverage threshold and stays green.

WorkflowengineeringMIT1 source files

Before you use this component

This is a third-party source bundle, not an installation into your account. UI Discovery has checked the available redistribution license evidence; runtime behavior has not been tested. Review all files, use a disposable project first, and do not enable scripts or hooks until you understand their permissions.

Some integrations require separately installed software, API keys or paid services. Credentials and subscriptions are not included. These are Claude Code resources; other clients may require adaptation.

Extract the ZIP into a temporary folder, inspect its entry file and supporting resources, then follow the original instructions. Do not overwrite an existing project configuration blindly. Keep the bundled license and attribution notices.

Source publisher
Claude Code Templates
Creator supplied by source
Not listed in source
Pinned source version
a344359459263d73d8948651c789244093c02e4e
License evidence
LICENSE

Source preview

cli-tool/components/loops/engineering/test-coverage-loop.md

---
name: test-coverage-loop
description: Adds meaningful tests pass after pass until the suite reaches a target coverage threshold and stays green.
category: engineering
interval: 20m
stop-condition: Coverage meets or exceeds the target (e.g. 90%) with all tests passing and no flaky additions.
components: [agent:performance-testing/test-automator, command:testing/test-coverage, command:testing/generate-tests]
tags: [testing, coverage, quality, loop]
---

# Test Coverage Loop

> **Loop Engineering** — a recurring goal that drives the agent to grow real test coverage incrementally instead of in one risky batch.

## 🎯 Goal
Raise test coverage toward a defined target by adding **meaningful** tests for the least-covered, highest-risk code first — never gaming the metric with empty assertions.

## ⏱️ Schedule
Suggested interval: `20m`.

## ▶️ Run it
```
/loop 20m "Measure current test coverage. Pick the lowest-covered, highest-risk module and add real, behavior-focused tests for it. Re-run the suite. Continue until coverage is at least 90% with everything passing."
```

## 🔁 Iteration steps
1. **Perceive** — run the coverage report and rank uncovered code by risk.
2. **Reason** — identify branches, error paths and edge cases that lack tests.
3. **Plan** — choose one module/area to cover this pass.
4. **Act** — generate tests with `test-automator` + `/generate-tests`.
5. **Observe** — re-run `/test-coverage`; if the suite is green and coverage rose, continue; if flaky, fix before moving on.

## 🛑 Stopping condition
Coverage ≥ target, full suite passes, and no newly-added test is flaky.

## 🧩 Referenced components
- `agent:performance-testing/test-automator` — authors the tests.
- `command:testing/test-coverage` — measures progress each pass.
- `command:testing/generate-tests` — scaffolds new test cases.

## 💡 Example
Starting at 61%, the loop targets the untested error branches of the payment module first, climbing a few points per pass until it crosses 90% with a green suite.

Preview capped at 60,000 characters. Download the bundle for every original file and notice.

Read the redistribution license
MIT License

Copyright (c) 2025 Daniel (San) Ávila

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Bundle SHA-256: 6e0f8c081d991c61f32e6d24486126916fd9e51fdc3a827fc2648b944b2229b0. Files are served as downloads and are never executed by this page.