aspnet-core
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging,…
Calculates CRAP (Change Risk Anti-Patterns) for a named .NET method, class, or file. USE FOR: explicit CRAP calculation or coverage-and-complexity risk within that named target, including which tests to prioritize. DO NOT USE FOR: project-wide coverage/CRAP, plateaus, or
Claude Code
$ npx -y skills add managedcode/dotnet-skills --skill crap-score --agent claude-code
Codex
$ npx skills add managedcode/dotnet-skills --skill crap-score -a codex -y
Cursor
$ npx skills add managedcode/dotnet-skills --skill crap-score -a cursor -y
Gemini CLI
$ npx skills add managedcode/dotnet-skills --skill crap-score -a gemini-cli -y
GitHub Copilot
$ npx skills add managedcode/dotnet-skills --skill crap-score -a github-copilot -y
OpenCode
$ npx skills add managedcode/dotnet-skills --skill crap-score -a opencode -y
Windsurf
$ npx skills add managedcode/dotnet-skills --skill crap-score -a windsurf -y
name: crap-score description: > Calculates CRAP (Change Risk Anti-Patterns) for a named .NET method, class, or file. USE FOR: explicit CRAP calculation or coverage-and-complexity risk within that named target, including which tests to prioritize. DO NOT USE FOR: project-wide coverage/CRAP, plateaus, or project-wide blockers/priorities (coverage-analysis); behavioral/pseudo-mutation gaps (test-gap-analysis); writing tests; test runs without CRAP context. license: MIT
Calculate CRAP (Change Risk Anti-Patterns) scores for .NET methods to identify code that is both complex and undertested.
The CRAP score combines **cyclomatic complexity** and **code coverage** into a single metric:
$$\text{CRAP}(m) = \text{comp}(m)^2 \times (1 - \text{cov}(m))^3 + \text{comp}(m)$$
Where:
| CRAP Score | Risk Level | Interpretation | |------------|------------|----------------| | < 5 | Low | Simple and well-tested | | 5 to < 15 | Moderate | Acceptable for most code | | 15 to 30 | High | Needs more tests or simplification | | > 30 | Critical | Refactor and add coverage urgently |
A method with 100% coverage has CRAP = complexity (the minimum). A method with 0% coverage has CRAP = complexity^2 + complexity.
| Input | Required | Description | |-------|----------|-------------| | Target scope | Yes | Method name, class name, or file path to analyze | | Test project path | No | Path to the test project. Defaults to discovering test projects in the solution. | | Source project path | No | Path to the source project under analysis |
If the user supplies a valid Cobertura report that contains the requested target, use it directly and do not rerun tests. If the supplied report is malformed, empty, internally contradictory, or missing the target, treat it as failed input: regenerate it with a repository-compatible command when possible, or request a valid report when collection is unavailable. Otherwise invoke `run-tests` to classify the repository's test platform and confirm the compatible command shape, then require a command that emits Cobertura:
| Coverage provider | Cobertura command | |---|---| | `coverlet.collector` with VSTest | `dotnet test <test.csproj> --collect:"XPlat Code Coverage" --results-directory <results-dir>` | | `Microsoft.Testing.Extensions.CodeCoverage` with .NET 9 bridged MTP | `dotnet test <test.csproj> -- --coverage --coverage-output-format cobertura --coverage-output <output-path>` | | `Microsoft.Testing.Extensions.CodeCoverage` with .NET 10+ native MTP | `dotnet test --project <test.csproj> --coverage --coverage-output-format cobertura --coverage-output <output-path>` |
Use an equivalent repository-owned command when the project defines one. Search the results directory recursively when the collector creates a GUID subfolder. Do not substitute a generic binary `.coverage` command when no converter is available.
Do not stop at the first restore, compilation, test, or collector failure. Classify the failing layer, inspect every report the command emitted, and exhaust non-persistent retries before asking for input. Safe retries include command-line MSBuild properties that leave source and manifests unchanged and an already-installed or repository-provided alternative collector. A trivial source error is a collection blocker, not the final analysis, when a reversible command-line setting can compile the same source. Never call an empty Cobertura file a successful fallback.
For classic non-SDK projects (`ToolsVersion`, explicit compile items, or `packages.config`), use only a repository-provided coverage command that emits Cobertura. If none exists, request Cobertura XML and stop; do not migrate the project or inject an SDK-style provider. CRAP scores always require real coverage data.
**Guessed coverage produces wrong CRAP scores, which is worse than no answer.** For a classic project with no repository coverage command or existing report, stop here and request Cobertura.
Do not add coverage packages, change project manifests, or install global tools unless the user explicitly authorized dependency/tooling changes. If the repository lacks a usable provider or converter, report that exact prerequisite and the compatible command shape identified through `run-tests`, then stop. If an existing binary `.coverage` report is present, convert it only with an already-installed or repository-provided converter; otherwise request authorization or a Cobertura export. If tests execute with failures but still emit valid coverage, continue with that data and note the failures. Report complexity on its own if useful, but never publish a CRAP number derived from assumed coverage.
Before using a report, verify that it parses, contains at least one class and method, and contains the requested target. An empty report or a report that omits the target is failed collection or filtering, not 0% coverage. Regenerate coverage when possible; otherwise stop without publishing a CRAP score.
If the user supplies an existing report, state that it was not regenerated. D
Stop explaining .NET to your AI. Start building. We've all been there: asking Claude to use Entity Framework, only to get EF6 patterns in a .NET 8 project. Explaining to Copilot that Blazor Server and Blazor WebAssembly aren't the same thing.
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging,…
Build, upgrade, and operate Aspire 13.5.x C# or TypeScript application hosts with the current CLI, AppHost, ServiceDefaults,…
Build and debug Avalonia 11/12 .NET applications with XAML, compiled bindings, MVVM, custom controls, desktop lifetimes, and…
Build, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable…
Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design,…
Maintain or migrate EF6-based applications with realistic guidance on what to keep, what to modernize, and when EF Core is or is…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.