crap-score

Calculates CRAP scores for .NET methods by combining Cobertura coverage data with cyclomatic complexity.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill crap-score-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: crap-score
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/crap-score
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill crap-score-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Simple coverage percentages hide which code is genuinely risky. This Skill identifies .NET methods that are both complex and undertested by computing CRAP (Change Risk Anti-Patterns) scores, so you know exactly which methods to test or refactor first. ## Core Features & Use Cases - Targeted CRAP Calculation: Computes CRAP scores for a named method, class, or single source file using the formula comp^2 x (1 - cov)^3 + comp. - Coverage Collection Guidance: Detects the coverage package in the test project (coverlet.collector or Microsoft.Testing.Extensions.CodeCoverage) and runs the correct dotnet test command to produce Cobertura XML. - Actionable Recommendations: Reports risk tiers, top offenders, quick wins, and the exact coverage needed to bring a method below CRAP 15, or flags methods that must be refactored first. - Use Case: Ask for the CRAP score of OrderService.ProcessOrder and receive a sorted table of complexity, coverage, and risk, plus specific test cases to add for uncovered branches. ## Quick Start Calculate the CRAP score for the ProcessOrder method in OrderService.cs and tell me which methods need tests or refactoring first.

Frequently Asked Questions about crap-score

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

FAQPage Schema
How do I calculate CRAP score for a .NET method?

Run dotnet test with coverage collection to produce a Cobertura XML file, compute cyclomatic complexity by counting decision points in the method, then apply CRAP = comp^2 x (1 - cov)^3 + comp. This Skill automates all steps for a named method, class, or file.

What is a good CRAP score threshold for code risk?

CRAP below 5 is low risk, 5-15 is moderate, 15-30 is high, and above 30 is critical. A method with 100% coverage has CRAP equal to its complexity, which is the minimum achievable score.

Which coverage tools work with dotnet test for Cobertura output?

coverlet.collector works via dotnet test --collect:"XPlat Code Coverage", while Microsoft.Testing.Extensions.CodeCoverage uses --coverage --coverage-output-format cobertura. The Skill checks the test project's .csproj to pick the right command.

Why do method names in Cobertura XML not match my source code?

Async methods, lambdas, and local functions get compiler-generated names in Cobertura XML. Match methods by line ranges instead of names when the identifiers do not align.

When should I not use CRAP score analysis?

Avoid it for project-wide coverage analysis, diagnosing coverage plateaus, or deciding where to add tests across a whole project. It is designed for targeted scoring of a specific method, class, or file, not broad coverage strategy.