One prompt runs on a fresh fork for each task. Each fork starts from the same disk, runs the agent, then runs the repository’s tests. The output is a pass or fail table.
Before you start
Section titled “Before you start”- An approved account and an API key from the API keys page.
- A base VM with your repository in
/home/user/app, its dependencies installed, and Claude Code signed in. Follow steps 1 and 2 of Fix a failing test with Claude Code, then clone the repository and install its dependencies in the same VM. - A test command,
npm test, that exits with0when the repository passes. A fork passes when that command exits with0. - Python 3.12 with
requests, Node 22 for the TypeScript tab, orjqfor the curl tab.
Set these once in your terminal. The prompt must not contain a single quote, because the job wraps it in quotes.
export SI_API_KEY=si_...export BASE=<base-vm-id>export PROMPT='Fix the failing test in this repository. Do not change the tests.'1. Fork a VM per task
Section titled “1. Fork a VM per task”Create one fork of the base VM for each task. Each fork is named eval-1, eval-2 and so on, and carries the label run=eval. The label lets the next steps find the forks.
for NUMBER in 1 2 3; do curl -sS -X POST "https://api.slashinfra.com/svms" \ -H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \ -d "{\"name\":\"eval-$NUMBER\",\"fork_of\":\"$BASE\",\"labels\":{\"run\":\"eval\"}}" echodoneAPI reference: Control API operation
import os, requests
for number in [1, 2, 3]: res = requests.post( "https://api.slashinfra.com/svms", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, json={"name": f"eval-{number}", "fork_of": os.environ["BASE"], "labels": {"run": "eval"}}, ) res.raise_for_status() print(res.text)for (const number of [1, 2, 3]) { const res = await fetch('https://api.slashinfra.com/svms', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ name: `eval-${number}`, fork_of: process.env.BASE!, labels: { run: 'eval' } }), }) if (!res.ok) throw new Error(`fork failed: ${res.status}`) console.log(await res.text())}{"id":"6f1c0f0e8a","name":"eval-1","generation":1,...}{"id":"7h2d1g1f9b","name":"eval-2","generation":1,...}{"id":"8j3e2h2g0c","name":"eval-3","generation":1,...}Each fork starts with the files of the base VM. Its writes stay in its own VM, so the forks do not see each other’s changes.
2. Run the prompt and the tests
Section titled “2. Run the prompt and the tests”In each fork, start a job that runs the agent and then npm test. The job’s exit code is the exit code of npm test, because the agent’s own exit code does not decide the result. The forks run at the same time. The table lists each fork and its result. --permission-mode bypassPermissions lets Claude Code edit files and run commands without asking. A job has no one to answer a prompt, and the agent works inside its own VM.
SCRIPT="cd /home/user/app && claude -p --permission-mode bypassPermissions '$PROMPT'; npm test"LISTING=$(curl -sS "https://api.slashinfra.com/svms?label.run=eval" -H "Authorization: Bearer $SI_API_KEY")
echo "name result exit"RUNS=$(jq -r '.svms[] | "\(.id) \(.name)"' <<<"$LISTING")while read -r ID NAME; do JOB=$(curl -sS -X POST "https://$ID.slashinfra.dev/usr/bin/job?cwd=/home/user&arg=-q" \ -H "Authorization: Bearer $SI_API_KEY" --data-binary "$SCRIPT") while HEADERS=$(curl -sS -D - -o /dev/null -X POST "https://$ID.slashinfra.dev/usr/bin/job?arg=wait&arg=$JOB" \ -H "Authorization: Bearer $SI_API_KEY"); grep -qi '^X-Timeout: 1' <<<"$HEADERS"; do :; done CODE=$(grep -i '^X-Exit-Code' <<<"$HEADERS" | cut -d' ' -f2 | tr -d '\r') if [ "$CODE" = "0" ]; then RESULT=pass; else RESULT=fail; fi printf '%-8s%-8s%s\n' "$NAME" "$RESULT" "$CODE"done <<<"$RUNS"API reference: Control API operation
import os, requests
def start_job(vm_id: str, script: str, cwd: str) -> str: res = requests.post( f"https://{vm_id}.slashinfra.dev/usr/bin/job", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, params={"cwd": cwd, "arg": "-q"}, data=script.encode(), ) res.raise_for_status() return res.text.strip()
def wait_for_job(vm_id: str, job: str) -> int: while True: res = requests.post( f"https://{vm_id}.slashinfra.dev/usr/bin/job", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, params=[("arg", "wait"), ("arg", job)], ) res.raise_for_status() if "X-Timeout" not in res.headers: return int(res.headers["X-Exit-Code"])
listing = requests.get( "https://api.slashinfra.com/svms", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, params={"label.run": "eval"},)listing.raise_for_status()
script = f"cd /home/user/app && claude -p --permission-mode bypassPermissions '{os.environ['PROMPT']}'; npm test"runs = [(svm["name"], svm["id"], start_job(svm["id"], script, "/home/user")) for svm in listing.json()["svms"]]
print("name result exit")for name, vm_id, job in runs: code = wait_for_job(vm_id, job) result = "pass" if code == 0 else "fail" print(f"{name:<8}{result:<8}{code}")type Svm = { id: string; name: string }
const auth = { Authorization: `Bearer ${process.env.SI_API_KEY!}` }
async function startJob(vmId: string, script: string, cwd: string): Promise<string> { const url = `https://${vmId}.slashinfra.dev/usr/bin/job?cwd=${encodeURIComponent(cwd)}&arg=-q` const res = await fetch(url, { method: 'POST', headers: auth, body: script }) if (!res.ok) throw new Error(`job start failed: ${res.status}`) return (await res.text()).trim()}
async function waitForJob(vmId: string, job: string): Promise<number> { const url = `https://${vmId}.slashinfra.dev/usr/bin/job?arg=wait&arg=${job}` for (;;) { const res = await fetch(url, { method: 'POST', headers: auth }) if (!res.ok) throw new Error(`wait failed: ${res.status}`) if (!res.headers.has('X-Timeout')) return Number(res.headers.get('X-Exit-Code')) }}
const listing = await fetch('https://api.slashinfra.com/svms?label.run=eval', { headers: auth })if (!listing.ok) throw new Error(`list failed: ${listing.status}`)const { svms } = (await listing.json()) as { svms: Svm[] }
const script = `cd /home/user/app && claude -p --permission-mode bypassPermissions '${process.env.PROMPT!}'; npm test`const runs: { fork: Svm; job: string }[] = []for (const fork of svms) { runs.push({ fork, job: await startJob(fork.id, script, '/home/user') })}
console.log('name result exit')for (const { fork, job } of runs) { const code = await waitForJob(fork.id, job) console.log(`${fork.name.padEnd(8)}${(code === 0 ? 'pass' : 'fail').padEnd(8)}${code}`)}name result exiteval-1 pass 0eval-2 fail 1eval-3 pass 03. Clean up
Section titled “3. Clean up”Delete the forks. The base VM stays, so you can run the evals again. Delete it with DELETE /svms/{id} when you no longer need it.
for ID in $(curl -sS "https://api.slashinfra.com/svms?label.run=eval" -H "Authorization: Bearer $SI_API_KEY" | jq -r '.svms[].id'); do curl -sS -o /dev/null -w "%{http_code}\n" -X DELETE "https://api.slashinfra.com/svms/$ID" -H "Authorization: Bearer $SI_API_KEY"doneAPI reference: Control API operation
import os, requests
auth = {"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}listing = requests.get("https://api.slashinfra.com/svms", headers=auth, params={"label.run": "eval"})listing.raise_for_status()for svm in listing.json()["svms"]: print(requests.delete(f"https://api.slashinfra.com/svms/{svm['id']}", headers=auth).status_code)const auth = { Authorization: `Bearer ${process.env.SI_API_KEY!}` }const listing = await fetch('https://api.slashinfra.com/svms?label.run=eval', { headers: auth })if (!listing.ok) throw new Error(`list failed: ${listing.status}`)const { svms } = (await listing.json()) as { svms: { id: string }[] }
for (const svm of svms) { const res = await fetch(`https://api.slashinfra.com/svms/${svm.id}`, { method: 'DELETE', headers: auth }) console.log(res.status)}204204204Check it works
Section titled “Check it works”The table has one row for each fork, and each row shows pass or fail with the exit code of its npm test. To compare runs, delete the forks with step 3, then run steps 1 and 2 again and compare the two tables.
If it doesn’t work
Section titled “If it doesn’t work”| Symptom | Cause | Fix |
|---|---|---|
409 on step 1 |
A fork named eval-1 already exists. |
Run step 3, then step 1 again. |
Every row shows fail with 127 |
npm or claude is missing from the path of the job. |
Run npm --version and claude --version in the base VM. |
| Every row fails at once | The prompt contains a single quote, which ends the quoted text in the job script. | Remove the quote from PROMPT, then run steps 1 and 2 again. |
Scroll horizontally to see all columns.
- Background work: the jobs that run each fork, and the log of each job.
- Snapshots: keep a base VM as a snapshot, so you can fork it later.
- Software factory: the same forks, each ending in a pull request.