---
title: "Try the sample test"
description: "Practice with a small app: run it, reproduce a duplicate ticket, and verify the fix."
canonical: "https://agenttwin.si/docs/example/"
---

# Try the sample test

Practice with a small app: run it, reproduce a duplicate ticket, and verify the fix.


This optional walkthrough uses an included Node.js app with fake customer data and simulated services. It does not test your project. To connect your own repository, [start with project setup](/docs/quickstart/).

Use Node.js 24.11 or newer for this walkthrough. You do not need an AgentTwin account, Docker or cloud credentials. Run the commands in a separate practice folder.

The app should create **one support ticket and one Slack notification**. A delayed response causes an unsafe retry to create two tickets; you will fix that retry while keeping the checks unchanged.

## 1. Create the sample app

Run from a working directory where AgentTwin can save its local records:

```sh
npx agenttwin example --out ./agenttwin-example
npx agenttwin contracts --file ./agenttwin-example/reusable.world.json --json
```

The example includes application source, a reusable world specification and `support.scenario.json`. Read the files before execution. The operation matrix establishes which requests the adapters actually support.

The primary `agenttwin.world.json` is clean by default. Compare the same source and assertions with and without the fault:

```sh
npx agenttwin run --file ./agenttwin-example/agenttwin.world.json --seed 00000000000000000000000000000001 --json
npx agenttwin run --file ./agenttwin-example/agenttwin.world.json --fault timeout-after-write --seed 00000000000000000000000000000001 --json
```

Expect exit 0 with one ticket and one notification, then exit 1 with two tickets and a triggered timeout-after-write fault. `--fault none` explicitly disables an active fault; `--fault <name>` selects a declared `faults` preset or the active fault type, and `--fault configured` selects the active fault. Unconfigured selections are rejected. Verification needs the same selection (for example `verify --file RECEIPT --world ./agenttwin-example/agenttwin.world.json --fault timeout-after-write`); replay automatically uses the effective world saved beside its receipt. No assertions change between the two runs.

The separate `reusable.world.json` used below retains the active fault for the lifecycle and application-repair walkthrough.

## 2. Save the starting data

```sh
npx agenttwin scenario save --file ./agenttwin-example/support.scenario.json --json
npx agenttwin world create --file ./agenttwin-example/reusable.world.json --scenario support_retry@1 --ttl 3600 --json
```

Keep the returned world ID. Endpoints and generated credentials belong to this test world. Keep credentials private. The services run on loopback; the application runs on your computer, with host filesystem and network access.

## 3. See the failure

```sh
npx agenttwin world run --id WORLD_ID --json
npx agenttwin receipt --id RUN_ID --json
```

Replace the uppercase placeholders with returned IDs. The first run is expected to fail: the ticket write commits, its response is delayed, and a retry without a stable idempotency key creates another ticket. Find the expected one-ticket outcome, actual two-ticket count and ordered service events. An intentional failed test is useful evidence, not a setup error.

## 4. Fix the sample app

Open `agenttwin-example/workflow.mjs`. The generated example contains a `safe` flag: set its assignment to `const safe = true` to activate the stable-key request and retry. Review that code to understand the repair. In your own application, implement the same behavior in the actual retry path rather than adding an example flag.

Leave the world specification, assertions and scenario version unchanged. Reusing the same baseline makes the before/after comparison meaningful.

```sh
npx agenttwin world run --id WORLD_ID --json
npx agenttwin receipt --id NEW_RUN_ID --json
npx agenttwin verify --file .agenttwin/runs/NEW_RUN_ID/run.json --world ./agenttwin-example/reusable.world.json --scenario support_retry@1 --json
```

Expect one ticket, one notification and unchanged customer records. Check that the source digest changed while specification and scenario digests stayed fixed. Verification recomputes evidence and checks freshness; it is not independent execution attestation.

## 5. Keep the result and clean up

Open [Runs](/dashboard/) and import the broken and fixed `run.json` receipts, or connect your account and use `npx agenttwin sync`. Manual imports stay in the browser session. Compare final state, checks and recorded steps, not just the green status.

```sh
npx agenttwin world teardown --id WORLD_ID --json
```

Teardown closes the world endpoints. Keep receipts as evidence. Next, [prepare your own workflow](/docs/preparation/) or read about [scenario versions](/docs/scenarios/).
