mayurpise/draft/coverage
Claude Code and agent skill by mayurpise/draft
- community
Checking that the SKILL.md file is still in the repository.
Compute code coverage for active track or module. Targets 95%+ coverage with report and justification for uncovered lines. Complements TDD workflow.
Install
npx vskill@latest install mayurpise/draft/coverageSKILL.md
The same SKILL.md was published earlier as mayurpise/draft/coverage.
Coverage Report
You are computing and reporting code coverage for the active track or a specific module. This complements the TDD workflow — TDD is the process (write test, implement, refactor), coverage is the measurement (how much code do those tests exercise).
Red Flags - STOP if you're
- Reporting coverage without actually running the coverage tool
- Making up coverage percentages
- Skipping uncovered line analysis
- Not presenting the report for developer approval
- Treating this as a replacement for TDD (it's not — TDD stays in
/draft:implement)
Step 1: Load Context
- Read
draft/tech-stack.mdfor test framework and language info - Find active track from
draft/tracks.md - If track has
architecture.md(track-level) or project has.ai-context.md, identify current module for scoping - Look for
coverage_targetindraft/workflow.md. Check for per-module targets first (see Per-Module Coverage Enforcement below); if absent, default to 95%. - Check if
draft/tracks/<id>/bughunt-report-latest.md(track scope) ordraft/bughunt-report-latest.md(project scope) exists for cross-referencing (see Coverage-Bughunt Cross-Reference below)
If no active track and no argument provided:
- Tell user: "No active track. Provide a path or track ID, or run
/draft:new-trackfirst."
Step 2: Detect Coverage Tool
Preferred: use the deterministic detect-test-framework.sh wrapper — it emits JSON {languages:[{language,framework,runner_command,test_globs,config_file}]}. Resolve via the canonical tool resolver (see core/shared/tool-resolver.md):
If the script is unavailable or returns framework: unknown, fall back to the heuristic table below:
| Language | Coverage Tools | |
|---|---|---|
| JavaScript/TypeScript | jest --coverage, vitest --coverage, c8, nyc | |
| Python | pytest --cov, coverage run, coverage.py | |
| Go | go test -coverprofile=coverage.out | |
| Rust | cargo tarpaulin, cargo llvm-cov | |
| C/C++ | gcov, lcov | |
| Java/Kotlin | jacoco, gradle jacocoTestReport | |
| Ruby | simplecov |
Detection order (fallback path):
- Check
tech-stack.mdfor explicit testing section - Check config files (
jest.config.*,vitest.config.*,pytest.ini,setup.cfg,pyproject.toml,.nycrc) - Check
package.jsonscripts for coverage commands - If not detectable, ask the developer which tool and command to use
Step 3: Determine Scope
Priority order:
- If argument provided (path or module name): use as scope filter
- If track has
architecture.md(or project has.ai-context.md) with an in-progress module: scope to that module's files - If active track exists: scope to files changed in the track (use
git diffagainst base branch) - Fallback: run coverage for entire project
Build the coverage command with the appropriate scope/filter flags.
Step 4: Run Coverage
Preferred: invoke the normalized run-coverage.sh dispatcher — it dispatches to the language-specific runner and emits a normalized JSON {language,tool,total:{lines,branches},per_file:[{path,lines,branches,uncovered_lines}]}. This avoids per-language ad-hoc parsing in Step 5.
If the script is unavailable or returns tool: unsupported:
- Execute the coverage command. Request machine-readable output when possible:
--jsonfor Jest,--cov-report=jsonfor pytest,-coverprofilefor Go,--coverage-output-format jsonfor dotnet. - Capture full output
- If command fails:
- Check if dependencies are installed (test framework, coverage plugin)
- Suggest installation command
- Ask developer to fix and retry
Step 5: Parse and Present Report
Parse coverage output and present in a standardized format:
Step 6: Branch/Condition Coverage (Optional)
If the project's test framework supports branch/condition coverage (e.g., Istanbul, coverage.py branch mode), execute this step. Otherwise skip to Step 7.
Beyond line coverage, evaluate branch coverage for modules with complex conditional logic:
- When to apply: If the module contains nested conditionals, switch statements, or complex boolean expressions, line coverage alone is insufficient. 100% line coverage can miss untested branches in complex if/else/switch logic.
- Branch coverage measures whether every branch of every decision point has been exercised. Enable it with the appropriate flag:
- Jest/Vitest:
--coverage --coverageReporters=json-summary(branch data included by default) - pytest:
--cov --cov-branch - Go:
go test -covermode=count(counts execution per branch) - JaCoCo: branch coverage reported by default
- lcov/gcov:
--rc lcov_branch_coverage=1
- MC/DC (Modified Condition/Decision Coverage) — For safety-critical modules (auth, payments, crypto), recommend MC/DC analysis. MC/DC requires that each condition in a decision independently affects the outcome. This is the standard in DO-178C (avionics) and referenced in ISTQB Advanced Test Analyst syllabi.
- Present MC/DC gaps separately from standard branch coverage gaps
- Flag any boolean expression with 3+ conditions as an MC/DC candidate
Include branch coverage percentage in the report alongside line coverage when branch analysis is performed.
Step 7: Analyze Gaps
For files below target (using per-module targets when configured — see Per-Module Coverage Enforcement):
- Identify uncovered lines - List specific line ranges and what they contain
- Classify each gap:
- Testable - Can and should be covered. Suggest specific test to write.
- Defensive - Assertions, error handlers for impossible states. Acceptable to leave uncovered.
- Infrastructure - Framework boilerplate, main entry points. Usually acceptable.
- Legacy/Brownfield - Modules with 0% or very low coverage that need refactoring. Apply Characterization Testing (see below).
- Suggest tests for testable gaps:
```text SUGGESTED TESTS ─────────────────────────────────────────────────────────
- Test malformed JWT token handling (jwt.ts:45-52)
- Input: token with invalid signature
- Expected: throws AuthError with code INVALID_TOKEN
- Test expired token rejection (jwt.ts:60-65)
- Input: token with exp in the past
- Expected: throws AuthError with code TOKEN_EXPIRED
```
Step 7b: Characterization Testing (Brownfield/Legacy Code)
When encountering modules with 0% or very low coverage that need refactoring, do not attempt to write unit tests for untested legacy code directly. Instead, apply the Golden Master / Approval Testing approach (ref: Michael Feathers, "Working Effectively with Legacy Code"):
- Create Golden Master baselines — Generate fixed-seed inputs that exercise the module's public interface. Capture all outputs (return values, side effects, logs) as the approved baseline.
- Lock behavior with approval tests — Any change that alters the captured output triggers a test failure, making the current behavior explicit and protected.
- Refactor under Golden Master safety net — With approval tests guarding against regressions, refactor the module incrementally.
- Write proper unit tests via TDD during refactoring — As you extract and clarify logic, write focused unit tests using RED → GREEN → REFACTOR.
- Remove approval tests — Once proper unit test coverage meets the target, retire the Golden Master tests.
Tool references:
- ApprovalTests (<https://approvaltests.com/>) — available for Java, C#, Python, JS, and more
- Verify (.NET) — snapshot testing library
Present characterization testing recommendations in the gap analysis when applicable.
Step 7c: Mutation Testing Awareness
After measuring line coverage (and branch coverage if applicable), prompt the engineer to consider mutation testing for critical modules. Mutation testing introduces small code changes (mutants) into the source; if existing tests still pass, the mutant "survived," indicating weak test assertions even at high line coverage.
When to recommend: Modules at 90%+ line coverage that are high-risk (auth, payments, crypto, data persistence) or where past bugs have occurred. Mutation testing is most valuable when line coverage is already high but test quality is uncertain.
Mutation score = killed mutants / total non-equivalent mutants. Target: 80%+ for critical modules.
Tool recommendations by language:
| Language | Tool | Reference | |
|---|---|---|---|
| Java | PIT | <https://pitest.org/> | |
| JavaScript/TypeScript | Stryker | <https://stryker-mutator.io/> | |
| Python | mutmut | (Mutation testing tool) | |
| Rust | cargo-mutants | (Mutation testing tool) | |
| C# | Stryker.NET | <https://stryker-mutator.io/> | |
| Go | go-mutesting | (Mutation testing tool) |
Reference: Google's mutation testing program is used by 6,000+ engineers and processes approximately 30% of all code diffs, validating that mutation testing scales to large codebases.
Include mutation testing recommendations in the report when applicable, but do not block coverage completion on mutation analysis — it is advisory.
Step 7d: Coverage-Bughunt Cross-Reference
If a bughunt report exists (draft/tracks/<id>/bughunt-report-latest.md or draft/bughunt-report-latest.md):
- Parse bughunt findings — Extract file paths and line ranges of confirmed or suspected bugs.
- Cross-reference with uncovered code paths — Identify bughunt findings that fall in uncovered lines.
- Flag as highest-priority test gaps — Confirmed bugs in uncovered code are the most dangerous gaps. Present them prominently:
```text BUGHUNT CROSS-REFERENCE ───────────────────────────────────────────────────────── ⚠ CRITICAL: Bug "Race condition in session refresh" (bughunt #3) at src/auth/session.ts:112-118 — IN UNCOVERED CODE → Write a test that exposes this bug FIRST before fixing
⚠ HIGH: Bug "Missing null check on user lookup" (bughunt #7) at src/users/repository.ts:45 — IN UNCOVERED CODE → Write a regression test targeting this path ```
- Prioritize suggested tests — Tests that cover bughunt-flagged code should appear first in the SUGGESTED TESTS section.
Per-Module Coverage Enforcement
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/coverage/SKILL.md
Popularity
- Repository stars
- 39
- Repository forks
- 5
- 7-day trend score
- 18
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/mayurpise/draft/coverage)