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-score skill instead
- Static source-to-test pairing or listing files with no tests — use
find-untested-sources
- Behavioral or pseudo-mutation gaps in existing tests — use
test-gap-analysis
- Test trait/category distributions or coverage shape by test type — use
test-tagging
- Writing 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
read references/setup-discovery.md or references/report-generation.md.
- Do not write
coverage-analysis.md or 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-tests for 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 are ceiling(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.md and 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.
1---2name: coverage-analysis3description: >4 Activation requires either supplied .NET coverage reports/percentages/line,5 branch, or condition metrics, or an explicit request to collect .NET coverage6 for analysis. USE FOR: interpreting that evidence, including Cobertura data,7 partial conditions, plateaus, target arithmetic,8 project-wide coverage-backed CRAP, and coverage-backed refactoring safety.9 Analyze supplied reports directly without rerunning tests or installing10 tools. DO NOT USE FOR: requests with neither coverage evidence nor explicit11 coverage-collection intent, including hypothetical change-survival questions12 (use test-gap-analysis); CRAP or refactoring safety for one named target (use13 crap-score); or requests owned by test-tagging, find-untested-sources,14 test-anti-patterns, run-tests, or code-testing.15license: MIT16metadata:17 source: https://skillmd.com/skills/managedcode/coverage-analysis18---1920# Coverage Analysis2122## Purpose2324Explain what .NET coverage evidence proves, reconcile target arithmetic, and25identify the code blocking progress. Add complexity/CRAP ranking only when the26user explicitly asks for risk hotspots, CRAP, priorities by risk, or refactoring27safety.2829## When to Use3031Use this skill for interpreting supplied .NET line/branch/condition evidence,32coverage gaps and plateaus, target arithmetic, or explicit project-wide33coverage-backed risk analysis.3435## When Not to Use3637- **Named method, class, or file CRAP/refactoring-safety analysis** — use the `crap-score` skill instead38- **Static source-to-test pairing or listing files with no tests** — use `find-untested-sources`39- **Behavioral or pseudo-mutation gaps in existing tests** — use `test-gap-analysis`40- **Test trait/category distributions or coverage shape by test type** — use `test-tagging`41- **Writing or generating tests** — this skill identifies where tests are needed, not write them42- **General test execution** unrelated to coverage or CRAP analysis43- **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 here4445## Inputs4647| Input | Required | Default | Description |48|-------|----------|---------|-------------|49| Project/solution path | No | Current directory | Path to the .NET solution or project |50| Line coverage threshold | No | 80% | Minimum acceptable line coverage |51| Branch coverage threshold | No | 70% | Minimum acceptable branch coverage |52| Existing Cobertura path | No | Discover only if not supplied | Preferred input; never rerun tests when usable |53| CRAP threshold | No | 30 | Used only for explicit risk/CRAP requests |54| Hotspot count | No | 3 | Explicit risk requests only; cap at 10 unless the user asks for more |5556Discover optional inputs from the workspace. Do not ask for a project path when57the current directory or a supplied report is sufficient.5859## Choose the smallest matching path6061| User intent | Required work | Do not do |62|-------------|---------------|-----------|63| Explain a supplied excerpt, condition, or summary | Answer directly from the supplied evidence | Tools, CRAP, discovery, report files |64| 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 |65| 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 |66| 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 |67| 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 |6869Words such as **analyze coverage**, **what is blocking coverage**, or **why is70coverage stuck** do not by themselves request CRAP. Explicit signals include71**risk hotspot**, **CRAP**, **complexity-weighted priority**, **safe to refactor**,72or an equivalent request to combine complexity with coverage.7374## Existing-data fast path7576When the user supplies a coverage excerpt, summary, or valid Cobertura path:7778- Treat it as authoritative input and start there.79- Do not discover the solution or test projects unless source mapping is necessary.80- Do not run `dotnet test`, install ReportGenerator, add a coverage package, or81 read `references/setup-discovery.md` or `references/report-generation.md`.82- Do not write `coverage-analysis.md` or create a report directory unless the user83 requested a saved/full report.84- For interpretation and plateau questions, parse only the evidence needed to85 answer. For explicit project-wide risk requests, use the bundled scripts as86 described in `references/guidelines.md`.8788A failed read/view operation is not proof that a named path does not exist.89Classify the failure, then make one targeted existence probe and use a normalized90path or alternate reader only for confirmed tool availability, transport, or91path-normalization failures and only after verifying the canonical path remains92inside the workspace. Stop on content-exclusion, permission/policy,93workspace-boundary, or unknown failures. Report a missing path only when the94independent probe also fails; do not broaden the search or substitute another95artifact.9697## Collection path9899Use this path only when no usable coverage evidence exists and the user asked for100analysis that requires it.1011021. Read `references/setup-discovery.md`.1032. Prefer existing Cobertura discovered under the requested root.1043. If none exists, invoke `run-tests` for repository overlay, platform, runner,105 and command selection, and have it collect Cobertura once per entry point.1064. Analyze the resulting Cobertura. Compute CRAP only if risk analysis was107 explicitly requested.108109When the workspace contains the project/test manifests needed by this path,110perform discovery directly and delegate collection to `run-tests`. Do not ask111the user to attach files or pre-run coverage that the current workspace lets112you inspect and generate.113114Do not modify production code. Any incidental test-project change needed for115collection is owned by `run-tests`; include that change and its revert command116in the final analysis.117118The automatic collection path is for SDK-style projects. For classic non-SDK or119`packages.config` projects, use only a repository-owned coverage command. If none120exists, stop and request Cobertura XML. Never migrate the project, inject an121SDK-style provider, create a wrapper project, or report substitute coverage from122another assembly.123124## Interpretation and arithmetic invariants125126- A line hit proves execution, not both decision outcomes.127- `condition-coverage="50% (1/2)"` proves one reported outcome ran, but not which128 one. Recommend forcing the opposite outcome. Without source, never invent likely129 predicates or claim whether true or false is missing. State that compound130 predicates need independently exercised operands and short-circuit combinations131 when applicable; do not infer the exact combinations without source or fuller XML.132- Derive overall totals from Cobertura's covered/valid line counts. For target133 `T`, required covered lines are `ceiling(valid lines × T)`.134- Projected coverage is `(current covered lines + newly covered distinct lines) /135 valid lines`. State assumptions such as fully covering a method.136- When asked whether one member can reach a target, show its maximum projected137 total and at least one concrete sufficient combination of supplied members or138 line gains. If no supplied combination is sufficient, say so.139- For a multi-member target, name the exact combination and resulting covered /140 valid total; saying only "combine it with another member" is incomplete.141- Reconcile member gaps against project totals. Method line ranges can overlap or142 omit class-level lines, so do not sum method counts as project truth.143- Never call one member the **sole**, **entire**, or **all** remaining gap unless144 its distinct uncovered lines exactly reconcile with the project total and no145 other below-threshold member remains.146- Name every supplied or extracted below-threshold member, but keep detail147 proportional: lead with the blockers, summarize the remainder in one sentence148 or a compact table.149150## Response contract151152Answer the user's question in the first 2–4 sentences.153154- **Excerpt or arithmetic question:** one explanation plus the next test or member155 priority. No dashboard.156- **Existing-report interpretation or plateau:** overall line/branch coverage,157 blocking members, reconciled target impact, and 1–3 recommendations. Use at158 most one compact table.159- **Explicit risk/CRAP request:** top 3 actual hotspots by default, supporting160 complexity/coverage/CRAP values, remaining flagged count, and 1–3 priorities.161 Exclude fully covered low-risk methods from the hotspot table. Never exceed 10162 rows unless the user requests a larger count. For refactoring safety, rank risky163 methods by CRAP rather than raw coverage alone, then name comparatively safe164 well-covered methods separately.165- **Explicit full report request:** read `references/output-format.md`. Save the166 report only then.167168Report only artifacts that exist. Do not announce inaccessible output paths or169failed optional file writes when no file was requested.170171## Optional reports172173HTML/CSV/markdown files are not part of normal analysis. Generate them only when174the user explicitly requests report files or a CI artifact.1751761. Deliver the direct coverage/risk answer first.1772. For a full markdown report, read `references/output-format.md` and save it.1783. For HTML/CSV, then read `references/report-generation.md`. Do not install179 ReportGenerator before the direct answer, and do not retry a failed install.180181## Validation182183- Confirm a supplied report was used without test execution or tool installation.184- Reconcile covered, valid, and uncovered line totals before projecting impact.185- Confirm every stated blocker comes from supplied or extracted evidence.186- If CRAP was requested, spot-check one score using `references/guidelines.md`.187- If files were requested, verify they exist before reporting their paths.188189## Common Pitfalls190191- **Existing report triggers setup work** — stop. Analyze the named artifact first.192- **Generic analysis triggers CRAP** — stop. CRAP requires explicit risk intent.193- **One method is called the entire gap** — reconcile distinct uncovered lines and194 the full below-threshold set first.195- **A small request gets a dashboard** — scale down to a direct answer or one table.196- **No Cobertura from collection** — report the collection failure; do not invent197 substitute coverage.198- **Compiler-generated method names** — verify suspicious async, lambda, or local199 function names against source before presenting them as user-authored members.200- **Test exit code 1** — coverage may still exist; proceed with a warning. Other201 nonzero build failures stop the collection path.