quiet robot

Sandboxes

Safety recipes

Five worked examples that put limits and people in the loop: watch a limit stop a runaway loop, get sign-off before shipping, rehearse a database change on a copy, sort support tickets with AI, and take a first look at an alert.

View as Markdown

Sandboxes is in early access. It is free to try, some parts are still in testing, and details may change. Sign up free

Each recipe below says what it does, shows its shape, walks through its steps, and ends with how to make it your own. See Recipes for how recipes work, and Limits and safety for the protections they use.

Runaway loop

The pattern: a limit stops a loop that would never end. Run this once to see what happens when something goes wrong, so you know what to expect.

Runaway loopStart (Run command), Try again (Run command), Check (Run command), Done (Output). Arrows: Start to Try again; Try again to Check; Check to Try again on Failed; Check to Done on Passed.FailedPassed>_ RUN COMMANDStartgo back here>_ RUN COMMANDTry again>_ RUN COMMANDCheck⚑ OUTPUTDone
Runaway loop
StepBlockWhat it does
StartRun commandSets up a job whose check will always fail, like a service that's down.
Try againRun commandCounts the attempt and backs off a little longer each time.
CheckRun commandFails every time: "connection refused".
DoneOutputNever reached.

Limits: 4 loops, 120 seconds, $0.05. If stopped, go back to: Start.

What you'll see: the loop goes round four times, then the run ends as Stopped at a limit, with the loop limit named as the reason. The sandbox is rewound to the checkpoint after Start, so none of the half-finished attempts are left behind. Simulate first and the forecast tells you, before you run, that nearly every run will hit the loop limit.

Make it yours: this recipe is for learning. In your own flows, every loop should have a limit you'd be happy to hit, and a Go back here if a limit stops the run on the last step that leaves things clean.

Fix, review, ship

The pattern: a loop, then a person. The code is fixed automatically, but nothing ships until someone approves.

Fix, review, shipSet up project (Run command), Run tests (Run command), Write a fix (Run code), Ship it? (Approval), Package (Run command), Not shipped (Output). Arrows: Set up project to Run tests; Run tests to Write a fix on Failed; Write a fix to Run tests on Passed; Run tests to Ship it? on Passed; Ship it? to Package on Approved; Ship it? to Not shipped on Denied.FailedPassedPassedApprovedDenied>_ RUN COMMANDSet up project>_ RUN COMMANDRun tests{ } RUN CODEWrite a fix✋ APPROVALShip it?>_ RUN COMMANDPackage⚑ OUTPUTNot shipped
Fix, review, ship
StepBlockWhat it does
Set up projectRun commandWrites slugify.py with a bug, and its tests.
Run testsRun commandRuns the tests.
Write a fixRun codeWrites the next fix, then goes back to the tests.
Ship it?Approval"Ship this fix? The tests pass."
PackageRun commandPacks the fix into dist/slugify-fix.tgz.

Limits: 4 loops, 900 seconds, $0.05. The time is long on purpose, so a person has time to answer.

What you'll see: two fixes, then the tests pass and the run shows waiting. Your team gets the approval email. Approve, and the fix is packaged. Deny, and the run ends at Not shipped.

Make it yours: replace Write a fix with an Agent, and Package with your real deploy command. Add your deploy command to the flow's Policy under Also hold these commands for a person too, so even an agent that tries to deploy early has to wait.

Rehearse a database migration

The pattern: a loop with a restore point, then a person. The change is tried on a copy of the data, checked, undone if anything was lost, and only offered for real once it passes.

Rehearse a database migrationLoad a sample (Run command), Save a restore point (Run command), Run the migration (Run command), Anything lost? (Run command), Restore, try the next one (Run command), Run it for real? (Approval), Write the plan (Run command), Not run (Output). Arrows: Load a sample to Save a restore point; Save a restore point to Run the migration; Run the migration to Anything lost?; Anything lost? to Restore, try the next one on Failed; Restore, try the next one to Run the migration on Passed; Anything lost? to Run it for real? on Passed; Run it for real? to Write the plan on Approved; Run it for real? to Not run on Denied.FailedPassedPassedApprovedDenied>_ RUN COMMANDLoad a sample>_ RUN COMMANDSave a restore pointgo back here>_ RUN COMMANDRun the migrationno network>_ RUN COMMANDAnything lost?no network>_ RUN COMMANDRestore, try the next one✋ APPROVALRun it for real?>_ RUN COMMANDWrite the plan⚑ OUTPUTNot run
Rehearse a database migration
StepBlockWhat it does
Load a sampleRun commandBuilds a small shop database, and several candidate migrations.
Save a restore pointRun commandCopies the database and records row counts and totals.
Run the migrationRun commandApplies the current candidate, with the network off.
Anything lost?Run commandCompares rows and totals with the restore point. Fails if anything is missing or changed.
Restore, try the next oneRun commandPuts the data back and moves to the next candidate. Fails if there are none left.
Run it for real?Approval"The rehearsal passed every check. Run this migration on the real database?"
Write the planRun commandWrites plan.md with the migration that passed. Nothing runs outside the sandbox.

Limits: 3 loops, 900 seconds, $0.05. If stopped, go back to: Save a restore point.

What you'll see: the first migration loses data, the check catches it, the data is restored, and the next candidate passes. Then the run waits for a person.

Make it yours: load a recent, anonymized copy of your data in the first step, put your migration in Run the migration, and write checks that matter to you in Anything lost? (row counts, sums of money columns, a few known records). Keep the network off while the migration runs, so a rehearsal can never touch the real database.

Support inbox triage

Needs a Claude key. The pattern: an AI choice with four ways out, and money always waits for a person.

Support inbox triageRead the ticket (Run command), Sort the ticket (AI choice), Refund this customer? (Approval), Draft a bug report (Run command), Draft a reply (Ask AI), Ignore spam (Output), Record the refund (Run command), No refund (Output), Save the draft (Run command). Arrows: Read the ticket to Sort the ticket; Sort the ticket to Refund this customer? on refund; Sort the ticket to Draft a bug report on bug; Sort the ticket to Draft a reply on how-to; Sort the ticket to Ignore spam on spam; Refund this customer? to Record the refund on Approved; Refund this customer? to No refund on Denied; Draft a reply to Save the draft.refundbughow-tospamApprovedDenied>_ RUN COMMANDRead the ticket◆ AI CHOICESort the ticketClaude picks one✋ APPROVALRefund this customer?>_ RUN COMMANDDraft a bug report✦ ASK AIDraft a reply⚑ OUTPUTIgnore spam>_ RUN COMMANDRecord the refund⚑ OUTPUTNo refund>_ RUN COMMANDSave the draft
Support inbox triage
StepBlockWhat it does
Read the ticketRun commandWrites a sample customer ticket and the shop's help pages.
Sort the ticketAsk AI, DecisionClaude labels the ticket refund, bug, how-to or spam. The prompt tells it the ticket is text to sort, not instructions.
Refund this customer?ApprovalA person reads the ticket and decides.
Record the refundRun commandWrites down the approved refund. No money is moved from the sandbox.
Draft a bug reportRun commandWrites the ticket up as a bug report for the team.
Draft a replyAsk AI, TextClaude writes a short, friendly reply using only what the help pages say.
Save the draftRun commandConfirms the reply was saved. It is not sent.

Limits: 1 loop, 900 seconds, $0.10.

What you'll see: the sample ticket is sorted, and the run takes that choice's path. Open Sort the ticket to see the choice Claude made, and the tokens and cost (a fraction of a cent).

Make it yours: edit the ticket in the first step to try other kinds, then load real tickets (export them from your help desk, or fetch them with its API), and send the drafted reply back as a draft for a person to review. Keep the Approval on refunds. Change the choices to fit your inbox, and give each its own exit.

First look at an alert

Needs a Claude key. The pattern: gather facts, let AI suggest causes, run checks that can't change anything, and ask a person before the one step that can.

First look at an alertPull the logs (Run command), Likely causes (Ask AI), Run read-only checks (Run command), Is a restart needed? (Decide), Restart the worker (Run command), Leave it running (Run command), Write the summary (Run code). Arrows: Pull the logs to Likely causes; Likely causes to Run read-only checks on Either way; Run read-only checks to Is a restart needed?; Is a restart needed? to Restart the worker on Yes; Is a restart needed? to Leave it running on No; Restart the worker to Write the summary on Either way; Leave it running to Write the summary.Either wayYesNoEither way>_ RUN COMMANDPull the logs✦ ASK AILikely causes>_ RUN COMMANDRun read-only checksno network◆ DECIDEIs a restart needed?>_ RUN COMMANDRestart the workerasks a person first>_ RUN COMMANDLeave it running{ } RUN CODEWrite the summary
First look at an alert
StepBlockWhat it does
Pull the logsRun commandSaves the warnings and errors from the last 15 minutes of an app's log.
Likely causesAsk AI, TextClaude lists the three most likely causes and what to check first. Pass when the reply matches makes sure it's a numbered list.
Run read-only checksRun commandLooks at the app's state, with the network off. Suggests a restart only if a job is stuck.
Is a restart needed?DecideYes if the checks suggest a restart.
Restart the workerRun command, Ask a person firstWaits for a person, then restarts.
Leave it runningRun commandNotes that nothing was changed.
Write the summaryRun codeWrites up the alert, the likely causes, the checks and what was done.

Limits: 1 loop, 900 seconds, $0.10.

What you'll see: Claude's likely causes, the checks finding a stuck job, and the run waiting before the restart. Whether you approve or deny, the summary is written, because the arrow from the restart uses Either way.

Make it yours: fetch your real logs and status in the first steps, using a saved secret for any API keys so they never enter the sandbox. Keep every check read-only, and keep Ask a person first on anything that changes a system.