Skip to content
Back to skills

Agent Gauntlet

ASecurity

Run the gauntlet, implement verifiable user stories, or set up agent quality gates. A staged pipeline specifies Gherkin, implements test-first, cleans to a per-function CRAP threshold and a DRY gate, optionally fixes architecture, and hardens through mutation testing.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 19, 2026
ai-agentstypescriptpythonrustgojavaswiftbashtestingrefactoringgit

Works with

  • claude code

Security analysis

A100/100

Pro scans all 17 files and shows the line behind each finding

Scanned November 27, 2026

npx -y skills add n0an/agent-gauntlet --skill agent-gauntlet --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Agent Gauntlet?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Agent Gauntlet
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/n0an-agent-gauntlet/badge)](https://www.skillsdirectory.com/skills/n0an-agent-gauntlet)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: agent-gauntlet
description: Run the gauntlet, implement verifiable user stories, or set up agent quality gates. A staged pipeline specifies Gherkin, implements test-first, cleans to a per-function CRAP threshold and a DRY gate, optionally fixes architecture, and hardens through mutation testing.
license: MIT
metadata:
  author: Anton Novoselov
  version: "0.5"
---

# The Agent Gauntlet

Uncle Bob's multi-agent methodology, as a portable skill. Core idea: **don't stuff quality rules into prompts - wrap the agent in deterministic gates.** Agents treat written rules as vague suggestions and forget the middle of long instructions; tools don't decay. Put the agent in a loop against a checker until the numbers pass. Built from his 2026 interview, then aligned with his published rules: [ub-mode](https://github.com/unclebob/ub-mode) and the [swarm-forge](https://github.com/unclebob/swarm-forge) six-pack.

## The pipeline

```
story ─▶ specifier ─▶ (approve) ─▶ coder ─▶ cleaner ─▶ (architect) ─▶ hardener ─▶ (qa)
          Gherkin +     human,        test-     CRAP +     boundaries,     mutation     UI
          QA proc       optional      first     DRY gates  optional        clean        check
```

Each stage runs in a **fresh context** and **its own git worktree**. Only disk artifacts cross stage boundaries: `features/<slug>.feature` and `features/<slug>.qa.md` are the contract; commits are the code; `.gauntlet/runs/<slug>/handoffs/` carries reports. This prevents context contamination, preserves the developer's checkout, and makes each stage's changes diffable.

## Stage contracts

Run stages as separate sessions using their system prompts in `stages/{specifier,coder,cleaner,architect,hardener,qa}.md`; without subagents, read and follow each directly. Summary:

1. **specifier** - story text → `features/<slug>.feature` (3-7 numbered Given/When/Then scenarios, user-observable only, no implementation terms) + `features/<slug>.qa.md` (numbered manual QA steps). Never writes code. With `--approve-spec` a human approves or rejects (with notes) before the coder starts.
2. **coder** - feature file → test-first, one scenario at a time: a test that fails for a plausible wrong implementation, seen red, then the smallest code. Data shape first, decisions in host-testable modules, thin adapters. May not edit the feature file; if the spec is unimplementable, it stops and reports. No refactoring of surrounding code.
3. **cleaner** - changed files → tests or refactors until every function is under the CRAP threshold and the story added no duplication (DRY gate). Behavior frozen: structure changes only, tests stay green, assertions never weakened.
4. **architect** (optional, `--architect`) - the story's diff → core apart from IO, dependencies pointing inward, no adapter re-answering a domain question, cheap boundary checks. Behavior frozen; tests, CRAP and DRY gates re-pass.
5. **hardener** - changed modules → mutation testing until zero unjustified survivors. Never weakens production code. Requires current raw tool evidence plus regular tests; narrow waivers name exact mutant IDs, reasons and reviewers. Follow `references/mutation-evidence.md`. Cover the uncovered, kill the survivors, delete unreachable code.
6. **qa** (optional, `--qa`) - QA procedure → executable UI check with screenshot evidence, PASS/FAIL per scenario.

Every report ends with a short decision log: what the stage chose and why. The report is the next stage's payload.

Pipeline rules: stages run sequentially; a failing stage stops the pipeline (no skipping); stages commit only in their own worktree, nothing is merged or pushed - the run's only output is the branch `gauntlet/<slug>`, which the human reviews.

## The handoff protocol

`scripts/gauntlet/gauntlet.sh` is the runtime (Bash 3.2 + git, Python 3.8+ for mutation evidence, no daemon). Full contract in `references/handoff-protocol.md`; the short version:

```bash
scripts/gauntlet/gauntlet.sh start <slug> --story story.md [--architect] [--qa] [--approve-spec]
scripts/gauntlet/gauntlet.sh stage <slug> coder
scripts/gauntlet/gauntlet.sh handoff <slug> coder --gate "swift test"
scripts/gauntlet/gauntlet.sh approve <slug>            # or: reject <slug> --note -
scripts/gauntlet/gauntlet.sh status <slug>
scripts/gauntlet/gauntlet.sh finish <slug> [--purge]
```

`handoff` refuses dirty worktrees, missing `By <stage>.` bylines, non-descendant HEADs, coder edits to `features/`, missing reports, red gates, and gate-induced tree changes. Hardener always needs regular tests and valid commit/base/scope-bound mutation evidence. Logs and captures survive `finish`. The first valid call returns `AUDIT_REQUIRED` (4); recheck the checklist, then repeat unchanged to queue and advance the branch. Changes to commit, report, gate or evidence restart audit. Other exits: 0 success, 1 refused, 2 setup, 3 `NO_TASK`, 5 `AWAITING_APPROVAL` (the coder cannot start before `approve`). A gate that fails twice in a row prints `ATTACK_THE_PREMISE`: name the premise the failed fixes shared, check it, and back the fixes out if it is wrong.

Stages begin with `stage`, use only its printed payload (it includes `RUN_BASE:`, the story's base commit), work/commit in `WORKTREE`, write `.gauntlet/report.md`, and end with `handoff`. The orchestrator launches fresh stages named in `NEXT:` and resumes through `status`.

## The deterministic gates

| Gate | Tool | Stage | Threshold |
|---|---|---|---|
| Tests green | `swift test` / project test cmd | coder, architect, hardener | 100% pass |
| CRAP per function | lizard + coverage export, joined by `crap.py` via `crap-gate.sh` | cleaner, architect | 6 (`GAUNTLET_CRAP_THRESHOLD`) |
| DRY | Uncle Bob's [dryer](https://github.com/unclebob/dryer) via `dry-gate.sh --base <RUN_BASE>`, pairs touching changed lines | cleaner, architect | similarity < 0.8 (`GAUNTLET_DRY_THRESHOLD`) |
| Module line coverage | llvm-cov totals, SPM mode only | cleaner | floor 70% (`GAUNTLET_COV_FLOOR`, 0 disables) |
| Structure (optional) | SwiftLint `swiftlint-gauntlet.yml`, when installed | cleaner | body 100 lines, nesting 3 |
| Mutation evidence | `mutation-evidence.py`, raw Muter or standard report JSON | hardener | nonzero results, exact commit/scope, zero unjustified survivors |

CRAP = `complexity^2 * (1 - coverage)^3 + complexity`, per function. At full coverage a function scores exactly its complexity, so a threshold of 6 means "at most six paths, all of them tested". Uncoverage is cubed: complexity 12 at 0% scores 156. That is what makes it a change-risk gate rather than two disconnected numbers - a module-level coverage floor lets an untested complex function hide behind well-covered neighbours; the per-function score does not.

Thresholds are Uncle Bob's agent-calibrated values: in the interview he held humans to CRAP 4, gave agents 6 and was trying 8; his published rules (ub-mode, six-pack) now use 10. The gauntlet keeps 6 and takes his exception instead: **one switch that answers one question** may stay over the threshold rather than be split into helpers that take booleans the caller already knew. Write it in `crap-waivers.txt` at the repo root (`<file> | <function> | <reason>`, committed, reviewed); the gate honours a waiver only at 100% coverage, so it never hides untested code. His published rules also put test-first back into the coder's job, which the coder prompt now follows.

The DRY gate scores pairs of functions by structural similarity (names, locals and literals drop out; calls, operators and shape stay). With `--base` only pairs that touch a line the story added or edited fail; duplication already in the codebase is listed, not gated.

### Other stacks

Complexity is lizard in every stack (27 languages, pure Python, auto-installed into `.crap/venv`). Coverage is whatever the repo already exports; hand it to the gate:

```bash
scripts/gauntlet/crap-gate.sh --lcov coverage/lcov.info src        # c8/nyc/jest/vitest, coverage.py lcov, gcov
scripts/gauntlet/crap-gate.sh --cobertura build/coverage.xml src   # JaCoCo, .NET, coverage.py xml
scripts/gauntlet/crap-gate.sh --xcresult .crap/cov.xcresult Sources  # iOS/macOS APP project
```

dryer reads Clojure, Java, Go, TypeScript, Rust, Python and Swift; `dry-gate.sh` exits 2 for a tree it cannot read.

Mutation validation is language-neutral: Muter v16 capture for Swift, or `run-report` for a committed command producing Mutation Testing Report v1/v2 JSON. A StrykerJS runner is bundled. Other tools need compatible reporters/adapters; being listed is not support. No zero/not-run pass. Read `references/mutation-evidence.md` for setup, source-scope policy and limits.

## Setup

1. Copy this skill's `scripts/` into `<repo>/scripts/gauntlet/`; keep helpers together. Ignore `.crap/` (gate environments/exports, dryer's snapshot) and `.gauntlet/` (run state). **Commit the scripts and ignores** before `start`: fresh worktrees see only committed files. The scorer `crap.py` is vendored from [crap-check](https://github.com/n0an/crap-check), pinned in its header; no second install is needed. With crap-check installed, cleaner can also use its repair loop.
2. Require Python 3.8+ for mutation evidence and Python 3.11+ for the DRY gate: its first run installs dryer at a pinned commit into `.crap/dryer-venv` (network needed once; `GAUNTLET_DRYER` points at an existing dryer instead). Both gate venvs upgrade pip (>= 26.2.2) and certifi (>= 2026.10.19) before installing anything. Swift needs its toolchain and Muter v16 (`brew install muter-mutation-testing/formulae/muter`, verify version). Optional: `brew install swiftlint` for structure rules.
3. Gate a module: `scripts/gauntlet/crap-gate.sh <ModuleName>` runs lizard, `swift test --enable-code-coverage`, `llvm-cov export` (never `--summary-only`, it strips per-function data) and the scorer. Env: `GAUNTLET_MODULES_DIR` (default `Modules`), `GAUNTLET_CRAP_THRESHOLD` (6), `GAUNTLET_COV_FLOOR` (70).

**On an app project, SPM mode cannot run - use `--xcresult`.** `swift test` builds nothing for an app target, and nothing for a package whose dependencies are iOS-only, so there is no profdata for llvm-cov. Such a project tests through the simulator, and its coverage lives in an `.xcresult`:

```bash
xcodebuild test -workspace App.xcworkspace -scheme App \
  -destination 'platform=iOS Simulator,name=iPhone 17 Pro' \
  -enableCodeCoverage YES -resultBundlePath .crap/cov.xcresult

scripts/gauntlet/crap-gate.sh --xcresult .crap/cov.xcresult Packages/Networking/Sources
```

Source directories also filter `xccov` paths to avoid per-file calls across the whole app; override with `GAUNTLET_XCCOV_INCLUDE`. In `.xcresult` mode `GAUNTLET_COV_FLOOR` is ignored: per-function CRAP is the gate.
4. Mutation: follow the adapter setup in `references/mutation-evidence.md`. Commit config, source and tests; capture with `mutation-evidence.py run-muter` (Swift) or `run-report` (standard JSON). Both bind to printed `MUTATION_BASE` and HEAD. Then hand off with regular tests; never relabel captures after commits.

Exit codes: 0 passed, 1 something over threshold, 2 could not measure (missing sources, red tests, no coverage export). A function flagged `not in the coverage report` means the test run never loaded that file - a build problem, not a testing gap.

## Practical notes

- Keep stories small (one story, 3-7 scenarios). Cost of change is ~zero; iterate instead of plan-maxing. `--approve-spec` costs one human read of 3-7 scenarios and saves a whole run on a misread story.
- Run gates one at a time, never two at once in one worktree, and never swap a gate for a homegrown measurement.
- Specs are **throwaway scaffolding**, not documentation: the feature file lives for one story cycle; the code is the only source of truth. Don't build a spec↔code sync habit - it never pays off.
- Prefer running the loop in fast, host-testable modules (SPM packages, workspace packages): mutation testing rebuilds per mutant, so test-loop speed decides whether the hardener is affordable. Each worktree also pays its own cold build and `.crap/venv`; that is the price of isolation, so `finish` runs as soon as the branch is reviewed.
- A stage that went wrong is restarted with `stage <slug> <stage> --retry` (the failed attempt stays under `refs/gauntlet/<slug>/<stage>/attempt-N`); a lost orchestrator recovers with `status`.
- In Claude Code with this repo installed as a plugin, the whole pipeline is one command: `/gauntlet <story text>` (add `--architect`, `--qa`, `--approve-spec` as needed). Elsewhere, any harness that can run staged sessions drives the same five `gauntlet.sh` commands by hand.

Files in this skill

  • SKILL.md9.5 KB
  • agents/openai.yaml316 B
  • references/handoff-protocol.md10 KB
  • references/mutation-evidence.md11.9 KB
  • scripts/crap-gate.sh7.3 KB
  • scripts/crap.py24.4 KB
  • scripts/gauntlet.sh22.1 KB
  • scripts/mutation-evidence.py23.7 KB
  • scripts/mutation-runner.template.json214 B
  • scripts/muter.conf.template.yml852 B
  • scripts/stryker-runner.mjs1.2 KB
  • scripts/swiftlint-gauntlet.yml794 B
  • stages/cleaner.md3.5 KB
  • stages/coder.md2.8 KB
  • stages/hardener.md3.7 KB
  • stages/qa.md2.3 KB
  • stages/specifier.md2.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.