Coverage analysis

From managedcode/dotnet-skills · View interactive version

Coverage analysis is an AI agent skill from the GitHub repository managedcode/dotnet-skills. Activation requires either supplied .NET coverage reports/percentages/line, branch, or condition metrics, or an explicit request to collect .NET coverage for analysis. USE FOR: interpreting that evidence, including Cobertura data, partial conditions, plateaus, target arithmetic, project-wide coverag

How to use this skill

Skill file

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

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:

read references/setup-discovery.md or references/report-generation.md.

requested a saved/full report.

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.

  1. Read references/setup-discovery.md.
  2. Prefer existing Cobertura discovered under the requested root.
  3. If none exists, invoke run-tests for repository overlay, platform, runner,

and command selection, and have it collect Cobertura once per entry point.

  1. 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

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.

T, required covered lines are ceiling(valid lines × T).

valid lines`. State assumptions such as fully covering a method.

total and at least one concrete sufficient combination of supplied members or

line gains. If no supplied combination is sufficient, say so.

valid total; saying only "combine it with another member" is incomplete.

omit class-level lines, so do not sum method counts as project truth.

its distinct uncovered lines exactly reconcile with the project total and no

other below-threshold member remains.

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.

priority. No dashboard.

blocking members, reconciled target impact, and 1–3 recommendations. Use at

most one compact table.

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.

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.

  1. Deliver the direct coverage/risk answer first.
  2. For a full markdown report, read references/output-format.md and save it.
  3. 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

Common Pitfalls

the full below-threshold set first.

substitute coverage.

function names against source before presenting them as user-authored members.

nonzero build failures stop the collection path.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.