One branch per agent task, merged only after you approve the diff
An agent that migrates and seeds directly against production is one bad migration away from the incidents everyone has read about this year. The fix that lets an agent still move fast: give every task its own branch — a real preview environment with its own URL, keys and database, sanitized by default, that deletes itself on a timer — and only merge after a human sees the diff.
Last checked November 30, 2026.
Why an isolated branch, not just a read-only connection
A read-only connection stops an agent from writing anything at all, which also stops it from doing its job: adding a column, seeding test data, running the exact migration it is trying to validate. An isolated branch answers a different, more useful question — not "can the agent write," but "can the agent write somewhere that is not production." It can migrate, seed and break the branch freely; nothing reaches production until a human approves the merge.
The real loop
Over MCP the same steps are environment_create, branch_register, migrate_run, branch_diff and branch_merge. The scribase-safe-change skill walks an agent through this loop, including the RLS proof with policy_test, so the branch itself never ships an unprotected table either.
TASK=add-invoices
scribase env create acme my-app "pr-$TASK" preview sanitized eu-frankfurt "create-pr-$TASK" 24
scribase branch register acme my-app "pr-$TASK" --base production
scribase migrate acme my-app "pr-$TASK" --dir supabase/migrations --apply
scribase branch diff acme my-app production "pr-$TASK"
scribase branch merge acme my-app production "pr-$TASK" --dry-runSources: Scribase docs: Branch per task
What data the branch actually gets
| Mode | What the branch gets |
|---|---|
| sanitized | A copy of the parent's data, then anonymized — the default for previews |
| snapshot | An exact copy, only when real data is explicitly requested |
| schema_only | Schema, no rows |
Sources: Scribase docs: Branch per task
No account at all: a temporary project
For the earliest exploration, before a task is even assigned a branch, an agent can get a full temporary backend with no account: npx scribase init --temp --yes --json. It lives 72 hours and is deleted if unclaimed; claim it to keep it, same URL and keys.
npx scribase init --temp --yes --jsonSources: Scribase docs: Temporary databases
Questions people ask
What is the difference between a branch and a temporary project?
A temporary project (npx scribase init --temp) is a whole new, standalone backend with no account, meant for a first prototype or exploration; it lives 72 hours unclaimed. A branch is a preview environment linked to an existing project, usually scoped to one task, with a base to diff and merge against — the right tool once there is a real production to protect.
Does the agent get real production data to test against?
By default a branch is sanitized: a copy of the parent's data, then anonymized, so the agent can test against realistic shapes without handling real user data. An exact snapshot is available but only when explicitly requested.
How does production actually get the change?
Only through an explicit merge the agent runs after showing a diff and a dry run; a human approves that step. The loop (branch_diff, branch_merge --dry-run, then the real merge) is the same whether the agent uses the CLI or the matching MCP tools.
What stops a branch from going stale and accumulating forever?
Every preview environment is created with a time to live and deletes itself automatically when it expires (scribase env renew extends it); there is no manual cleanup step an agent or a person has to remember.