| name | ensure-test-coverage |
| version | 1.1.0 |
| description | Ensure every code change ships with passing tests and ≥ 75% coverage before marking a task complete. Always use this skill when implementing a feature, fixing a bug, refactoring backend code, or about to mark any task done — even if the user doesn't ask for tests explicitly. |
| triggers | ["writing new code","modifying backend logic","before completing a task","implementing a feature","fixing a bug","refactoring"] |
| config | {"threshold":75,"service":"web","compose_file":"docker-compose.yml"} |
ensure-test-coverage
Purpose
No task is complete until the test suite passes and coverage is ≥ 75%. All commands run inside the web Docker service — never on the host.
Check container state first: docker compose ps --status running --services | grep -qx web
- Running →
docker compose exec web <command>
- Stopped →
docker compose run --rm web <command>
(<run> below means whichever form applies.)
Workflow
- Write or update tests alongside the implementation.
- Run:
docker compose <run> web pytest --cov --cov-report=term-missing
- Coverage ≥ 75% and all tests pass → done.
- Coverage < 75% → read the missing-lines report, add targeted tests, re-run. Repeat.
Commands
docker compose <run> web pytest --cov --cov-report=term-missing
docker compose <run> web pytest --cov --reuse-db
Rules
- Never run on the host. All pytest and coverage commands run inside the container.
- Never mark a task complete if coverage < 75%.
- Prefer real behavior over mocks. Mock only external I/O (HTTP, S3, email) — never the DB.
- Bug fixes → regression test first. Write a failing test reproducing the bug, then fix it.
- Follow project test layout. Place tests under
baseapp_<package>/tests/, using integration/ and unit/ when working on packages or apps/<app>/tests/integration/ or apps/<app>/tests/unit/ when working on a project or template. Use factories.py and fixtures.py.
- Both API surfaces need coverage. REST + GraphQL features both need tests.
- Don't over-test boilerplate. Skip
__str__, auto-generated migrations. Focus on logic, permissions, and edge cases.