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 1mo 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 1mo 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. 1mo 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 (157 stars, last pushed 23d 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

Other skills, from other repositories

brooks-test

Test quality review drawing on twelve classic engineering books — with primary focus on xUnit Test Patterns, The Art of Unit Testing, How Google Tests Software, and Working Effectively with Legacy Code — that diagnoses structural problems in an existing test suite: brittleness, mock abuse, coverage illusions, slow…

hyhmrright/brooks-lint · 161 tokens

Behat BDD Testing

PHP BDD testing with Behat framework using Gherkin feature files, Mink browser extension, context classes, and Symfony integration for behavior-driven acceptance testing.

PramodDutta/qaskills · 37 tokens

pre-pr-audit

Pre-PR confidence audit with 5-dimension scoring. Use when: final check before commit/push/PR, evaluating PR readiness, assessing test quality + risk + coverage holistically. Triggers: pre-pr, readiness check, confidence audit, final verification, ready to PR, how confident. Not for: code review (use…

sd0xdev/sd0x-harness · 95 tokens

vibe-gap-analysis

Assesses production readiness or audits a codebase against its specs. Supports quick static mode, deep 17-dimension audit, or single-dimension focus. Use before a production launch, after a major refactor, when inheriting a codebase, or when someone asks how done the project is.

ash1794/vibe-engineering · 65 tokens

spike-consumer-adversarial

OI-3 spike harness — heavy consumer, ADVERSARIAL arm. Worst-case early-exit test: the mid-workflow Skill call has no continuation guardrail and the guidance skill ends with a final-sounding anchor. Use only when explicitly invoked by the spike harness with a TRIALID and data path.

testdouble/han · 0 tokens

Behave BDD Testing

Python BDD testing with Behave framework using Gherkin feature files, step definitions, environment hooks, and Selenium integration for behavior-driven acceptance testing.

PramodDutta/qaskills · 36 tokens