A branch-first dev loop for Neon: link, checkout and env pull
Neon's CLI adds three commands for branch-first Postgres development. `neon link` binds a workspace to a project and branch via a git-ignored `.neon` file. `neon checkout` creates or switches database branches, much like `git checkout -b`. `neon env pull` writes only the Neon-managed connection strings and service secrets for the current branch into `.env`. Link and checkout run env pull automatically, which suits coding agents that need an isolated database per feature. Teams that keep secrets off disk can pass `--no-env-pull` and inject env at runtime with `@neondatabase/env` (`neon-env run`, `fetchEnv`) or export it into varlock.
Related posts
- Just landed in the Neon CLI
Neon mediumAdept
The Neon CLI is renamed from neonctl to neon (old name kept as an alias) and gains a branch-first workflow built on `neon link`, `neon checkout` and `neon env pull`, which store project/branch context in a local .neon file and rewrite only Neon-managed env vars. New commands include `neon inspect db` for read-only Postgres diagnostics (bloat, unused indexes, locks, pg_stat_statements outliers, cache hit rate), `neon diff` for git-style schema diffs, snapshots, project-scoped API keys and credential profiles for CI and agents, and a raw `neon api` fallback. `neon init` sets up MCP and agent skills in one step, and a suggested AGENTS.md snippet steers coding agents toward the branch-per-feature loop.
- Automating Neon branch creation with Githooks
Neon mediumAdept
A Git post-checkout hook can create a Neon database branch for each new Git branch, giving every feature branch an isolated copy of the main Postgres database without a local install or seed scripts. The shell script reads the hook's arguments to detect branch checkouts and counts reflog entries to spot first-time checkouts. It asks the user for confirmation via /dev/tty, checks the Neon API for an existing branch, creates one with a POST request, and uses jq to write the returned connection URI to .env as DATABASE_URL.
- Branching Postgres databases with the Neon API
Neon mediumAdept
Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests. Two experimental GitHub Actions, neondatabase/create-branch-action and neondatabase/delete-branch-action, wrap the API. A sample pull-request workflow creates a branch from a parent branch, runs the test steps, then deletes the branch. The actions were beta at the time and still being hardened for production use.
- Fullstack preview environments using Neon and Qovery
Neon mediumAdept
Each Qovery preview environment can get its own isolated Postgres database by using a Qovery lifecycle job that creates a copy-on-write Neon branch on the environment's Start event and deletes it on Delete. A Docker image bundles the Neon CLI and two shell scripts. create-branch.sh creates a branch named after QOVERY_ENVIRONMENT_NAME and writes direct and pooled connection strings to /qovery-output/qovery-output.json, so other services receive them as environment variables. delete-branch.sh looks up the branch ID through the Neon API and deletes it. This sidesteps the conflicts of a shared preview database and the slow provisioning, stale seed scripts and privacy issues of copying production data.
- Make Yourself at Home with Neon Local
Neon mediumAdept
Neon Local is a Docker-based proxy that exposes a local Postgres endpoint for a Neon cloud database. By default it creates a fresh database branch when the container starts and deletes it when the container stops, giving isolated ephemeral environments for local development and CI without a local Postgres instance or environment drift. Configuration happens through environment variables: DRIVER selects the serverless or standard Postgres client, PARENT_BRANCH_ID picks the base branch, and DELETE_BRANCH=false keeps the branch between runs. Example docker-compose and docker run setups show how to point the Neon serverless driver at the proxy. Named branches and an offline dump/restore mode are planned.