coverage-analysis

Analyzes .NET code coverage and computes CRAP scores to rank risky, under-tested methods.

Updated Jul 12, 2026
One-click install
npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill coverage-analysis-patrick-rex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: coverage-analysis
Source: https://github.com/Patrick-Rex/DotNetTechSamples/tree/main/.agents/plugins/dotnet-test/skills/coverage-analysis
Command: npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill coverage-analysis-patrick-rex

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Raw coverage percentages tell you what code ran, but not which uncovered code is risky or why coverage has plateaued. This Skill turns a .NET solution or existing Cobertura XML into a prioritized list of risk hotspots — complex methods with low coverage that are dangerous to modify. ## Core Features & Use Cases - CRAP Score Analysis: Computes Change Risk Anti-Patterns scores per method using cyclomatic complexity and line coverage, surfacing the top risk hotspots. - Automated Coverage Collection: Detects the coverage provider (Coverlet or Microsoft CodeCoverage) per test project, adds one if missing, and runs dotnet test with Cobertura output. - Coverage Gap Reporting: Produces a markdown report with coverage gaps by file, priority rankings, and quantified recommendations; optionally generates HTML/CSV reports via ReportGenerator. - Use Case: Your project's line coverage is stuck at 72% and you don't know what to test next. Run this Skill to get a ranked table showing that ProcessOrder has a CRAP score of 48, and that three targeted tests would drop it to ~6. ## Quick Start Analyze the test coverage and CRAP risk hotspots for the .NET solution in the current directory.

Frequently Asked Questions about coverage-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze code coverage and CRAP scores for a .NET project?

Point the Skill at your .NET solution or project directory. It detects your coverage provider, runs dotnet test with Cobertura output, then computes per-method CRAP scores and returns a ranked risk hotspot table with recommendations.

What is a CRAP score in code coverage analysis?

CRAP (Change Risk Anti-Patterns) combines cyclomatic complexity and test coverage using the formula complexity squared times (1 minus coverage) cubed plus complexity. Scores above 30 indicate complex, poorly tested code that is risky to modify.

Can I analyze an existing Cobertura XML file without running tests?

Yes. If you supply a path to an existing coverage.cobertura.xml file, or one is found under TestResults, the Skill skips test execution entirely and runs the CRAP and coverage-gap analysis directly on that data.

Does it work with both Coverlet and Microsoft CodeCoverage?

Yes. The Skill detects which provider each test project references and adapts the dotnet test arguments accordingly. For mixed solutions it runs per-project to avoid dual-provider conflicts, and it can add coverlet.collector to projects with no provider.

Why did coverage analysis produce no Cobertura XML output?

This usually happens when the test project lacks a coverage provider or dotnet add package fails due to no internet access. Check for binary .coverage files as an indicator, and ensure NuGet access is available for adding coverlet.collector.

When should I not use project-wide coverage analysis?

Avoid it for targeted single-method CRAP analysis, writing or generating tests, or general test execution unrelated to coverage. The Skill identifies where tests are needed but does not write them.