Skip to content

One database per branch

Your code has branches. So does your database.

One database per branch
Terminal window
kling db branch -golden crm-demo # current branch: creates its copy
kling db branch hook install # every git checkout switches database
kling db branch -ls # branches with their copy, state and last use
kling db branch -prune # deletes those of branches that no longer exist

The connection is written to .git/kling-db.env (0600), never to the working tree:

Terminal window
set -a; . "$(git rev-parse --absolute-git-dir)/kling-db.env"; set +a

Measured end to end, N = 20, hook included.

Linux (i7-8700T) macOS (M4, vz)
back to a branch with a copy 43 ms p50 322 ms p50
new branch, parent reserve ready 88 ms p50 348 ms p50
new branch, parent changed 2,200 ms p50 731 ms p50

Branches nobody uses are frozen in the background: 0 RAM.