crap-analyzer

Rank recently changed functions by CRAP using diff-scoped complexity and coverage signals.

134|9|Updated Feb 16, 2026
One-click install
npx skills add https://github.com/swingerman/disciplined-agentic-engineering --skill crap-analyzer
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: crap-analyzer
Source: https://github.com/swingerman/disciplined-agentic-engineering/tree/main/crap-analyzer/skills/crap-analyzer
Command: npx skills add https://github.com/swingerman/disciplined-agentic-engineering --skill crap-analyzer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill identifies functions in recently-changed code that are both complex and under-tested, helping you prevent high-risk refactors and regressions before they ship.

Core Features & Use Cases

  • Diff-scoped CRAP ranking: Computes CRAP for newly added/changed lines only, producing a worst-first list of risky functions.
  • Coverage-aware analysis: Auto-discovers coverage files (or runs with coverage=0% and clearly flags the limitation if unavailable).
  • Actionable refactor + test stubs: Turns each CRAP finding into a concrete refactor proposal plus targeted test stub(s), with rules to avoid unsafe auto-changes.

Quick Start

Use the crap-analyzer skill on the current PR to compute CRAP for recently changed methods and generate a prioritized refactor and test-stub plan.

Frequently Asked Questions about crap-analyzer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find risky code changes in a pull request before merging?▼

To find risky code changes in a pull request, you compute Change Risk Anti-Patterns (CRAP) by analyzing a unified diff. This ranks recently changed functions worst-first by combining diff-scoped complexity and test coverage signals to surface under-tested paths.

What is the CRAP formula used for mutation testing and risk scoring?▼

The CRAP formula used for risk scoring is CRAP(m) = comp(m)^2 × (1-cov(m))^3 + comp(m). It calculates risk by combining a function's complexity with its test coverage deficiency to identify refactoring targets.

Can I run diff analysis and risk scoring on a Python or Java repository?▼

Yes, you can run diff analysis and risk scoring on Python or Java/Kotlin repositories. The analyzer supports TypeScript/JavaScript, Python, Java/Kotlin, Go, Ruby, C#, Rust, and PHP across PR and branch workflows.

How do I generate test stubs for complex functions flagged by mutation testing?▼

To generate test stubs for complex functions flagged by mutation testing, the CRAP analyzer turns each finding into a targeted test stub and a concrete refactor proposal. It applies rules to avoid unsafe auto-changes while planning fixes.

What happens if test coverage files are missing during refactor planning?▼

If test coverage files are missing during refactor planning, the analysis runs with coverage set to 0% and clearly flags the limitation. It auto-discovers compatible coverage formats when available to ensure accurate risk scoring.