Code quality guardrails for the agentic age.

SlopGuard finds the complex, untested methods your coding agents break first, then turns them into one number you can gate in CI.

Get started See the formula
$slopguard-swift analyze --fail-over 50
// the guardrail

Reduce complexity.
Increase coverage.

That's the whole guardrail. Agents iterate by changing code and running tests, and the quality of that loop is decided by your codebase, not the model.

01

Coverage is the feedback loop

An agent editing untested code can't tell a fix from a regression. Where coverage is missing, agents guess.

02

Complexity is where agents fail

Deeply nested, many-branched methods blow past what any model reasons about reliably.

03

wCRAP gates both

One score per method. Gate it in CI, or hand the worst offenders to an agent as a work queue.

// the formula

The math, without the math degree.

wCRAP = (cyc × cog) × (1 − cov⁄100)³ + √(cyc × cog)
cyc
Cyclomatic complexity. Independent paths through the method. Each branch, loop, and conditional adds one.
cog
Cognitive complexity. How hard it is for a human to follow. Nested logic compounds the cost.
cov
Test coverage. The share of the method's lines exercised by tests, from 0 to 100%.
(cyc × cog): the tangle How many paths through the method, times how hard it is to follow. How much can go wrong.
(1 − cov/100)³: untested risk, cubed Risk falls off a cliff as soon as you start testing: 50% coverage kills 87.5% of it.
√(cyc × cog): the floor Even fully tested, a tangled method is still tangled. Only refactoring goes below this.

Pick a real method (from SlopGuard's own report)

Or build your own

Cyclomatic: paths through it17
Cognitive: how hard to follow15
Test coverage0%
270.97
crappy: above threshold 30

// real output, real code

A report agents and jq can eat.

Pretty text for humans, stable versioned JSON for everything else.

shell
# Top of the leaderboard, straight from the dogfood run
$ slopguard-swift analyze --path Sources --json | jq '.methods | sort_by(-.crap)[0]'
{
  "qualifiedName" : "CrapAggregator.aggregate(fileReports:sourceRootURL:…)",
  "file"      : "slopguard-core/Aggregation/CrapAggregator.swift",
  "complexity"          : 17,
  "cognitiveComplexity" : 15,
  "coverage"  : 0,
  "crap"      : 270.97,
  "isCrappy"  : true
}
prompt for your coding agent
Use slopguard-swift to analyze this repo and find the
method with the highest wCRAP score. Show me its
file and line, then add tests or refactor until
its score is under 30.
.github/workflows/quality.yml
- name: Gate on wCRAP
  run: slopguard-swift analyze --path Sources --fail-over 50
  # exits 2 if any method's wCRAP exceeds 50 → PR blocked
shell
# Top of the leaderboard, straight from the dogfood run
$ slopguard-ts analyze --path src --json | jq '.methods | sort_by(-.crap)[0]'
{
  "qualifiedName": "CrapAggregator.aggregate",
  "file": "core/aggregation/crapAggregator.ts",
  "complexity": 20,
  "cognitiveComplexity": 16,
  "coverage": 0,
  "crap": 337.89,
  "isCrappy": true
}
prompt for your coding agent
Use slopguard-ts to analyze this repo and find the
method with the highest wCRAP score. Show me its
file and line, then add tests or refactor until
its score is under 30.
.github/workflows/quality.yml
- name: Gate on wCRAP
  run: slopguard-ts analyze --path src --fail-over 50
  # exits 2 if any method's wCRAP exceeds 50 → PR blocked
shell
# Top of the leaderboard, straight from the dogfood run
$ slopguard-go analyze --path . --json | jq '.methods | sort_by(-.crap)[0]'
{
  "qualifiedName": "enumerate",
  "file": "core/diranalyzer.go",
  "complexity": 10,
  "cognitiveComplexity": 26,
  "coverage": 0,
  "crap": 276.12,
  "isCrappy": true
}
prompt for your coding agent
Use slopguard-go to analyze this module and find the
method with the highest wCRAP score. Show me its
file and line, then add tests or refactor until
its score is under 30.
.github/workflows/quality.yml
- name: Gate on wCRAP
  run: slopguard-go analyze --path . --fail-over 50
  # exits 2 if any method's wCRAP exceeds 50 → PR blocked
shell
# Top of the leaderboard, straight from the dogfood run
$ slopguard-kotlin analyze --path . --json | jq '.methods | sort_by(-.crap)[0]'
{
  "qualifiedName": "ComplexityCalculator.walk",
  "file": "core/src/main/kotlin/.../ComplexityVisitor.kt",
  "complexity": 19,
  "cognitiveComplexity": 12,
  "coverage": 0,
  "crap": 243.10,
  "isCrappy": true
}
prompt for your coding agent
Use slopguard-kotlin to analyze this module and find
the method with the highest wCRAP score. Show me its
file and line, then add tests or refactor until
its score is under 30.
.github/workflows/quality.yml
- name: Gate on wCRAP
  run: slopguard-kotlin analyze --path src/main/kotlin --fail-over 50
  # exits 2 if any method's wCRAP exceeds 50 → PR blocked
shell
# Top of the leaderboard, straight from the dogfood run
$ slopguard-python analyze --path . --json | jq '.methods | sort_by(-.crap)[0]'
{
  "qualifiedName": "_run_analyze",
  "file": "src/slopguard/cli.py",
  "complexity": 14,
  "cognitiveComplexity": 18,
  "coverage": 0,
  "crap": 267.87,
  "isCrappy": true
}
prompt for your coding agent
Use slopguard-python to analyze this repo and find the
method with the highest wCRAP score. Show me its
file and line, then add tests or refactor until
its score is under 30.
.github/workflows/quality.yml
- name: Gate on wCRAP
  run: slopguard-python analyze --path . --fail-over 50
  # exits 2 if any method's wCRAP exceeds 50 → PR blocked
// languages

Swift, TypeScript, Go, Kotlin, and Python today. Your stack next.