Fix a bug with tests
Fix a small bug, verify the result, then make the workflow your own.
An order total ignores item quantities. You'll ask an agent to repair it in a working copy, run its tests, then inspect the checked result.
Before you start: follow host setup for Bun ≥1.4.2, Node ≥22, Git and Codex subscription login. This tutorial uses 0.0.1-alpha.7 with native local execution. Commands below work in Mac/Linux terminals and PowerShell. Windows needs Git for Windows Bash. Local agent commands run with your permissions; choose Docker if you need isolation.
1. Create a project
On your host, in a directory where you keep projects:
mkdir my-checked-trial
cd my-checked-trial
bunx laufwerk@0.0.1-alpha.7 init --execution local
bunx laufwerk@0.0.1-alpha.7 doctor
bun run --cwd laufwerk checkInitialization creates laufwerk/ with the coding workflow, a hello workflow, configuration, dependencies and a stable project ID. It also installs authoring skills for coding assistants. The type check should finish without errors. Resolve any failing local readiness checks before continuing.
Keep this terminal in my-checked-trial for the remaining commands.
2. Get the small broken example
Save this as prepare.ts in your project root:
import { mkdir } from 'node:fs/promises';
await mkdir('project', { recursive: true });
for (const name of ['total.mjs', 'verify.mjs']) {
const response = await fetch(`https://www.laufwerk.dev/downloads/alpha7/first-workflow/${name}`);
if (!response.ok) throw new Error(`Download failed: ${name} (${response.status})`);
await Bun.write(`project/${name}`, await response.arrayBuffer());
}bun prepare.ts
bun test ./project/verify.mjsThe tests should fail here. The function adds prices but ignores quantities. The first test expects 52, but gets 20. This is the bug the agent will fix. The host uses Bun for this check; the agent environment will use node --test.
3. Run the coding workflow
Save this as run.ts. A script passes the same JSON on every shell:
const input = {
executionKey: 'total-1',
source: 'project',
request: 'Fix total.mjs so each item price is multiplied by its quantity. Keep verify.mjs unchanged. Make no other changes.',
verify: 'node --test verify.mjs',
};
const child = Bun.spawn([
process.execPath, 'x', 'laufwerk@0.0.1-alpha.7',
'run', 'coding', '--input', JSON.stringify(input),
], { stdout: 'inherit', stderr: 'inherit' });
process.exit(await child.exited);bun run.tsThe workflow opens a working copy, asks Codex to implement the change, runs verification in that environment, closes the session and writes back only after verification succeeds. Initial package downloads can take several minutes; the tested Mac took roughly 4–7 minutes for successful live checks. This is not a latency guarantee.
The CLI prints a run ID and the outcome. Expect completed (healthy). The exact run ID and model wording will differ. If the run fails, inspect the error with the debugging guide; do not delete its state or rerun indefinitely.
4. Check the result yourself
cat project/total.mjs
bun test ./project/verify.mjsExpect all three tests to pass. The function should now account for quantity, for example:
export function total(items) {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}The model may choose equivalent code. Review the actual change and confirm the tests were not modified. This fixture is a teaching exercise, not protection against an adversarial agent rewriting its verifier. The documentation repair example explains a stricter change boundary.
5. See what happened
bunx laufwerk@0.0.1-alpha.7 status
bunx laufwerk@0.0.1-alpha.7 studioOpen the local URL Studio prints. Find the coding run, inspect the model's work and the verification operation. Studio runs on your machine; it is not a hosted dashboard. Use port forwarding if your workflow runs remotely.
For live terminal progress, use a second terminal in this same project:
bunx laufwerk@0.0.1-alpha.7 status RUN_ID --watchReplace RUN_ID with the ID returned by your run.
6. Change the request
In run.ts, change executionKey to total-2 and the request to: “Add a short comment above total explaining that it sums prices multiplied by quantities. Keep the tests unchanged.” Run bun run.ts again.
A new attempt needs a new execution key. The same key refers to the same recorded execution, even if you edited the prompt or workflow. total-2 is a new run. Use the existing ID when inspecting or recovering the original run.
To see the failure boundary, use another new key and set verify to exit 1. The run should fail and its candidate change must not appear in your host project.
What you just built
Your request → agent working copy → deterministic test → checked write-back
↓ failure
stop, inspectYou supplied the task and the definition of success. Laufwerk supplied the recorded execution, agent environment and explicit write-back boundary. Your next workflow uses the same pieces with your own rules.