The config command manages a branch declaratively with a neon.ts policy file: scaffold a starter config, inspect the branch's live state, preview what an apply would change, and apply the policy. For the neon.ts file format, see the neon.ts reference.
The top-level neon deploy command is an alias for config apply, and neon status is an alias for config status.
neon config init
Scaffolds a starter neon.ts policy file in the current project and installs the @neon/config and @neon/env packages, so you can start managing a branch declaratively. The generated file uses the standard named defineConfig import from @neon/config/v1 and exports the result as the module default, for example:
import { defineConfig } from "@neon/config/v1";
export default defineConfig({
// Declare your Neon services here
auth: false,
// Branch policy: per-branch tuning
branch: (branch) => {
if (branch.isDefault) {
// Default branch: no overrides, uses project defaults
return {};
}
if (!branch.exists) {
// New non-default branches: auto-expire
// Run `neon checkout <name>` to create a new branch with these settings
return { ttl: "7d" };
}
// Existing branch: no changes
return {};
},
});If a neon.ts, neon.mts, neon.js, or neon.mjs file already exists, config init is idempotent: it leaves that file untouched instead of overwriting hand-written policy.
config init runs entirely locally and does not call the Neon API. It detects your package manager (npm, pnpm, yarn, or bun) from how the command was invoked. Pass --no-install to skip installation and just print the command to run.
neon config init [options]neon config initFor non-interactive setup, run it with package installation disabled, then install the printed dependencies yourself (or add them to your lockfile in a separate step):
neon config init --no-install
npm install @neon/config @neon/envUse config init when you want a trusted starter artifact and package list. Hand-write neon.ts instead when you need a different filename/module format or want to avoid modifying files in the current directory.
tip
After running an interactive neon link, the CLI offers to run config init as its final step, unless the project already has a neon.ts file.
neon config status
Shows the branch's live Neon state.
neon config status [options]neon config statusThe top-level neon status command is an alias for config status and accepts the same options.
Print the current branch offline
Pass --current-branch to print only the branch pinned in the local .neon file. This variant makes no network request and requires no login or analytics, so it is cheap enough to drive a shell prompt.
It prints the branch name to stdout and exits 0. When no branch is pinned, it prints nothing to stdout, writes a neon checkout <branch> hint to stderr, and exits with a non-zero status, so a prompt can guard on the command directly.
neon status --current-branchFor example, add your current Neon branch to a starship prompt. Append this [custom.neon] module to ~/.config/starship.toml. The command prints the pinned branch, and when hides the segment (exits non-zero) whenever you are not in a Neon project:
# ~/.config/starship.toml
[custom.neon]
description = "Current Neon branch"
command = "neon status --current-branch" # prints the branch pinned in .neon (no network)
when = "neon status --current-branch" # exits non-zero when no branch -> segment is hidden
symbol = "🌿 "
style = "bold green"
format = "[$symbol$output]($style) "Faster outside Neon projects
The when above runs the CLI on every prompt everywhere. To skip it unless a .neon file exists somewhere up the tree, replace when with a pure-shell walk-up and add shell = ["sh"] so it runs under sh even if your interactive shell is fish or PowerShell:
shell = ["sh"]
when = '''
d="$PWD"
while [ "$d" != "$HOME" ] && [ "$d" != / ]; do
if [ -e "$d/.neon" ]; then
neon status --current-branch >/dev/null 2>&1
exit $?
fi
d=$(dirname "$d")
done
exit 1
'''For a full copy-paste (and agent-ready) walkthrough, including prerequisites and troubleshooting, see this Starship + Neon branch setup gist.
neon config plan
Shows what config apply would change, as a dry run. Nothing is modified.
neon config plan [options]neon config plan --config ./neon.ts --env .env.localneon config apply
Applies a neon.ts policy to the branch.
neon config apply [options]For non-interactive use (scripts, CI, agents), pass --update-existing and --allow-protected to auto-confirm the corresponding prompts.
neon config apply --branch feature/auth --update-existing --allow-protected







