Skip to content
Rehearsev1.2.0

For agents

An agent drives the product one step at a time, and reads one JSON object back from each step.

Terminal
$ rehearse drive start --json
{"v":1,"ok":true,"command":"start","ms":984,"file":null,"tree":null,"driver":"browser","said":null}
$ rehearse drive fill --name Search --with pens --json
{"v":1,"ok":true,"command":"fill","ms":154,"file":null,"tree":null,"driver":"browser"}
$ rehearse drive click --name "Add to basket" --json
{"v":1,"ok":true,"command":"click","ms":213,"file":null,"tree":null,"driver":"browser"}
$ rehearse drive snapshot --name Basket --role status --json
{"v":1,"ok":true,"command":"snapshot","ms":201,"file":null,"tree":"- status \"Basket\": 1 in the basket","driver":"browser"}
$ rehearse drive stop --json
{"v":1,"ok":true,"command":"stop","ms":0,"file":null,"tree":null,"driver":"browser"}

An agent uses Rehearse the way a person does, through commands that print JSON instead of a page. It looks at what the repository declares, finds what its change reaches, writes scenarios, compares, announces what it meant, and drives the product one step at a time when it needs to see.

Every command takes --json and prints one object with "v": 1 on stdout, and nothing else there. Progress (services coming up, checkouts being prepared) goes to stderr. Each output has a JSON Schema in schema/v1/, named after the command. The JSON reference describes them.

Command Prints
rehearse check --json whether the manifest reads, how many scenarios of each kind, files it couldn’t read
rehearse list --json every scenario: id, kind, name, file, area, world, person, service
rehearse list --affected <file>… --json the scenarios those files reach, each with reachedBy
rehearse services --json, people --json, worlds --json what can come up, who you can be (with tokens), where you can start
rehearse run <id> --json one observation
rehearse compare --base main --json a verdict per scenario
rehearse open <id> --json the stage’s address for a scenario
rehearse stage --json one line once the stage listens: its url, port and pid
rehearse up --json, down --json what was brought up or stopped

A refusal is one object too, and the exit code says what kind.

Terminal
{
"v": 1,
"ok": false,
"error": {
"code": "usage",
"says": "rehearse compare takes no `--bogus`. It takes --base, --head, --announce, --said, --world, --as, --real, --manifest, --affected, --fresh, --json, --help."
}
}
Exit Means
0 done, and for compare, ok
1 failed, or not ok
2 a usage mistake

rehearse validate <schema> [file] checks any file or stdin against a v1 schema, so an agent checks what it writes, such as an announcement, before it relies on it.

Terminal
rehearse services --json | rehearse validate services

Within v1, outputs only gain optional fields. Read what you know and ignore the rest.

  1. Look. rehearse check --json, then rehearse list --json.

  2. Find what the change reaches. rehearse list --since main --json. Each scenario’s reachedBy says why.

  3. Write a scenario beside what it tries, if none covers the change: a call beside the handler, a story beside the component, a flow, a file scenario. See the guides.

  4. Run it once. rehearse run '<id>' --json. ok, failures and observed say what happened.

  5. Compare. rehearse compare --base main --json, or --affected. Read line, then each scenario’s verdict.

  6. Announce what you meant to change in .rehearse/announce.yaml (or a file you pass with --announce). Compare again. Fix every unsaid you didn’t mean, and every fails where failsOnBase is false.

  7. Show a person. rehearse open '<id>' --json gives the stage’s address for the pull request or the message.

Verdict What the agent does
same nothing
said checks the differences match what it meant
unsaid fixes it, or announces it if it was meant
new checks it passes and tries the right thing
fails fixes it, unless failsOnBase is true

With rehearse drive, an agent uses the product as a person does: it looks at the screen as an accessibility tree, clicks by name, fills a field, presses a key. Each step is one command and one answer.

Step Does
rehearse drive start Brings the service up with its world, signs in as the person, opens the page. Takes --service <name> or --piece <id>, --world <name>, --as <person>, --start <path>, --on <checkout>, and --scheme light or dark (else $DRIVE_SCHEME).
rehearse drive snapshot The page’s accessibility tree; --name <name> (and --role <role>) for one element’s
rehearse drive click --name <name> Clicks the one element with that name; --role when two share it
rehearse drive fill --name <name> --with <text> Fills a field
rehearse drive type <text> Types into whatever has focus
rehearse drive key <key> Presses a key: Enter, Escape, Meta+k, ControlOrMeta+j
rehearse drive screenshot <file.png> Saves a screenshot, the path read from where you run the command
rehearse drive stop Closes the page and stops what start brought up

Without --json, a snapshot prints the tree itself.

Terminal
$ rehearse drive snapshot
- main:
- heading "Shop" [level=1]
- paragraph: Signed in as the owner
- link "Sign in":
- /url: /login
- text: Search
- searchbox "Search"
- status "Basket": 0 in the basket
- button "Add to basket"

Each step answers in the drive result shape, with v and driver added.

Result Fields
done {"ok": true, "command", "ms", "file", "tree"}, and said or errors when there is something to say
failed {"ok": false, "command", "ms", "failure", "says"}

file is the screenshot saved; tree is what a snapshot saw. errors lists what the page logged during the step. driver is browser (Rehearse’s own), service (the service’s own driver), or null when no driver answered.

command is the step. A step written wrong still names its command when its first word is one, such as key in rehearse drive key Ctrl+k; it is null only when the words name no step.

Terminal
$ rehearse drive key Ctrl+k --json
{"v":1,"ok":false,"command":"key","ms":0,"failure":"usage","says":"Drive can't press Ctrl+k: name it as Playwright does, such as Enter or Meta+k.","driver":null}

failure is one of these words.

Failure Means Exit
usage The step is written wrong 2
not_found Nothing on screen has that name; says lists what is close 1
ambiguous More than one element has it; says lists them 1
not_running Nothing is being driven: start first 1
timed_out The element didn’t answer in five seconds 1
crashed The page or the driver stopped 1

When a name isn’t on screen, says lists what is close, so the next step can be right.

Terminal
$ rehearse drive click --name "Add to baskets"
Nothing on screen is named “Add to baskets”. Close to it on screen:
button “Add to basket”
status “Basket”

When more than one element has the name, says lists them, and --role picks one.

Terminal
$ rehearse drive click --name "Sign in" --json
{"v":1,"ok":false,"command":"click","ms":4,"failure":"ambiguous","says":"More than one element is named “Sign in”: give `--role` to say which.\n heading “Sign in”\n button “Sign in”","driver":"browser"}
$ rehearse drive click --name "Sign in" --role button

drive start leaves a small browser process running between commands, listening on 127.0.0.1 with a secret only the next rehearse drive command knows, so no web page can drive it. The secret is kept in .rehearse/drive.json, which only you can read, and the browser reads each step it is sent again as words, so it takes only what the step grammar allows.

One page is driven at a time per manifest: start refuses while another runs. stop closes the browser and stops the services start brought up. If the browser stops answering, Rehearse ends it and forgets it.

stop when nothing is driven is done too, with no driver, so an agent can stop first to start clean.

Terminal
$ rehearse drive stop --json
{"v":1,"ok":true,"command":"stop","ms":61,"file":null,"tree":null,"driver":null,"said":null}

When the service names its own driver, such as pnpm drive, in the manifest’s drive:, drive start brings the service up and every step goes through that driver.

Terminal
$ rehearse drive start --service desk --as owner --json
{"v":1,"ok":true,"command":"start","ms":369,"file":null,"tree":null,"driver":"service","said":"desk's driver signs in as no one, so it isn't owner."}
$ rehearse drive fill --name Name --with x --json
{"v":1,"ok":false,"command":"fill","ms":74,"failure":"usage","says":"desk's driver takes no fill step: click the field, then type.","driver":"service"}

A driver signs in as no one, and takes no fill. See a service’s own driver.

drive start --piece '<id>' opens a piece’s canvas instead, with no service.

Rehearse ships a skill for agents at skill/rehearse/SKILL.md. It teaches, in order:

  1. looking before changing anything (check, list, services, people, worlds);
  2. finding what a change reaches (list --affected);
  3. writing each kind of scenario, with an example of each;
  4. running one, then comparing, and what to do for each verdict;
  5. announcing what you meant to change;
  6. driving the product step by step;
  7. showing a person (open);

and three rules: never print, log or commit a token from rehearse people --json; run one comparison at a time; stop what you started with rehearse down --all and rehearse drive stop.

Give it to your agent the way it takes skills. For Claude Code, copy skill/rehearse/ into the repository’s .claude/skills/.

llms.txt at the package’s root is a short index for a model to read first: every command with its options, the four kinds and their formats, the verdicts, and every schema in schema/v1/.