Coverage Analysis
.NET (Microsoft)OfficialPublished by .NET (Microsoft)
- Skill
- Review and audit
- Software development
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Coverage Analysis provides diagnostic insights into .NET test coverage evidence. It interprets line, branch, and condition metrics from existing Cobertura reports or collects them on demand. The skill focuses on reconciling coverage totals, identifying specific code blocks that hinder progress, and performing risk-based analysis using CRAP (Change Risk Anti-Patterns) scores when explicitly requested. It is designed to provide actionable feedback without requiring manual tool installation or redundant test execution.
What it does
- Interprets .NET line, branch, and condition coverage metrics.
- Reconciles coverage totals and identifies specific blocking members.
- Computes project-wide CRAP scores to identify high-risk hotspots.
- Assesses refactoring safety based on complexity and coverage data.
- Calculates projected coverage improvements for specific code targets.
- Generates structured reports only upon explicit user request.
When to use it
- You have existing Cobertura coverage reports and need to understand the gaps.
- You need to determine if a specific refactoring task is safe based on current coverage.
- You want to identify high-risk code areas (hotspots) that require better test coverage.
- You need to calculate how much coverage will increase by testing specific methods.
- You are stuck on a coverage plateau and need to know which files or methods are blocking progress.
Advantages
- Directly analyzes existing reports without rerunning tests.
- Provides objective risk assessment using the CRAP metric.
- Avoids unnecessary tool installation or environment modification.
- Offers clear, prioritized recommendations for improving test coverage.
- Maintains a lightweight footprint by avoiding full reports unless requested.
Usage examples
- “Analyze my Cobertura report at ./coverage/results.xml and tell me why my branch coverage is stuck at 60%.”
- The agent parses the XML, identifies the specific methods or branches causing the plateau, and provides a summary of the uncovered logic with recommendations.
- “Which methods in my project are the most dangerous to refactor based on coverage and complexity?”
- The agent calculates CRAP scores for the project, identifies the top 3 high-risk hotspots, and suggests where to add tests to improve safety.
- “If I add tests for the PaymentProcessor class, what will my total line coverage be?”
- The agent calculates the projected coverage increase by assuming full coverage of the specified class and provides the new estimated total.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/dotnet/coverage-analysis/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip coverage-analysis.zip -d .agents/skills
Documentation by .NET (Microsoft)
Coverage Analysis
Purpose
Explain what .NET coverage evidence proves, reconcile target arithmetic, and identify the code blocking progress. Add complexity/CRAP ranking only when the user explicitly asks for risk hotspots, CRAP, priorities by risk, or refactoring safety.
When to Use
Use this skill for interpreting supplied .NET line/branch/condition evidence, coverage gaps and plateaus, target arithmetic, or explicit project-wide coverage-backed risk analysis.
When Not to Use
Named method, class, or file CRAP/refactoring-safety analysis — use the
crap-scoreskill insteadStatic source-to-test pairing or listing files with no tests — use
find-untested-sourcesBehavioral or pseudo-mutation gaps in existing tests — use
test-gap-analysisTest trait/category distributions or coverage shape by test type — use
test-taggingWriting or generating tests — this skill identifies where tests are needed, not write them
General test execution unrelated to coverage or CRAP analysis
Only collecting .NET coverage or printing a raw percentage with no diagnosis — use
run-tests; use native tooling for non-.NET coverage collection or analysis. Interpreting .NET line/branch gaps remains in scope here
Inputs
| 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 |
| Existing Cobertura path | No | Discover only if not supplied | Preferred input; never rerun tests when usable |
| CRAP threshold | No | 30 | Used only for explicit risk/CRAP requests |
| Hotspot count | No | 3 | Explicit risk requests only; cap at 10 unless the user asks for more |
Discover optional inputs from the workspace. Do not ask for a project path when the current directory or a supplied report is sufficient.
Choose the smallest matching path
| User intent | Required work | Do not do |
|---|---|---|
| Explain a supplied excerpt, condition, or summary | Answer directly from the supplied evidence | Tools, CRAP, discovery, report files |
| Interpret a supplied Cobertura path or diagnose a plateau | Read that report, reconcile totals, name all material gaps, answer directly | Rerun tests, install tools, compute CRAP, or generate files unless explicitly requested |
| Rank risk hotspots, compute project-wide CRAP, or assess refactoring safety | Use the supplied/existing report, read references/guidelines.md, and compute CRAP before ranking | Coverage-only ranking or a full report template unless requested |
| Analyze coverage when no report exists | Invoke run-tests to collect coverage with the repository-compatible runner, then analyze the generated report | Choose or execute a test command independently; CRAP unless risk was requested |
| Produce a full markdown/HTML/CSV report | First deliver the direct answer; then read references/output-format.md or references/report-generation.md | Report generation before the answer |
Words such as analyze coverage, what is blocking coverage, or why is coverage stuck do not by themselves request CRAP. Explicit signals include risk hotspot, CRAP, complexity-weighted priority, safe to refactor, or an equivalent request to combine complexity with coverage.
Existing-data fast path
When the user supplies a coverage excerpt, summary, or valid Cobertura path:
Treat it as authoritative input and start there.
Do not discover the solution or test projects unless source mapping is necessary.
Do not run
dotnet test, install ReportGenerator, add a coverage package, or readreferences/setup-discovery.mdorreferences/report-generation.md.Do not write
coverage-analysis.mdor create a report directory unless the user requested a saved/full report.For interpretation and plateau questions, parse only the evidence needed to answer. For explicit project-wide risk requests, use the bundled scripts as described in
references/guidelines.md.
A failed read/view operation is not proof that a named path does not exist. Classify the failure, then make one targeted existence probe and use a normalized path or alternate reader only for confirmed tool availability, transport, or path-normalization failures and only after verifying the canonical path remains inside the workspace. Stop on content-exclusion, permission/policy, workspace-boundary, or unknown failures. Report a missing path only when the independent probe also fails; do not broaden the search or substitute another artifact.
Collection path
Use this path only when no usable coverage evidence exists and the user asked for analysis that requires it.
Read
references/setup-discovery.md.Prefer existing Cobertura discovered under the requested root.
If none exists, invoke
run-testsfor repository overlay, platform, runner, and command selection, and have it collect Cobertura once per entry point.Analyze the resulting Cobertura. Compute CRAP only if risk analysis was explicitly requested.
When the workspace contains the project/test manifests needed by this path,
perform discovery directly and delegate collection to run-tests. Do not ask
the user to attach files or pre-run coverage that the current workspace lets
you inspect and generate.
Do not modify production code. Any incidental test-project change needed for
collection is owned by run-tests; include that change and its revert command
in the final analysis.
The automatic collection path is for SDK-style projects. For classic non-SDK or
packages.config projects, use only a repository-owned coverage command. If none
exists, stop and request Cobertura XML. Never migrate the project, inject an
SDK-style provider, create a wrapper project, or report substitute coverage from
another assembly.
Interpretation and arithmetic invariants
A line hit proves execution, not both decision outcomes.
condition-coverage="50% (1/2)"proves one reported outcome ran, but not which one. Recommend forcing the opposite outcome. Without source, never invent likely predicates or claim whether true or false is missing. State that compound predicates need independently exercised operands and short-circuit combinations when applicable; do not infer the exact combinations without source or fuller XML.Derive overall totals from Cobertura's covered/valid line counts. For target
T, required covered lines areceiling(valid lines × T).Projected coverage is
(current covered lines + newly covered distinct lines) / valid lines. State assumptions such as fully covering a method.When asked whether one member can reach a target, show its maximum projected total and at least one concrete sufficient combination of supplied members or line gains. If no supplied combination is sufficient, say so.
For a multi-member target, name the exact combination and resulting covered / valid total; saying only "combine it with another member" is incomplete.
Reconcile member gaps against project totals. Method line ranges can overlap or omit class-level lines, so do not sum method counts as project truth.
Never call one member the sole, entire, or all remaining gap unless its distinct uncovered lines exactly reconcile with the project total and no other below-threshold member remains.
Name every supplied or extracted below-threshold member, but keep detail proportional: lead with the blockers, summarize the remainder in one sentence or a compact table.
Response contract
Answer the user's question in the first 2–4 sentences.
Excerpt or arithmetic question: one explanation plus the next test or member priority. No dashboard.
Existing-report interpretation or plateau: overall line/branch coverage, blocking members, reconciled target impact, and 1–3 recommendations. Use at most one compact table.
Explicit risk/CRAP request: top 3 actual hotspots by default, supporting complexity/coverage/CRAP values, remaining flagged count, and 1–3 priorities. Exclude fully covered low-risk methods from the hotspot table. Never exceed 10 rows unless the user requests a larger count. For refactoring safety, rank risky methods by CRAP rather than raw coverage alone, then name comparatively safe well-covered methods separately.
Explicit full report request: read
references/output-format.md. Save the report only then.
Report only artifacts that exist. Do not announce inaccessible output paths or failed optional file writes when no file was requested.
Optional reports
HTML/CSV/markdown files are not part of normal analysis. Generate them only when the user explicitly requests report files or a CI artifact.
Deliver the direct coverage/risk answer first.
For a full markdown report, read
references/output-format.mdand save it.For HTML/CSV, then read
references/report-generation.md. Do not install ReportGenerator before the direct answer, and do not retry a failed install.
Validation
Confirm a supplied report was used without test execution or tool installation.
Reconcile covered, valid, and uncovered line totals before projecting impact.
Confirm every stated blocker comes from supplied or extracted evidence.
If CRAP was requested, spot-check one score using
references/guidelines.md.If files were requested, verify they exist before reporting their paths.
Common Pitfalls
Existing report triggers setup work — stop. Analyze the named artifact first.
Generic analysis triggers CRAP — stop. CRAP requires explicit risk intent.
One method is called the entire gap — reconcile distinct uncovered lines and the full below-threshold set first.
A small request gets a dashboard — scale down to a direct answer or one table.
No Cobertura from collection — report the collection failure; do not invent substitute coverage.
Compiler-generated method names — verify suspicious async, lambda, or local function names against source before presenting them as user-authored members.
Test exit code 1 — coverage may still exist; proceed with a warning. Other nonzero build failures stop the collection path.
Files
- ATTRIBUTION.mdAdded by AutoGineer845 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md11.1 KiB
- references/guidelines.md2.6 KiB
- references/output-format.md4.1 KiB
- references/report-generation.md2.0 KiB
- references/setup-discovery.md15.0 KiB
- scripts/Compute-CrapScores.ps1Script4.3 KiB
- scripts/CoverageData.ps1Script14.4 KiB
- scripts/Extract-MethodCoverage.ps1Script3.6 KiB
scripts/Extract-MethodCoverage.ps1
<#
.SYNOPSIS
Extract Cobertura method coverage without inventing missing measurements.
.DESCRIPTION
Legacy output is a JSON array; diagnostics and summaries go to stderr.
Use -OutputFormat json-v1 for provenance, null/unknown metrics and branch bounds.
Merging is scoped to reported module/file/class/signature identities, not an
attestation of source revision. Duplicate report bytes are idempotent.
Exit codes: 0 complete, 2 invalid input, 3 incomplete/unrepresentable evidence.
#>
param(
[Parameter(Mandatory=$true)][string[]]$CoberturaPath,
[ValidateRange(0,100)][int]$CoverageThreshold = 80,
[ValidateRange(0,100)][int]$BranchThreshold = 70,
[ValidateSet('uncovered', 'below-threshold', 'all')][string]$Filter = 'all',
[ValidateSet('legacy', 'json-v1')][string]$OutputFormat = 'legacy'
)
try {
. "$PSScriptRoot\CoverageData.ps1"
} catch {
$diagnostic = @{ code = 'DEPENDENCY_UNAVAILABLE'; severity = 'error'; message = $_.Exception.Message; path = "$PSScriptRoot\CoverageData.ps1" }
[Console]::Error.WriteLine("$($diagnostic.code): $($diagnostic.message)")
if ($OutputFormat -eq 'json-v1') {
@{
schema_version = '1'; tool = 'Extract-MethodCoverage'; tool_version = '1.0'; status = 'error'
scope = @{}; inputs = @(); diagnostics = @($diagnostic); data = @{}
} | ConvertTo-Json -Depth 5
}
exit 2
}
$scope = @{ identity = 'reported-module-file-class-signature'; source_revision = $null; filter = $Filter }
try {
$coverage = Get-CoverageData $CoberturaPath
} catch {
$diagnostics = @([pscustomobject]@{ code = 'INVALID_INPUT'; severity = 'error'; message = $_.Exception.Message })
Write-CoverageDiagnostics $diagnostics
if ($OutputFormat -eq 'json-v1') { Write-CoverageJson 'Extract-MethodCoverage' 'error' $scope @() $diagnostics @{} }
exit 2
}
$partial = -not $coverage.Methods.Count -or @($coverage.Methods | Where-Object {
$_.LineCoverageStatus -eq 'unknown' -or $_.BranchCoverageStatus -in @('unknown', 'bounded') -or $_.ComplexityStatus -eq 'unknown'
}).Count -gt 0
$methods = @($coverage.Methods | Where-Object {
if ($Filter -eq 'all') { return $true }
if ($_.LineCoverageStatus -eq 'unknown' -or $_.BranchCoverageStatus -in @('unknown', 'bounded')) { return $true }
if ($Filter -eq 'uncovered') { return $_.LineCoverage -eq 0 }
return (100.0 * $_.CoveredLines / $_.TotalLines) -lt $CoverageThreshold -or
($_.TotalBranches -gt 0 -and (100.0 * $_.CoveredBranches / $_.TotalBranches) -lt $BranchThreshold)
} | Sort-Object -Property @{Expression='UncoveredLines';Descending=$true}, @{Expression='LineCoverage';Descending=$false}, Class, Method, File, Signature)
Write-CoverageDiagnostics $coverage.Diagnostics
if ($OutputFormat -eq 'json-v1') {
Write-CoverageJson 'Extract-MethodCoverage' $(if ($partial) { 'partial' } else { 'complete' }) $scope $coverage.Inputs $coverage.Diagnostics @{
methods = $methods; summary = $coverage.Summary
}
} elseif (-not $partial) {
$legacy = @($methods | Select-Object Class, Method, Signature, File, Complexity, LineCoverage,
@{Name='BranchCoverage';Expression={if ($_.BranchCoverageStatus -eq 'not-applicable') { 0 } else { $_.BranchCoverage }}},
CoveredLines, TotalLines, UncoveredLines, CoveredBranches, TotalBranches)
ConvertTo-Json -InputObject $legacy -Depth 5
[Console]::Error.WriteLine("METHODS_FILTERED:$($methods.Count)")
[Console]::Error.WriteLine("UNCOVERED_METHODS:$(@($methods | Where-Object { $_.LineCoverageStatus -eq 'exact' -and $_.LineCoverage -eq 0 }).Count)")
}
if ($partial) { exit 3 }
exit 0
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- .NET (Microsoft)
- Publisher
- .NET (Microsoft) (Official)
- Source
- dotnet/skills · plugins/dotnet-test/skills/coverage-analysis · commit 96c3d68
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by .NET (Microsoft) or .NET (Microsoft).
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download coverage-analysis.zip