Best for
- What tests should I write next? — ranked by risk and impact
- Which uncovered code is risky vs. trivial? — CRAP scores separate the two
- Why has coverage plateaued? — identify the files blocking further gains
dotnet/skills/plugins/dotnet-test/skills/coverage-analysis/SKILL.md
Project-wide code coverage and CRAP (Change Risk Anti-Patterns) score analysis for .NET projects. Calculates CRAP scores per method and surfaces risk hotspots — complex code with low coverage that is dangerous to modify. Use to diagnose why coverage is stuck or plateaued, identify what methods block improvement, or get project-wide coverage analysis with risk ranking. USE FOR: coverage stuck, coverage plateau, can't increase coverage, what's blocking coverage, coverage gap, CRAP scores, risk hot
Decision brief
Project-wide code coverage and CRAP (Change Risk Anti-Patterns) score analysis for . NET projects.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/dotnet/skills --skill "plugins/dotnet-test/skills/coverage-analysis"Inspect the Agent Skill "coverage-analysis" from https://github.com/dotnet/skills/blob/805a42a675a47f14fdd77a54aa474fcb8e499b9e/plugins/dotnet-test/skills/coverage-analysis/SKILL.md at commit 805a42a675a47f14fdd77a54aa474fcb8e499b9e. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
MANDATORY: deliver the final assistant response with the CRAP/risk-hotspot summary BEFORE any optional work. As soon as Compute-CrapScores.ps1 and Extract-MethodCoverage.ps1 return data, your next assistant response must contain the user-facing analysis (CRAP table, blocking met…
Read references/setup-discovery.md and run the probes it contains, in order:
Run only when Phase 1 found no Cobertura XML. If the user already has coverage data, skip directly to Phase 3 — do not read this section's reference file, and do not re-run the suite.
Run the two bundled PowerShell scripts. Both are cheap and complete in seconds. Do not install or invoke ReportGenerator here — that belongs in optional Phase 5, after the user-facing summary has been delivered.
Run scripts/Compute-CrapScores.ps1 (co-located with this SKILL.md). It reads all Cobertura XML files, applies CRAP(m) = comp² × (1 − cov)³ + comp per method, and returns the top-N hotspots as JSON.
Permission review
The documentation asks the agent to create, modify, or delete local files.
| 2. Create the output directory | `COVERAGE_DIR` | Skill-owned `TestResults/coverage-analysis/`; never deletes user-supplied reports |The documentation asks the agent to read local files, directories, or repositories.
Run only when Phase 1 found no Cobertura XML. If the user already has coverage data, skip directly to Phase 3 — do not read this section's reference file, and do not re-run the suite.The documentation asks the agent to create, modify, or delete local files.
Attempt to save the same content to `TestResults/coverage-analysis/coverage-analysis.md` before delivering the response (use the editor's create/edit tool — do not shell out). If the file write fails, still deliver the summary and note the Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 93/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 4,922 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Raw coverage percentages answer "what code was executed?" — they don't answer what you actually need to know:
This skill bridges that gap: from a bare .NET solution to a prioritized risk hotspot list, with no manual tool configuration required.
Use this skill when the user mentions test coverage, coverage gaps, code risk, CRAP scores, where to add tests, why coverage plateaued, or wants to know which code is safest to refactor — even if they don't explicitly say "coverage analysis".
crap-score skill insteaddotnet test with coverage collection directly| Input | Required | Default | Description |
|---|---|---|---|
| Project/solution path | No | Current directory | Path to the .NET solution or project |
| Line coverage threshold | No | 80% | Minimum acceptable line coverage |
| Branch coverage threshold | No | 70% | Minimum acceptable branch coverage |
| CRAP threshold | No | 30 | Maximum acceptable CRAP score before flagging |
| Top N hotspots | No | 10 | Number of risk hotspots to surface |
dotnet on PATH)dotnet add package coverlet.collector (or Microsoft.Testing.Extensions.CodeCoverage) when a test project has no coverage provider yet. Skip when the user supplies an existing Cobertura XML.dotnet tool install (ReportGenerator). Core CRAP/coverage analysis works from Cobertura XML alone — ReportGenerator only adds HTML/CSV reports as an optional post-summary extra.The skill auto-detects coverage provider state per test project and selects the least-invasive execution strategy:
No pre-existing runsettings files or manually installed tools required.
MANDATORY: deliver the final assistant response with the CRAP/risk-hotspot summary BEFORE any optional work. As soon as
Compute-CrapScores.ps1andExtract-MethodCoverage.ps1return data, your next assistant response must contain the user-facing analysis (CRAP table, blocking methods, recommendations). Do not run ReportGenerator (Phase 5), do not install global tools, and do not start any heavy parallel work before that response is delivered. The user is judged on the final assistant message, not on side-effect files.If a phase fails, times out, or budget is running low, skip remaining optional work and immediately return a partial summary containing: (1) what was found in the Cobertura XML, (2) any CRAP/risk-hotspot data already extracted, (3) which methods are blocking coverage, and (4) failures encountered.
If the user provides a path to existing Cobertura XML (or coverage data is already present in TestResults/), skip Phase 2 entirely (no test execution) and skip Phase 5 by default (no ReportGenerator install or HTML report) — go directly from Phase 3 (analysis scripts) to Phase 4 (user-facing summary). Only run Phase 5 if the user explicitly asks for HTML/CSV reports. The Risk Hotspots table and CRAP scores are mandatory in every output — they are the skill's core value-add over raw coverage numbers.
The workflow runs in five phases. Phases 1–4 are required; Phase 5 (ReportGenerator HTML/CSV reports) is strictly optional and runs after the user-facing summary has been delivered. Do not parallelize Phase 5 with earlier phases — the heavy dotnet tool install for ReportGenerator can crash the session before Phase 4 completes.
Read references/setup-discovery.md and run the probes it contains, in order:
| Step | Emits | Why it matters |
|---|---|---|
| 1. Locate the solution or project | ENTRY_TYPE, ENTRY, TEST_PROJECTS, TEST_OUTPUT_ROOT | Entry point for dotnet test and where skill outputs are written |
| 2. Create the output directory | COVERAGE_DIR | Skill-owned TestResults/coverage-analysis/; never deletes user-supplied reports |
| 2b. Discover or accept existing Cobertura XML | EXISTING_COBERTURA_COUNT, EXISTING_COBERTURA | A user-supplied path always wins; otherwise probe TestResults/ |
2c. Recommend ignoring TestResults/ | GITIGNORE_RECOMMENDATION | One-line recommendation, reported in the summary |
Branching after Phase 1:
EXISTING_COBERTURA_COUNT > 0 → skip Phase 2 entirely; go to Phase 3 with those paths. Do not read references/test-execution.md.EXISTING_COBERTURA_COUNT == 0 and test projects were found → run Phase 2.ENTRY_TYPE:NotFound with test projects → use the test projects directly as entry points.No test projects found (expected projects with 'Test' or 'Spec' in the name), and no existing Cobertura XML was provided. Add a test project or provide a Cobertura file path.Run only when Phase 1 found no Cobertura XML. If the user already has coverage data, skip directly to Phase 3 — do not read this section's reference file, and do not re-run the suite.
Read references/test-execution.md. It covers provider detection (Microsoft.Testing.Extensions.CodeCoverage vs coverlet.collector), adding a provider to projects that have none, the dotnet test command for each provider and SDK version, mixed-provider solutions, exit-code handling, and locating the generated reports.
Exit codes: 0 all passed; 1 some tests failed (coverage is still collected — proceed with a warning); anything else is a build failure — stop and report it.
Run the two bundled PowerShell scripts. Both are cheap and complete in seconds. Do not install or invoke ReportGenerator here — that belongs in optional Phase 5, after the user-facing summary has been delivered.
Run scripts/Compute-CrapScores.ps1 (co-located with this SKILL.md). It reads all Cobertura XML files, applies CRAP(m) = comp² × (1 − cov)³ + comp per method, and returns the top-N hotspots as JSON.
To locate the script: find the directory containing this skill's SKILL.md file (the skill loader provides this context), then resolve scripts/Compute-CrapScores.ps1 relative to it. If the script path cannot be determined, calculate CRAP scores inline using the formula below.
& "<skill-directory>/scripts/Compute-CrapScores.ps1" `
-CoberturaPath @(<all COBERTURA file paths as array>) `
-CrapThreshold <crap_threshold> `
-TopN <top_n>
Script outputs: OVERALL_LINE_COVERAGE:<n>, OVERALL_BRANCH_COVERAGE:<n> (aggregated project-wide rates across all provided Cobertura files), TOTAL_METHODS:<n>, FLAGGED_METHODS:<n>, HOTSPOTS:<json> (top-N sorted by CrapScore descending). The OVERALL_* values are exactly what the Phase 4 summary needs for the "Line Coverage" / "Branch Coverage" rows — no separate XML parsing tool call is required.
Run scripts/Extract-MethodCoverage.ps1 to get per-method coverage data for the Coverage Gaps table:
& "<skill-directory>/scripts/Extract-MethodCoverage.ps1" `
-CoberturaPath @(<all COBERTURA file paths as array>) `
-CoverageThreshold <line_threshold> `
-BranchThreshold <branch_threshold> `
-Filter below-threshold
Script outputs: JSON array of methods below the coverage threshold, sorted by coverage ascending. Use this data to populate the Coverage Gaps by File table in the report.
As soon as Phase 3 completes, your immediately next assistant response must contain the user-facing analysis — do not interleave any other tool calls before it. This is the response the user (and any judge) sees. Skipping or deferring this in favor of Phase 5 (ReportGenerator) is a hard failure.
The response must include, at minimum:
OVERALL_LINE_COVERAGE: / OVERALL_BRANCH_COVERAGE: lines emitted by Compute-CrapScores.ps1 (no extra Cobertura parsing required)Compute-CrapScores.ps1 HOTSPOTS: output (CRAP scores, complexity, coverage)Every number must come from the script output, and the arithmetic must reconcile. Uncovered lines attributed to individual members must not exceed the project's total uncovered lines, and the coverage you project after a recommendation must follow from those counts.
List every member below threshold, not just the worst one. Extract-MethodCoverage.ps1 returns the full below-threshold set: name the others even if briefly. Only say "the rest is fine / leave it alone" when that set is otherwise empty — claiming one method is the entire gap when the extractor found more is a factual error.
Use references/output-format.md verbatim for fixed headings, table structures, symbols, and emoji. Use references/guidelines.md for prioritization rules and style.
If Phase 5 has not yet run when you compose this summary, mark the ## 📁 Reports section's HTML/Text/CSV/GitHub-markdown rows as Not generated (optional — request HTML reports to enable). Only the coverage-analysis.md and raw Cobertura paths are guaranteed to exist.
Attempt to save the same content to TestResults/coverage-analysis/coverage-analysis.md before delivering the response (use the editor's create/edit tool — do not shell out). If the file write fails, still deliver the summary and note the file-write failure explicitly.
Phase 5 is strictly optional and runs only after Phase 4 has been delivered. Skip Phase 5 entirely when:
Run Phase 5 only when the user explicitly asks for HTML/CSV reports, or when the project flow requires them (e.g., a CI artifact upload step).
Read references/report-generation.md for the ReportGenerator install and invocation. It is the only heavy step in this skill: a dotnet tool install that can exhaust the session budget, which is why it never runs before the Phase 4 summary has been delivered.
If the install fails (no internet), leave the existing Phase 4 summary as the final output and note that HTML reports were skipped. Do not retry or block on it.
coverage.cobertura.xml file was generated after dotnet test (or already exists when the user supplied one)TestResults/coverage-analysis/coverage-analysis.md was written and contains datacomp² × (1 − cov)³ + comp — a method with 100% coverage should have CRAP = complexityTestResults/coverage-analysis/reports/index.html exists; otherwise the report file should mark HTML/Text/CSV rows as Not generateddotnet add package fails (offline/proxy), coverage collection silently produces nothing. Check for .coverage binary files as a fallback indicator.dotnet tool install can crash the session or exhaust budget, leaving the user with no analysis even though the CRAP scores were already computed.dotnet tool install fails (no internet) during Phase 5, leave the existing Phase 4 summary as the final output and note that HTML reports were skipped. Do not retry or block on the install.Extract-MethodCoverage.ps1 first; naming a single blocker while other uncovered members exist misdirects the user's next test.Alternatives
ruvnet/ruflo
Agent skill for hierarchical-coordinator - invoke with $agent-hierarchical-coordinator
alirezarezvani/claude-skills
Use when the user asks to review pull requests, analyze code changes, check for security issues in PRs, or assess code quality of diffs.
ruvnet/ruflo
Agent skill for workflow-automation - invoke with $agent-workflow-automation
alirezarezvani/claude-skills
Use when planning, funding, scoping, or synthesizing enterprise research across workstreams — clinical study design, R&D program finance, market sizing/surveys, or product/user research. Triggers on "design this clinical study", "what sample size", "R&D budget", "burn rate", "capitalize or expense", "TAM SAM SOM", "market sizing", "survey design", "segment the market", "plan user interviews", "usability test", "synthesize research insights". Forks context to route to one of four Research-Operati