/prompt-ab:prompt-ab [variant name | vanilla | report]from prompt-ab
Use whenever the user wants to know whether a change to a system prompt, CLAUDE.md, AGENTS.md or output style actually changed the model output, even if they do not ask for a measurement. Trigger on "A/B this prompt", "test my system prompt", "compare these CLAUDE.md versions", "does this rule actually work", "is this technique worth adopting", in Polish on "przetestuj ten prompt A/B", "czy ta zmiana w CLAUDE.md coś zmieniła", "porównaj dwie wersje promptu", on any request to adopt a prompt rule from an article, video or colleague, and when the user is about to edit CLAUDE.md and wonders whether it is worth it. It runs one fixed task through each prompt variant headlessly, measures the noise floor first so a random difference is never reported as an effect, counts what changed (visible text, reasoning, tics, em dashes, structure, reference codes) and renders every answer side by side with a prompt diff. Do NOT use it to judge which answer is better written: counters cannot rank quality.
Ships in prompt-ab. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A/B harness for prompt-layer changes. It answers one question: did this edit change the output, or am I looking at randomness?
A single run proves nothing. In the session that produced this skill, the same variant on identical input returned 1026 and 1721 output tokens on two consecutive runs, a 68% spread. The first run alone read as a 55% improvement. It was noise.
So the harness always measures a noise floor before it reports a difference.
CLAUDE.md and want to know whether it does anything.Pick the workdir. Use ./prompt-ab in the user's project and always pass it as --workdir, before the subcommand. Without it the workdir is ./prompt-ab under whatever directory the command runs in. The skeleton is created on first run.
Write task.md. The user prompt, with {ARTICLE} where the input text goes. Put the input in article.md.
The task must exercise the rules being tested. A summarize-an-article task measures verbosity and nothing else; it will not tell you whether an alias, a decision-format rule, or a scope boundary works. Match the task to the rule.
Write variants/<name>.md. Each file is appended via --append-system-prompt-file, on top of whatever CLAUDE.md is already loaded. Variants add; they never replace. To test an output style, write variants/<name>.settings.json (e.g. {"outputStyle": "Learning"}) instead or alongside: it is passed with --settings, because a style replaces part of the base prompt and cannot be appended.
Run. Baseline (no appended file) is computed once with repeats and cached. Each variant costs one call per iteration. Every call is a real claude -p run: it spends the user's quota.
python3 "${CLAUDE_SKILL_DIR}/scripts/ab.py" --workdir ./prompt-ab run v1 --ref-repeat 3 --repeat 1
python3 "${CLAUDE_SKILL_DIR}/scripts/ab.py" --workdir ./prompt-ab run v2 --repeat 1
python3 "${CLAUDE_SKILL_DIR}/scripts/ab.py" --workdir ./prompt-ab diff baseline v1 v2
On Windows use python or py -3 in place of python3.
Read the noise floor first. The spread column is each arm's own min..max over its runs. The baseline row's spread is the noise floor: a variant whose text tok median falls inside it is indistinguishable from randomness, no matter how good the percentage looks. A variant's own spread says how stable that variant is; with one run it reads n=1, so treat that result as provisional.
Read the answers, not only the table. report.html renders every variant side by side. The table says what changed; only the text says whether you want it.
These are the reason this skill exists. The script is replaceable; this list is not.
Pin --effort explicitly on every arm. Otherwise you measure reasoning, not prompt. Measured: the same setup produced 1600 tokens of reasoning at xhigh against 384 at default, while emitting less visible text. If one arm inherits settings.json and another does not, the comparison is worthless.
--setting-sources project is the only thing that cuts CLAUDE.md (both global and project). Verified by probe: without it the agent answers yes to "do your instructions contain ", with it, no. But it also drops settings.json, which silently changes effort. That is two variables, so a "vanilla" arm is not comparable to a "baseline" arm unless effort is pinned on both. run vanilla passes this flag and the same explicit --effort as the baseline; each run records its effort, and a cached arm measured at another level is flagged.
output_tokens is not answer length. It bundles reasoning. Split it: estimate visible-text tokens from the text itself and treat the remainder as reasoning. A variant can cut visible text while raising total tokens.
Recompute metrics from the stored text, never read them from the stored JSON. Then changing a metric definition reapplies to every historical run for free, instead of costing a re-run.
The input text must not be about the thing being measured. A tic counter run over an article that discusses those exact tics counts the topic, not the style. Discount quoted and backticked spans as well.
Cache the baseline. It does not change between iterations. Recompute it only when the task, the article, or the effort level changes, via --force-base.
Negative rules are weak. A NEVER use X rule sat loaded in context and was violated five times in one answer. Rewrite each prohibition as an instruction naming the substitute: not "do not use em dashes" but "where a dash is needed, use a comma, a colon, parentheses, or a plain hyphen". This is Anthropic's own guidance and it is measurable here.
Tic lists do not transfer between models. The phrases one model overuses are not the phrases another overuses. Harvest the list from that model's own output rather than copying someone else's.
total_cost_usd is a valuation, not an invoice. On a subscription these runs consume quota, priced at published API rates for reporting only. Say "quota" unless an API key is actually set.
Skills are off by default, and that is not neutral. Runs pass --disable-slash-commands, verified by probe: the agent answers "No" to "is skill X available", and "Yes" without the flag. That isolates the prompt, but it also means the baseline measured here is not the baseline you actually work in, because a skill that reshapes output never gets to run. Use --with-skills when the question is "what happens in real conditions" rather than "what does this prompt do".
Report the run nearest the median, never the last one. A card showing the last run contradicted its own table: one variant had a median of 379 tokens and a last run of 643, so the column read as longer than baseline when the median said 37% shorter. Pick the representative run and label which one it is.
Reference codes must not leak into anything durable. If a variant teaches the model to tag items F1/R2, keep those out of stored memory, notes, commits and PR bodies. They are conversation-scoped and become dangling references everywhere else.
| Command | Effect |
|---|---|
run <variant> | Runs baseline (cached) then the variant; writes both reports |
run <variant> --repeat N | N iterations of the variant |
run <variant> --ref-repeat N | N iterations of baseline; this sets the noise floor |
run <variant> --force-base | Discards the cached baseline and recomputes |
run <variant> --with-skills | Leaves skills enabled: real working conditions, not the prompt alone |
run vanilla | Built-in reference arm with no CLAUDE.md at all, for diagnosis. Needs no variant file; runs --repeat times with --setting-sources project and nothing appended |
diff <a> <b> ... | Table for the named arms only |
report [names...] | Rebuilds report.md and report.html |
Options: --workdir PATH (default ./prompt-ab) goes before the subcommand. --effort LEVEL (low/medium/high/xhigh/max, default medium, pinned on every arm), --model NAME (default opus) and --timeout SECONDS (default 600 per call) go after run.
| Column | Meaning |
|---|---|
n | Runs of that arm |
text tok | Estimated tokens of visible answer text (characters / 4), median |
spread | That arm's min..max of text tok. The baseline row is the noise floor; read it before any delta |
vs baseline | Change in visible text against the current setup |
thinking | Total output tokens minus estimated visible text, so roughly reasoning. An estimate: it can come out slightly negative on short answers |
em dash, tics | Style counters; tics discount quoted spans |
ref codes | Distinct F1/D1/R1-style codes emitted |
time | Median CLI-reported duration |
report.html carries the table plus every answer rendered side by side, in light and dark. Each column keeps its name and its metrics pinned while the answer scrolls, so a number is never read against the wrong variant.
It also records what produced the numbers, which is what makes the file readable a week later:
task.md in full and the head of article.md with its word count.report.md carries the same content with answers fenced as source. Both show the run nearest the median per arm and say which one it is (run 2/3).
Runs execute outside the project tree with --strict-mcp-config and --disable-slash-commands, so no MCP server and no skill contributes to the measurement. The loaded CLAUDE.md stays in place on every arm except vanilla by design: the question is normally "does this addition beat what I already have", not "what would a bare model do".
Python 3.10+ (python3) and the claude CLI on PATH. No third-party packages. Installed as a plugin or cloned into ~/.claude/skills/prompt-ab; either way the script is ${CLAUDE_SKILL_DIR}/scripts/ab.py.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub marcinsufa/claude-prompt-ab --plugin prompt-ab