crap-analyzerlisted
Install: claude install-skill swingerman/disciplined-agentic-engineering
# 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](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.**
```bash
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-referenc