
Illustrative test design

List every step that can't be undone (money moves, an email or Slack message goes out, a record is created in another system), then ask what happens when each one runs twice. You can do that by hand, or let a tool find the steps and try the failures for you.
By hand
- Inventory the side-effecting steps. Charges, refunds and transfers. Emails, texts and Slack messages. Records created in CRMs and ticket systems. Read-only steps (searching, summarizing, reading) are safe to repeat; ignore them.
- Find what can repeat a step. Retries after timeouts and 5xx errors, rate limits, a webhook delivered twice, a crash and resume, a person or agent asking again.
- Check each step for a guard. An idempotency key, a unique constraint, or a "have I done this?" lookup before acting.
- Order by cost. Money first, then customer-facing messages, then internal records.
Automatically
npx agenttwin does these four steps for your repository. It scans for the services your code calls and the workflows that reach them (routes, webhooks, jobs and existing test suites), tests the top three by default, and prints each finding with an estimated cost per incident and the file and line. Discovery never runs your code or uploads source.
A report from a demo support agent (written for AgentTwin's product films, run on AgentTwin 0.3.38) looked like this:
$64.50 per incident Your agent announced on Gmail although the Stripe refund never happened (Stripe returned a 500)
$60.00 per incident The Stripe refund never happened when Stripe returned a 500
$48.00 per incident Your agent refunded ch_at_1001 twice
$0.75 per incident Your agent posted the same Slack message twice
Costs are estimates, and the report lists its assumptions (for example, engineering time at $120 an hour, and the share of incidents that reach support).
Related: Choose your first AI-agent workflow test and Idempotency keys.