[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CV410TY82N3JA6SDKY5CS4":3,"skill-same:01M7CV410TY82N3JA6SDKY5CS4":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7CV410TY82N3JA6SDKY5CS4","crap-score",null,"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\u002FCRAP, plateaus, or project-wide blockers\u002Fpriorities (coverage-analysis); behavioral\u002Fpseudo-mutation gaps (test-gap-analysis); writing tests; test runs without CRAP context.","deadmade\u002Fdead-agent-skills","deadmade","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F130925709?v=4","01M7CTQ65AGYR4J9K9TX0YR9V3","01M7CTQ66B4VMJFEDZP4EKKE6K",0,"MIT","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fcrap-score\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: crap-score\ndescription: >\n  Calculates CRAP (Change Risk Anti-Patterns) for a named .NET method, class, or\n  file. USE FOR: explicit CRAP calculation or coverage-and-complexity risk\n  within that named target, including which tests to prioritize. DO NOT USE\n  FOR: project-wide coverage\u002FCRAP, plateaus, or project-wide blockers\u002Fpriorities\n  (coverage-analysis); behavioral\u002Fpseudo-mutation gaps (test-gap-analysis);\n  writing tests; test runs without CRAP context.\nlicense: MIT\n---\n\n# CRAP Score Analysis\n\nCalculate CRAP (Change Risk Anti-Patterns) scores for .NET methods to identify code that is both complex and undertested.\n\n## Background\n\nThe CRAP score combines **cyclomatic complexity** and **code coverage** into a single metric:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nWhere:\n\n- $\\text{comp}(m)$ = cyclomatic complexity of method $m$\n- $\\text{cov}(m)$ = code coverage ratio (0.0 to 1.0) of method $m$\n\n| CRAP Score | Risk Level | Interpretation |\n|------------|------------|----------------|\n| \u003C 5        | Low        | Simple and well-tested |\n| 5 to \u003C 15  | Moderate   | Acceptable for most code |\n| 15 to 30   | High       | Needs more tests or simplification |\n| > 30       | Critical   | Refactor and add coverage urgently |\n\nA method with 100% coverage has CRAP = complexity (the minimum). A method with 0% coverage has CRAP = complexity^2 + complexity.\n\n## When to Use\n\n- User wants to assess which methods are risky due to low coverage and high complexity\n- User asks for CRAP score of specific methods, classes, or files\n- User wants to prioritize what to test next within a named method, class, or file based on coverage-and-complexity risk\n- User wants to evaluate test quality beyond simple coverage percentages\n\n## When Not to Use\n\n- User just wants to run tests (use `run-tests` skill)\n- User wants to write new tests (use `code-testing`)\n- User only wants a coverage percentage without complexity analysis\n- User wants project-wide coverage\u002FCRAP analysis or priorities (use `coverage-analysis`)\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Target scope | Yes | Method name, class name, or file path to analyze |\n| Test project path | No | Path to the test project. Defaults to discovering test projects in the solution. |\n| Source project path | No | Path to the source project under analysis |\n\n## Workflow\n\n### Step 1: Collect code coverage data\n\nIf the user supplies a valid Cobertura report that contains the requested\ntarget, use it directly and do not rerun tests. If the supplied report is\nmalformed, empty, internally contradictory, or missing the target, treat it as\nfailed input: regenerate it with a repository-compatible command when possible,\nor request a valid report when collection is unavailable. Otherwise invoke\n`run-tests` to classify the repository's test platform and confirm the\ncompatible command shape, then require a command that emits Cobertura:\n\n| Coverage provider | Cobertura command |\n|---|---|\n| `coverlet.collector` with VSTest | `dotnet test \u003Ctest.csproj> --collect:\"XPlat Code Coverage\" --results-directory \u003Cresults-dir>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 9 bridged MTP | `dotnet test \u003Ctest.csproj> -- --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 10+ native MTP | `dotnet test --project \u003Ctest.csproj> --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n\nUse an equivalent repository-owned command when the project defines one. Search\nthe results directory recursively when the collector creates a GUID subfolder.\nDo not substitute a generic binary `.coverage` command when no converter is\navailable.\n\nDo not stop at the first restore, compilation, test, or collector failure.\nClassify the failing layer, inspect every report the command emitted, and\nexhaust non-persistent retries before asking for input. Safe retries include\ncommand-line MSBuild properties that leave source and manifests unchanged and\nan already-installed or repository-provided alternative collector. A trivial\nsource error is a collection blocker, not the final analysis, when a reversible\ncommand-line setting can compile the same source. Never call an empty Cobertura\nfile a successful fallback.\n\nFor classic non-SDK projects (`ToolsVersion`, explicit compile items, or\n`packages.config`), use only a repository-provided coverage command that emits\nCobertura. If none exists, request Cobertura XML and stop; do not migrate the\nproject or inject an SDK-style provider. CRAP scores always require real\ncoverage data.\n\n#### Never estimate coverage\n\n**Guessed coverage produces wrong CRAP scores, which is worse than no answer.**\nFor a classic project with no repository coverage command or existing report,\nstop here and request Cobertura.\n\nDo not add coverage packages, change project manifests, or install global tools\nunless the user explicitly authorized dependency\u002Ftooling changes. If the\nrepository lacks a usable provider or converter, report that exact prerequisite\nand the compatible command shape identified through `run-tests`, then stop. If\nan existing binary `.coverage` report is present, convert it only with an\nalready-installed or repository-provided converter; otherwise request\nauthorization or a Cobertura export. If tests execute with failures but still\nemit valid coverage, continue with that data and note the failures. Report\ncomplexity on its own if useful, but never publish a CRAP number derived from\nassumed coverage.\n\nBefore using a report, verify that it parses, contains at least one class and\nmethod, and contains the requested target. An empty report or a report that\nomits the target is failed collection or filtering, not 0% coverage. Regenerate\ncoverage when possible; otherwise stop without publishing a CRAP score.\n\nIf the user supplies an existing report, state that it was not regenerated.\nDo not describe its data as current unless its provenance is established by\nrunning the repository's coverage command in this analysis.\n\n### Step 2: Compute cyclomatic complexity\n\nPrefer a machine-produced per-method complexity from a repository-provided code\nmetrics report or from the Cobertura method's `complexity` attribute when that\nreport maps to the current source. Microsoft.CodeAnalysis.Metrics can generate\nmethod-level `CyclomaticComplexity` data through `msbuild \u002Ft:Metrics`, but do\nnot add the package or modify the project without user approval.\n\nIf no machine-produced metric exists, analyze the current target source and\nlabel the result as a manual complexity count. Count the following decision\npoints (each adds 1 to the base complexity of 1):\n\n| Construct | Example |\n|-----------|---------|\n| `if` | `if (x > 0)` |\n| `else if` | `else if (y \u003C 0)` |\n| `case` (each) | `case 1:` |\n| `for` | `for (int i = 0; ...)` |\n| `foreach` | `foreach (var item in list)` |\n| `while` | `while (running)` |\n| `do...while` | `do { } while (cond)` |\n| `catch` (each) | `catch (Exception ex)` |\n| `&&` | `if (a && b)` |\n| `\\|\\|` (OR) | `if (a \\|\\| b)` |\n| `??` | `value ?? fallback` |\n| `?.` | `obj?.Method()` |\n| `? :` (ternary) | `x > 0 ? a : b` |\n| Pattern match arm | `x is > 0 and \u003C 10` |\n\nBase complexity is 1 for every method. Each decision point adds 1.\n\nWhen counting manually, read the source file, report the construct-by-construct\nbreakdown, and do not use a source comment as evidence. Count every occurrence,\nincluding operators nested inside arguments or return expressions; before\ndeclaring a conflict, rescan specifically for `&&`, `||`, `??`, `?.`, ternaries,\nand switch\u002Fpattern arms. If a supplied report maps to the current method and a\ncareful recount agrees, use its metric decisively. If a genuine disagreement\nremains, label both sources; when the user explicitly asked to use that report,\ncalculate the primary CRAP result from its machine-produced metric and present\nthe manual count as a caveat rather than withholding the requested result.\n\n### Step 3: Extract per-method coverage from Cobertura XML\n\nParse the Cobertura XML to find each method's `line-rate` attribute under the target `\u003Cclass>` element. If `line-rate` is not available at method level, compute it from the `\u003Clines>` elements:\n\n$$\\text{cov}(m) = \\frac{\\text{lines with hits} > 0}{\\text{total lines}}$$\n\nMethod names in Cobertura may differ from source (async methods, lambdas). Match by line ranges when names don't align.\n\nWhen both `line-rate` and `\u003Clines>` exist, recompute the hit ratio and compare\nthem. Allow only normal report rounding (one percentage point); if they differ\nmore, the report contradicts itself. Regenerate it or report the conflict and\nstop without calculating CRAP. Never silently choose whichever value produces\nthe expected score.\n\n### Step 4: Calculate CRAP scores\n\nFor each method in scope, apply the formula:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nUse a calculator or script for the arithmetic and show the substituted\ncomplexity and coverage. Do not calculate the formula mentally. Answer a named\nmethod directly; analyze unrelated methods only when the requested scope is a\nclass or file. Once the requested result is established, do not append\nhypothetical refactor scores or coverage targets unless the user asked for\nthem. Any numeric example must also come from the calculator or script.\n\n### Step 5: Present results\n\nPresent a sorted table (highest CRAP first):\n\n```text\n| Method                          | Complexity | Coverage | CRAP Score | Risk     |\n|---------------------------------|------------|----------|------------|----------|\n| OrderService.ProcessOrder       | 10         | 45%      | 26.6       | High     |\n| OrderService.ValidateItems      | 8          | 90%      | 8.1        | Moderate |\n| OrderService.CalculateTotal     | 3          | 100%     | 3.0        | Low      |\n```\n\nInclude:\n\n- **Summary**: total methods analyzed, how many in each risk category\n- **Top offenders**: methods with CRAP > 30, with specific recommendations\n- **Quick wins**: methods with high complexity but where small coverage improvements would drop the score significantly\n\n### Step 6: Provide actionable recommendations\n\nFor high-CRAP methods, suggest one or both:\n\n1. **Add tests** -- identify uncovered branches and suggest specific test cases\n2. **Reduce complexity** -- suggest extract-method refactoring for deeply nested logic\n\nCalculate the **coverage needed** to bring a method below a CRAP threshold of 15:\n\n$$\\text{cov}_{\\text{needed}} = 1 - \\left(\\frac{15 - \\text{comp}}{\\text{comp}^2}\\right)^{1\u002F3}$$\n\nThis formula only applies when comp \u003C 15. When comp >= 15, the minimum possible CRAP score (at 100% coverage) is comp itself, which already meets or exceeds the threshold. In that case, **coverage alone cannot bring the CRAP score below the threshold** -- the method must be refactored to reduce its cyclomatic complexity first.\n\nReport this as: \"To bring `ProcessOrder` (complexity 10) below CRAP 15, increase coverage from 45% to more than 63.2% (at least 64% when reporting whole percentages).\" For methods where complexity alone exceeds the threshold, report: \"`ComplexMethod` (complexity 18) cannot reach CRAP \u003C 15 through testing alone -- reduce complexity by extracting sub-methods.\"\n\n## Validation\n\n- Verify that coverage data was collected successfully (Cobertura XML exists and contains data)\n- Confirm the target method is present; absence is not evidence of 0% coverage\n- Confirm every coverage figure came from that XML — no estimated, assumed, or source-comment-derived values\n- Cross-check method `line-rate` against its line-hit ratio when both exist\n- Cross-check that method names in coverage data match the source code\n- Confirm CRAP scores with calculator or script output\n- Ensure a 100%-covered method's CRAP equals its complexity exactly\n\n## Common Pitfalls\n\n- **Estimating coverage when collection fails**: never do it — the resulting CRAP scores are wrong in the direction that matters. Use the repository-compatible Cobertura path confirmed through `run-tests`, then report the blocker instead.\n- **Treating an empty report or missing method as 0% coverage**: this is failed collection, filtering, or method mapping; do not manufacture a score.\n- **Trusting contradictory Cobertura fields**: compare `line-rate` with the line-hit ratio and stop if they disagree beyond rounding.\n- **Trusting a stale complexity comment in the source**: compute cyclomatic complexity from the current code; a `\u002F\u002F complexity: 7` comment left by a previous author is not evidence.\n- **Mental CRAP arithmetic**: use a calculator or script and show the substituted inputs.\n- **Changing tooling to bypass a collector error**: report the failed repository-compatible command and missing prerequisite; do not install a global collector or edit manifests without explicit authorization.\n- **Stale coverage data**: regenerate when the user asks for current results or the source\u002Fbinaries changed; otherwise disclose that a supplied report was not regenerated.\n- **Method name mismatches**: Cobertura XML may use mangled\u002Fcompiler-generated names for async methods, lambdas, or local functions. Match by line ranges when names don't align.\n- **Generated code**: Exclude auto-generated files (e.g., `*.Designer.cs`, `*.g.cs`) from analysis unless explicitly requested.\n","# CRAP Score Analysis\n\nCalculate CRAP (Change Risk Anti-Patterns) scores for .NET methods to identify code that is both complex and undertested.\n\n## Background\n\nThe CRAP score combines **cyclomatic complexity** and **code coverage** into a single metric:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nWhere:\n\n- $\\text{comp}(m)$ = cyclomatic complexity of method $m$\n- $\\text{cov}(m)$ = code coverage ratio (0.0 to 1.0) of method $m$\n\n| CRAP Score | Risk Level | Interpretation |\n|------------|------------|----------------|\n| \u003C 5        | Low        | Simple and well-tested |\n| 5 to \u003C 15  | Moderate   | Acceptable for most code |\n| 15 to 30   | High       | Needs more tests or simplification |\n| > 30       | Critical   | Refactor and add coverage urgently |\n\nA method with 100% coverage has CRAP = complexity (the minimum). A method with 0% coverage has CRAP = complexity^2 + complexity.\n\n## When to Use\n\n- User wants to assess which methods are risky due to low coverage and high complexity\n- User asks for CRAP score of specific methods, classes, or files\n- User wants to prioritize what to test next within a named method, class, or file based on coverage-and-complexity risk\n- User wants to evaluate test quality beyond simple coverage percentages\n\n## When Not to Use\n\n- User just wants to run tests (use `run-tests` skill)\n- User wants to write new tests (use `code-testing`)\n- User only wants a coverage percentage without complexity analysis\n- User wants project-wide coverage\u002FCRAP analysis or priorities (use `coverage-analysis`)\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Target scope | Yes | Method name, class name, or file path to analyze |\n| Test project path | No | Path to the test project. Defaults to discovering test projects in the solution. |\n| Source project path | No | Path to the source project under analysis |\n\n## Workflow\n\n### Step 1: Collect code coverage data\n\nIf the user supplies a valid Cobertura report that contains the requested\ntarget, use it directly and do not rerun tests. If the supplied report is\nmalformed, empty, internally contradictory, or missing the target, treat it as\nfailed input: regenerate it with a repository-compatible command when possible,\nor request a valid report when collection is unavailable. Otherwise invoke\n`run-tests` to classify the repository's test platform and confirm the\ncompatible command shape, then require a command that emits Cobertura:\n\n| Coverage provider | Cobertura command |\n|---|---|\n| `coverlet.collector` with VSTest | `dotnet test \u003Ctest.csproj> --collect:\"XPlat Code Coverage\" --results-directory \u003Cresults-dir>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 9 bridged MTP | `dotnet test \u003Ctest.csproj> -- --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 10+ native MTP | `dotnet test --project \u003Ctest.csproj> --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n\nUse an equivalent repository-owned command when the project defines one. Search\nthe results directory recursively when the collector creates a GUID subfolder.\nDo not substitute a generic binary `.coverage` command when no converter is\navailable.\n\nDo not stop at the first restore, compilation, test, or collector failure.\nClassify the failing layer, inspect every report the command emitted, and\nexhaust non-persistent retries before asking for input. Safe retries include\ncommand-line MSBuild properties that leave source and manifests unchanged and\nan already-installed or repository-provided alternative collector. A trivial\nsource error is a collection blocker, not the final analysis, when a reversible\ncommand-line setting can compile the same source. Never call an empty Cobertura\nfile a successful fallback.\n\nFor classic non-SDK projects (`ToolsVersion`, explicit compile items, or\n`packages.config`), use only a repository-provided coverage command that emits\nCobertura. If none exists, request Cobertura XML and stop; do not migrate the\nproject or inject an SDK-style provider. CRAP scores always require real\ncoverage data.\n\n#### Never estimate coverage\n\n**Guessed coverage produces wrong CRAP scores, which is worse than no answer.**\nFor a classic project with no repository coverage command or existing report,\nstop here and request Cobertura.\n\nDo not add coverage packages, change project manifests, or install global tools\nunless the user explicitly authorized dependency\u002Ftooling changes. If the\nrepository lacks a usable provider or converter, report that exact prerequisite\nand the compatible command shape identified through `run-tests`, then stop. If\nan existing binary `.coverage` report is present, convert it only with an\nalready-installed or repository-provided converter; otherwise request\nauthorization or a Cobertura export. If tests execute with failures but still\nemit valid coverage, continue with that data and note the failures. Report\ncomplexity on its own if useful, but never publish a CRAP number derived from\nassumed coverage.\n\nBefore using a report, verify that it parses, contains at least one class and\nmethod, and contains the requested target. An empty report or a report that\nomits the target is failed collection or filtering, not 0% coverage. Regenerate\ncoverage when possible; otherwise stop without publishing a CRAP score.\n\nIf the user supplies an existing report, state that it was not regenerated.\nDo not describe its data as current unless its provenance is established by\nrunning the repository's coverage command in this analysis.\n\n### Step 2: Compute cyclomatic complexity\n\nPrefer a machine-produced per-method complexity from a repository-provided code\nmetrics report or from the Cobertura method's `complexity` attribute when that\nreport maps to the current source. Microsoft.CodeAnalysis.Metrics can generate\nmethod-level `CyclomaticComplexity` data through `msbuild \u002Ft:Metrics`, but do\nnot add the package or modify the project without user approval.\n\nIf no machine-produced metric exists, analyze the current target source and\nlabel the result as a manual complexity count. Count the following decision\npoints (each adds 1 to the base complexity of 1):\n\n| Construct | Example |\n|-----------|---------|\n| `if` | `if (x > 0)` |\n| `else if` | `else if (y \u003C 0)` |\n| `case` (each) | `case 1:` |\n| `for` | `for (int i = 0; ...)` |\n| `foreach` | `foreach (var item in list)` |\n| `while` | `while (running)` |\n| `do...while` | `do { } while (cond)` |\n| `catch` (each) | `catch (Exception ex)` |\n| `&&` | `if (a && b)` |\n| `\\|\\|` (OR) | `if (a \\|\\| b)` |\n| `??` | `value ?? fallback` |\n| `?.` | `obj?.Method()` |\n| `? :` (ternary) | `x > 0 ? a : b` |\n| Pattern match arm | `x is > 0 and \u003C 10` |\n\nBase complexity is 1 for every method. Each decision point adds 1.\n\nWhen counting manually, read the source file, report the construct-by-construct\nbreakdown, and do not use a source comment as evidence. Count every occurrence,\nincluding operators nested inside arguments or return expressions; before\ndeclaring a conflict, rescan specifically for `&&`, `||`, `??`, `?.`, ternaries,\nand switch\u002Fpattern arms. If a supplied report maps to the current method and a\ncareful recount agrees, use its metric decisively. If a genuine disagreement\nremains, label both sources; when the user explicitly asked to use that report,\ncalculate the primary CRAP result from its machine-produced metric and present\nthe manual count as a caveat rather than withholding the requested result.\n\n### Step 3: Extract per-method coverage from Cobertura XML\n\nParse the Cobertura XML to find each method's `line-rate` attribute under the target `\u003Cclass>` element. If `line-rate` is not available at method level, compute it from the `\u003Clines>` elements:\n\n$$\\text{cov}(m) = \\frac{\\text{lines with hits} > 0}{\\text{total lines}}$$\n\nMethod names in Cobertura may differ from source (async methods, lambdas). Match by line ranges when names don't align.\n\nWhen both `line-rate` and `\u003Clines>` exist, recompute the hit ratio and compare\nthem. Allow only normal report rounding (one percentage point); if they differ\nmore, the report contradicts itself. Regenerate it or report the conflict and\nstop without calculating CRAP. Never silently choose whichever value produces\nthe expected score.\n\n### Step 4: Calculate CRAP scores\n\nFor each method in scope, apply the formula:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nUse a calculator or script for the arithmetic and show the substituted\ncomplexity and coverage. Do not calculate the formula mentally. Answer a named\nmethod directly; analyze unrelated methods only when the requested scope is a\nclass or file. Once the requested result is established, do not append\nhypothetical refactor scores or coverage targets unless the user asked for\nthem. Any numeric example must also come from the calculator or script.\n\n### Step 5: Present results\n\nPresent a sorted table (highest CRAP first):\n\n```text\n| Method                          | Complexity | Coverage | CRAP Score | Risk     |\n|---------------------------------|------------|----------|------------|----------|\n| OrderService.ProcessOrder       | 10         | 45%      | 26.6       | High     |\n| OrderService.ValidateItems      | 8          | 90%      | 8.1        | Moderate |\n| OrderService.CalculateTotal     | 3          | 100%     | 3.0        | Low      |\n```\n\nInclude:\n\n- **Summary**: total methods analyzed, how many in each risk category\n- **Top offenders**: methods with CRAP > 30, with specific recommendations\n- **Quick wins**: methods with high complexity but where small coverage improvements would drop the score significantly\n\n### Step 6: Provide actionable recommendations\n\nFor high-CRAP methods, suggest one or both:\n\n1. **Add tests** -- identify uncovered branches and suggest specific test cases\n2. **Reduce complexity** -- suggest extract-method refactoring for deeply nested logic\n\nCalculate the **coverage needed** to bring a method below a CRAP threshold of 15:\n\n$$\\text{cov}_{\\text{needed}} = 1 - \\left(\\frac{15 - \\text{comp}}{\\text{comp}^2}\\right)^{1\u002F3}$$\n\nThis formula only applies when comp \u003C 15. When comp >= 15, the minimum possible CRAP score (at 100% coverage) is comp itself, which already meets or exceeds the threshold. In that case, **coverage alone cannot bring the CRAP score below the threshold** -- the method must be refactored to reduce its cyclomatic complexity first.\n\nReport this as: \"To bring `ProcessOrder` (complexity 10) below CRAP 15, increase coverage from 45% to more than 63.2% (at least 64% when reporting whole percentages).\" For methods where complexity alone exceeds the threshold, report: \"`ComplexMethod` (complexity 18) cannot reach CRAP \u003C 15 through testing alone -- reduce complexity by extracting sub-methods.\"\n\n## Validation\n\n- Verify that coverage data was collected successfully (Cobertura XML exists and contains data)\n- Confirm the target method is present; absence is not evidence of 0% coverage\n- Confirm every coverage figure came from that XML — no estimated, assumed, or source-comment-derived values\n- Cross-check method `line-rate` against its line-hit ratio when both exist\n- Cross-check that method names in coverage data match the source code\n- Confirm CRAP scores with calculator or script output\n- Ensure a 100%-covered method's CRAP equals its complexity exactly\n\n## Common Pitfalls\n\n- **Estimating coverage when collection fails**: never do it — the resulting CRAP scores are wrong in the direction that matters. Use the repository-compatible Cobertura path confirmed through `run-tests`, then report the blocker instead.\n- **Treating an empty report or missing method as 0% coverage**: this is failed collection, filtering, or method mapping; do not manufacture a score.\n- **Trusting contradictory Cobertura fields**: compare `line-rate` with the line-hit ratio and stop if they disagree beyond rounding.\n- **Trusting a stale complexity comment in the source**: compute cyclomatic complexity from the current code; a `\u002F\u002F complexity: 7` comment left by a previous author is not evidence.\n- **Mental CRAP arithmetic**: use a calculator or script and show the substituted inputs.\n- **Changing tooling to bypass a collector error**: report the failed repository-compatible command and missing prerequisite; do not install a global collector or edit manifests without explicit authorization.\n- **Stale coverage data**: regenerate when the user asks for current results or the source\u002Fbinaries changed; otherwise disclose that a supplied report was not regenerated.\n- **Method name mismatches**: Cobertura XML may use mangled\u002Fcompiler-generated names for async methods, lambdas, or local functions. Match by line ranges when names don't align.\n- **Generated code**: Exclude auto-generated files (e.g., `*.Designer.cs`, `*.g.cs`) from analysis unless explicitly requested.\n",{"name":5,"license":14,"description":23},"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\u002FCRAP, plateaus, or project-wide blockers\u002Fpriorities (coverage-analysis); behavioral\u002Fpseudo-mutation gaps (test-gap-analysis); writing tests; test runs without CRAP context.\n","main","ccab8dffc0ecc173838f51e4c5f0d3b51a704f41","plugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fcrap-score","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills","https:\u002F\u002Fgithub.com\u002Fdeadmade","https:\u002F\u002Fdeadmade.github.io\u002F","Blood, an Ocean of blood","2026-11-14 02:03:31",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add deadmade\u002Fdead-agent-skills --skill crap-score",{"tool":38,"command":39},"bunx","bunx skills add deadmade\u002Fdead-agent-skills --skill crap-score",{"tool":41,"command":42},"pnpm","pnpm dlx skills add deadmade\u002Fdead-agent-skills --skill crap-score","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fcrap-score\u002FSKILL.md",true,[],[47,54,63,71,78,85],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":18},"01M7CVRBFTXSTTQ7F5P6PJEFYA","rust-best-practices","Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook. Use this skill when: (1) writing new Rust code or functions, (2) reviewing or refactoring existing Rust code, (3) deciding between borrowing vs cloning or ownership patterns, (4) implementing error handling with Result types, (5) optimizing Rust code for performance, (6) writing tests or documentation for Rust projects.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Frust-skills\u002Fskills\u002Frust-best-practices\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":58,"licenseFileUrl":59,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M7CVR0W7B8EGTNPSPA7FPC4Z","postgres-database-migration","Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases.\n\n**Trigger when user asks to:**\n- Test a schema migration before applying it to production\n- Add, remove, or rename columns safely on a live table\n- Change a column's data type without downtime\n- Add or drop indexes, constraints, or foreign keys on large tables\n- Understand which ALTER TABLE operations lock the table\n- Roll back a failed migration\n- Plan a zero-downtime migration strategy\n- Fork a database to test a migration safely\n\nCovers: lock-level reference for every common DDL operation, safe migration patterns, fork-based testing, zero-downtime column changes, index creation, constraint addition, backfill strategies, pre\u002Fpost-migration validation, and rollback planning.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-database-migration\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-database-migration\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":58,"licenseFileUrl":67,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":18},"01M7CVQWK20ASAZN5VETZC8J99","postgres-best-practices","Best practices and guidelines for working with Postgres. Covers schema design, indexing strategies, query optimization, migrations, and common pitfalls. Use when writing SQL, designing database schemas, optimizing queries, or setting up a Postgres database.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-best-practices\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-best-practices\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":18},"01M7CVQ5CY7AQHY7A2Y99RE6A7","writing-mstest-tests","ALWAYS USE when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for \"review\" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected\u002Factual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext\u002Flifecycle; timeout\u002Fcancellation; OS\u002FCI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. DO NOT USE to design new test cases (code-testing), perform report-only audits, create project files rather than explain MSTest setup, run tests, migrate frameworks, or handle non-MSTest\u002Fnon-.NET code.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fwriting-mstest-tests\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M7CVPWJZ63GB0810F0SCGZ1K","winforms-expert","Create, modify, debug, or review Windows Forms applications only when the request contains a concrete Windows Forms marker. USE FOR: WinForms, Windows Forms, System.Windows.Forms, WinForms Form or UserControl designer files (*.Designer.cs or *.Designer.vb), Visual Studio WinForms Designer, TableLayoutPanel, BindingSource, DataGridView, Control.InvokeAsync, component-tray ownership, or custom control serialization. DO NOT USE FOR: WPF or WPF XAML, including Window.InputBindings, KeyBinding, commands, or DataContext; .NET MAUI; Avalonia; or any request where none of the listed Windows Forms markers is present.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fwinforms-expert\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M7CVPR0QFZ1HMJ6GZRBQAQ7W","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fvectorization\u002FSKILL.md",[],[]]