crap-analyzer

crap-analyzer is a skill for Claude Code from swingerman/engineer. It costs 109 tokens per session (1,165 once invoked), scanned A, original, MIT.

A risk check for recently changed code that combines code complexity with test coverage. It uses the CRAP score, a measure intended to highlight complex code that has little test protection.

In plain words
What is it for?
Use it on a diff, branch, or pull request across supported programming languages to plan focused refactoring and add missing test cases.
Why use it?
A code review can miss risky functions when attention is spread across a large change. This ranks the most exposed changed methods and links each one to a refactoring and testing idea.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions subagents; names the AskUserQuestion tool.

Part of the crap-analyzer plugin — 1 skill shipped together

Good fit Use it on a diff, branch, or pull request across supported programming languages to plan focused refactoring and add missing test cases.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/swingerman/engineer/crap-analyzer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add swingerman/engineer --skill crap-analyzer
Clone the repo
git clone --depth 1 https://github.com/swingerman/engineer

Made for: Claude Code.

Or install crap-analyzer, the plugin that ships this one along with the rest of its 1 skill.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for crap-analyzer

README.md
[![agentmods](https://agentmods.dev/badge/skills/swingerman/engineer/crap-analyzer/github.svg)](https://agentmods.dev/skills/swingerman/engineer/crap-analyzer)
Your own site
<a href="https://agentmods.dev/skills/swingerman/engineer/crap-analyzer"><img src="https://agentmods.dev/badge/skills/swingerman/engineer/crap-analyzer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for crap-analyzer

Your own site · 80×15
<a href="https://agentmods.dev/skills/swingerman/engineer/crap-analyzer"><img src="https://agentmods.dev/badge/skills/swingerman/engineer/crap-analyzer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 109 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,165 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00109 $0.01165
Opus 5.5 $0.00044 $0.00466
Sonnet 5.5 $0.00022 $0.00233
Haiku 4.5 $0.00011 $0.00117

Measured 3mo ago against content hash 7ad02cce7eed, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

crap-analyzer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/compute_crap.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

crap-analyzer/skills/crap-analyzer/SKILL.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CRAP Analyzer

CRAP (Change Risk Anti-Patterns) flags functions that are both complex and poorly tested — the worst-risk code to ship.

CRAP(m) = comp(m)² × (1 − cov(m))³ + comp(m)

This skill scopes analysis to a diff, ranks findings worst-first, and turns each finding into a concrete refactor + test-stub proposal.

Workflow

  1. Determine the diff. First that works:

    • gh pr diff / gh pr diff <number> if a GitHub PR is referenced.
    • git diff --merge-base <main-branch> — detect the main branch with git remote show origin | grep 'HEAD branch'.
    • git diff --cached for staged changes.
    • git diff HEAD~N..HEAD for a named commit range.
    • Explicit file list if the user names files.

    Pipe the diff to scripts/compute_crap.py --diff -.

  2. Locate or generate coverage. Let the script auto-discover coverage files first (lcov, Cobertura, JaCoCo, Clover, Go coverage.out, coverage.py JSON). If nothing is found, follow references/coverage-discovery.md to detect the toolchain, then ask before running it. On decline, proceed with coverage=0% and flag it in the report header.

  3. Run the analyzer.

    python3 <skill-dir>/scripts/compute_crap.py --diff - --repo-root <repo> --threshold <N> --format both
    

    Default threshold is 20. Read .crap-analyzer.json at repo root if present and pass its threshold through. Full flag list and output JSON shape: references/script-reference.md.

  4. Present the report. Show the markdown table. For each finding, link file:start_line. If more than ~8 findings, surface the top 5 and mention the rest.

  5. Propose fixes per finding, worst-first. For each function above threshold:

    • Read the function. Score alone is not enough — look at the code.
    • Refactor proposal. Extract-method diff or guard-clause rewrite. Patterns: references/refactor-patterns.md.
    • Test stubs. Cover each uncovered branch in the repo's test framework. Templates: references/test-stub-templates.md.
    • Respect codebase conventions. Read nearby code and match naming, error handling, DI, async patterns.

Read the full file on GitHub · 84 lines

Files

What ships with it

7 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 84 lines · 109 tokens per session scan A 7ad02cce7eed

Subscribe to this mod's changes

crap-analyzer is a skill published in the GitHub repository swingerman/engineer (166 stars, last pushed 20d ago), licensed MIT. It adds 109 tokens to every session and 1,165 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

crap-analyzer compared with skills from other repositories

crap-analyzer next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
crap-analyzerswingerman/engineerSkill16620d agoMITA109Claude Code
eu-ai-act-checkpitimon/8-habit-ai-devSkill320d agoMITA24Claude Code
workflowpitimon/8-habit-ai-devSkill320d agoMITA36Claude Code
analyze-github-issueTNT-Likely/honeycombSkill31mo agoMITA166Claude Code
gate-wiringObsidian-Owl/specwrightSkill97mo agoMITA40Claude Code
sdd-validaterubenzarroca/sdd-pluginSkill78mo agoMITA67Claude Code
sw-designObsidian-Owl/specwrightSkill97mo agoMITA29Claude Code