Tutorial 1 — Your first Bench, no API key required
Goal: write your first madbench Bench from scratch and run it end-to-end in under two minutes, with zero cost and zero network calls.
You will learn: the shape of madbench.yaml, what the mock Harness is for, and the five string-shaped Checks you will use most often (contains, not-contains, starts-with, regex, assert-set).
Prerequisites: the madbench binary on your PATH. Run madbench --version to confirm.
Why start with a mock?
A madbench Bench has two moving parts: the Harness (the agent under test) and the Checks. Most bugs in a new Bench are in the YAML, not the agent. The mock Harness lets you debug the YAML side in isolation — it just echoes the prompt back as the agent's final output, costs nothing, and runs offline.
If mock works, your YAML is well-formed and your Checks match the strings you think they do. Only then is it worth spending tokens on a live Harness.
Step 0 — Create a fresh project
A madbench project is just a directory with a madbench.yaml in it. From wherever you keep your scratch work:
mkdir hello-mock
cd hello-mock
That is the entire setup.
Step 1 — Write your first madbench.yaml
Create madbench.yaml in the project directory with the following contents. Type it out rather than copying it — the indentation and the - type: / value: shape is the muscle memory you want.
description: "Hello Claude - Basic Checks" # human label for the Bench
harness: mock # echo prompt -> final output, no API call
scenarios:
- description: "Agent says hello"
prompt: "Hello, world! This is a test of madbench." # mock echoes this back verbatim
checks:
- type: contains # final output contains the substring
value: "Hello"
- type: contains
value: "madbench"
- type: not-contains # final output does NOT contain the substring
value: "goodbye"
- type: starts-with # final output begins with the substring
value: "Hello"
- type: regex # final output matches the regex
value: '(?i)hello.*madbench' # (?i) = case-insensitive
Five Checks, all string-shaped, all running against Session.FinalOutput — the agent's last message. Because harness: mock echoes the prompt as the final output, you can hand-verify each Check in your head before running.
The contract for string Checks is always the same: they grade
Session.FinalOutput. If you remember nothing else, remember that —contains "Hello"doesn't search the session, doesn't search files, it searches the agent's final message. Tutorial 2 introduces a different family that grades the session.
regexuses Go'sregexpsyntax, which is RE2. No backreferences, no lookaround. If you write Perl-ish regex it will compile (or fail to) but not behave the way you expect.
Step 2 — Run it
madbench
That's the whole command. With no arguments, madbench looks for madbench.yaml (or madbench.yml) in the current directory and runs it. Expected:
Bench: Hello Claude - Basic Checks
✓ PASS Agent says hello
1 passed, 0 failed
If you see this, the toolchain works and your YAML is well-formed. If you don't, the error message will point at a line number in madbench.yaml — fix and rerun.
Step 3 — Add the refusal test
Append a second scenario to the scenarios: list in your madbench.yaml:
- description: "Refusal detection"
prompt: "I cannot help with that request. I'm sorry, but I refuse."
checks:
- type: is-refusal
is-refusal is a built-in pattern matcher for "the model declined to do the work" messages — it scans for phrases like "I cannot", "I'm sorry, but", "I refuse". Useful when you want to assert the agent did refuse (red-team Benches) or did not refuse (helpfulness Benches — wrap it in not-any-of, see Tutorial 4).
Re-run madbench. You should now see two scenarios pass.
Step 4 — Composite scoring with assert-set
Append a third scenario:
- description: "Composite Check set"
prompt: "The answer is 42"
checks:
- type: assert-set
threshold: 0.66 # at least 2/3 children must pass
checks:
- type: contains
value: "42" # passes
- type: contains
value: "answer" # passes
- type: contains
value: "missing-value" # fails — substring not in prompt
assert-set is the "fuzzy AND" — it groups N children and passes when at least threshold of them clear (here: 2/3 = 0.66). It fits Scenarios where you have several plausible signals and any majority is good enough. Tutorial 4 contrasts this with any-of (1-of-N) and not-any-of (0-of-N).
Re-run. All three scenarios should now pass:
Bench: Hello Claude - Basic Checks
✓ PASS Agent says hello
✓ PASS Refusal detection
✓ PASS Composite Check set
3 passed, 0 failed
Step 5 — Break it on purpose
The fastest way to internalize how Checks report failures is to make one fail. Edit the first Scenario's last Check in your madbench.yaml:
- type: regex
value: '^GOODBYE' # was: '(?i)hello.*madbench'
Re-run. You should see:
✗ FAIL Agent says hello
✓ contains: contains: pass
✓ contains: contains: pass
✓ not-contains: not-contains: pass
✓ starts-with: starts-with: pass
✗ regex: regex did not match
The Reason column is what you debug from in real Benches. Restore the value before moving on.
Step 6 — Inspect the JSON report
madbench --report-json out/hello.json
cat out/hello.json | jq '.results[0].checks[] | {type, pass, reason}'
You should see one object per Check. The fields you will care about across every tutorial:
type— which Check ranpass— booleanreason— short string, your first stop when something failsscore— float in[0, 1], used by composite Checks likeassert-set
The
scorefield exists for every Check, even the binary ones (where it is 0 or 1). Composite Checks aggregate child scores, so aregexthat "barely passes" still contributes 1.0 —scoreonly spreads in Checks that compute it (latency, cost, llm-rubric).
What you now know
| Concept | Where it appears |
|---|---|
harness: mock | Bench-level — picks the Harness adapter |
scenarios: array | Bench has N Scenarios, each scored independently |
prompt | What the Harness sees |
checks: | List of Checks, one per entry |
contains / not-contains / starts-with / regex / is-refusal | String-shaped Checks |
assert-set (with threshold) | Composite, "K of N must pass" |
What you do not yet know
A mock Harness cannot grade a real agent. The next thing every Check you wrote is missing: the agent had no testdata, no tools, and no work to do. Tutorial 2 introduces the claude-code Harness, the sandbox/testdata mechanism, and your first cost meter.