On the evening of 18 September, in our office in Gilbert, we branched the database behind a live demo app while the room watched. Lakebase had the copy ready to use in 4.5 seconds. Its logical_size_bytes read zero, because nothing had really been copied yet. A branch shares its parent's storage until somebody writes to it.
That speed matters to anyone waiting on a release. When every change is tested against one shared database, one change breaks another's tests, and a release waits while engineers work out whose change did it. A private copy of the database for each change ends that, and at a few seconds a copy it's cheap enough to be the default. The same call had been in our own tooling for two months by then. Since 15 July, the test kit in TechFabric Experiments, our Databricks testing accelerator, has created a Lakebase branch for a live test run. It hands the run its connection details and deletes the branch at the end. We haven't yet given each AI coding agent the same kind of branch. That's the next step.
Why one shared test database stops working
One change adds a column, another deletes rows the first was reading, and the second change's tests fail for a reason that has nothing to do with its code.
Coding agents make that worse. Three agents can each work in their own Git worktree, so the code side holds up, and then all three run their migrations against the same Postgres. The one that finishes first changes the schema under the other two halfway through their tests.
A copy per change fixes it, and the cost of a copy has always decided how many a team gets. Restoring a database for every pull request was too slow and too expensive, so teams shared one. A Lakebase branch is copy-on-write and appears in seconds whatever the database's size (branching docs), which moves the unit cost enough to change the habit.
How Experiments gives a test run its own branch
A live run starts with fx test env create --lakebase-branch. The test kit (createEphemeralLakebaseBranch in packages/databricks-testkit) posts to /api/2.0/postgres/<project>/branches with a ttl in the spec, polls the operation every two seconds for up to five minutes, then reads back the branch's primary endpoint host and its database name. Our GitHub workflow writes those into the job's environment as DBX_TEST_LAKEBASE_HOST and DBX_TEST_LAKEBASE_DATABASE, the tests connect to them, and a destroy step deletes the branch with purge when the run ends.
We made some choices in that code by thinking about what goes wrong.
- The branch name is derived from the test environment's name and always starts
fx-. The delete refuses any branch whose name doesn't matchprojects/<id>/branches/fx-..., so a wrong argument can't remove a branch outside the test namespace, production's included. - The create call sends
replace_existing: false. Two runs handed the same name fail loudly instead of quietly sharing data. - The time to live never drops below 60 seconds, so a typo in a duration can't create a branch that's gone before the tests reach it.
The delete guard is the one we'd copy into any team's tooling first. Branch deletion is permanent, data and compute together, and a cleanup script with a bad variable is the most likely way a team loses a branch it meant to keep.
TechFabric Runway has the same idea written for preview deployments, where each preview gets a branch from production with a 24 hour time to live unless the deployment sets another. That path is exercised in Runway's test suite against mocked Databricks calls. We haven't run it against a live workspace yet.
What a branch costs, and the setting that decides it
Databricks bills an expiring branch only for the data that changes on it, and a permanent branch, one created with no expiration, for its full data size (Manage branches). The CLI asks for an expiration policy on every new branch, a ttl, an expire_time or no_expiry: true, and both examples in its reference create permanent ones.
So nothing our tooling creates is permanent.
Compute is the other half. It scales to zero after an idle timeout that defaults to 24 hours and can be set from 60 seconds to 7 days (scale to zero). Our Gilbert project went back to zero after five idle minutes, and the price of that showed up in the same session: the first query against the idle endpoint took 2,979 ms, against 1,650 ms warm. A test run pays that once. A person clicking through a preview app notices it.
Two structural rules shaped the branch tree too. An expiring branch can't have children, and a branch with children can't expire, so test and preview branches hang directly off production, one level deep. And a project allows 20 concurrently active computes, with the default branch exempt (Manage projects). A CI pipeline that opens branches faster than it lets them idle hits that ceiling long before the 500-branch limit.
A branch per coding agent, the way we'd set it up
Databricks published a workflow on 8 October 2026 that ties branches to Git worktrees through a post-checkout hook (Databricks blog). In its example the agent starts on a new worktree, Git makes the worktree, and the hook makes the database. We'd keep that shape and add the guards Experiments already has: a fixed prefix for agent branches, a delete that refuses anything without it, and a time to live on every branch.
Take a team with a fee-calculation service on Postgres. One agent adds a currency column, a second rewrites the refund job, and a third fixes a report query. With a branch per worktree, each agent works on its own copy of a seeded database and none sees another's change until the pull requests open. CI then does what Experiments does today: a fresh branch from production, the migration applied, the tests run, the branch deleted.
We'd write the discipline into the repository's AGENTS.md in plain sentences, because the agent follows whatever that file says. The agent works only against the branch its worktree's hook created. Every schema change is a migration file in the repository, never a statement typed into a session. Where production-derived data is needed, it comes masked through Unity Catalog. Cleanup we'd automate rather than trust, with a nightly job that deletes any agent branch whose worktree no longer exists.
Credentials matter as much as the rules. Creating or deleting a branch needs CAN MANAGE on the project (Manage branches), so the CI service principal holds it. An agent working on a laptop needs only its own branch, and giving it more turns a mistake on a branch into a mistake on production.
Schema changes have to be migrations first
Lakebase branches don't merge back into their parent. Reset runs from parent to child only, so a schema change survives only if it lives in code and is promoted through a migration tool such as Drizzle, Flyway, Liquibase or Alembic.
This is where we'd expect most teams to stall. If schema changes today happen by somebody connecting to dev and typing SQL, an agent with its own branch will do the same, and the change dies with the branch. We'd move a team to migration files first and add branching second.
Branching also does little for two kinds of system. A single developer with no agents has no concurrency to isolate. An application whose state lives mostly outside Postgres, in object storage, a queue or a SaaS tool, gets a partial environment from a database branch, and its tests pass against data the other systems don't hold. We wouldn't move an operational database to Lakebase for agent isolation alone. We'd move it because the app's data needs to sit next to the lakehouse (Lakebase managed Postgres), and count branching as part of what the move buys the engineering team.
Start with a branch per pull request
CI is where we started, and it's where we'd start a client's team, with an ephemeral branch per pull request that lives a few hours and a delete that checks the prefix. It fails safely, and the team learns the permission model and the expiration rules before an agent ever creates a branch. Then we'd audit for permanent branches every month, since the gap between paying for changes and paying for full copies stays invisible until the invoice arrives. Per-agent branches come last, once migrations are files.
Branching is one part of our Lakebase implementation work, and how we scope what an agent may touch is in our AI agents work. For a comparison with another vendor's Postgres, see Lakebase vs Snowflake Postgres, and for another gap between coding agents and their tests, green test runs that left the change untested.
Frequently asked questions
Can Databricks raise the limit on active computes for a busy CI pipeline?
The limit on concurrently active computes, 20 per project with the default branch exempt, can be raised through Databricks Support. A project also holds up to 500 branches (Manage projects). A pipeline that hits the compute limit usually has branches that aren't scaling down, so we'd shorten the idle timeout before asking for more.
What happens to a Lakebase branch when its time to live runs out?
Databricks deletes it automatically, with its data and its compute, and the deletion is permanent (Manage branches). The docs describe no warning before it goes, so anything worth keeping on an agent's branch has to leave as a migration file or a dump first. The longest expiration you can set is 30 days from now, and it can be extended before it lapses.
What does resetting a Lakebase branch from its parent do?
It overwrites the child with the parent's data and schema, so every local change on the child is lost. Existing connections drop for a moment and come back with the same connection details. A branch with children can't be reset, and neither can a root branch, which is one more reason to keep agent branches one level below production.
How does a test run find its branch's connection details?
Experiments reads the primary endpoint's host and the branch's Postgres database name back from the Lakebase API once the branch is ready. The workflow exports them as environment variables for the tests, so the tests never need production's address and can't reach it by accident.