Skip to main content
See what's recently landed on the Neon backend: Object Storage, Functions, AI Gateway, and more
/APIs & SDKs/Overview

Neon CLI

The Neon command-line interface: every command, with options and examples

View as Markdown

One CLI for every Neon surface: manage Postgres, Functions, Storage, the Data API, and Managed Better Auth from the terminal, with branch-scoped workflows built in.

Install
npm i -g neon

Get started

Agent mode

Use Neon CLI with Claude Code, Cursor, Codex, and other AI development tools.

note

Every command supports --output json for machine-readable results, and setting the NEON_API_KEY environment variable authenticates non-interactively. Agents bind a directory to a project with neon link's non-interactive flags, the same ones used for CI and scripts.

Commands reference

Browse every Neon CLI command, organized by category. The CLI is invoked as neon. neonctl is an alias for neon, so any command works with either name.

Setup & context

CommandDescriptionExample
api-keysManage API keys
neon api-keys <sub-command> [options]
askAsk the Neon assistant a question from the terminal.
neon ask --prompt "How do schema-only branches work?"
bootstrapScaffold a new project from a Neon starter template, then install agent tooling and link a Neon project
neon bootstrap my-appneon bootstrap . --template hononeon bootstrap my-app --default
checkoutPin a branch in .neon; auto-pulls its env vars.
neon checkout feat/auth
claimCreate and claim a temporary project without an account.
neon claim create --env-pullneon claim accept
docsSearch neon.com docs, guides, and more from the terminal.
neon docs search "reset a branch"
envWrite the branch's DATABASE_URL + Neon vars to .env.
neon env pull
feedbackSend feedback about the CLI to the Neon team; no login required.
neon feedback --message "The branch docs were unclear"
gitSync the checked-out Neon branch to your git branch on checkout (Preview).
neon git installneon git status
initSet up this directory for Neon: agent tooling, a linked project, and optionally neon.ts.
npx neon@latest init
linkBind the directory to a project; writes .neon and pulls env.
neon linkneon link --org-id org-abc --project-id polished-snowflake-1234
loginBrowser OAuth; stores credentials locally.
neon login
mcpInstall the Neon MCP server into your coding agents.
neon mcpneon mcp -y
meShow the authenticated user.
neon me
openOpen the linked project in the Neon Console in your browser.
neon open
pluginsInstall the Neon plugin (skills plus MCP) into your coding agents.
neon pluginsneon plugins -yneon plugins --global
profileManage named sets of Neon credentials
neon profile create workneon profile create ci --mint --org-id org-abc-123
set-contextWrite org/project/branch context to .neon.
neon set-context --project-id polished-snowflake-1234
skillsInstall, update, and check Neon agent skills in your coding agents.
neon skillsneon skills update -yneon skills status

Projects & branches

CommandDescriptionExample
branchesCreate, diff, reset, restore, and manage branches.
neon branches create --name feat/auth --parent mainneon branches restore main ^self@2024-05-06T10:00:00Z --preserve-under-name backupneon branches schema-diff production development
databasesManage databases on a branch.
neon databases create --name analytics
diffShow a git-style schema diff between the current branch and another branch
neon diff main --db neondbneon diff main --branch feature/checkoutneon diff
operationsInspect async operations.
neon operations listneon operations get <operation-id>
postgresManage computes, databases, and roles, and connect, in one group (alias pg).
neon postgres computes listneon postgres computes update ep-cool-king-123456 --cu 0.25-2
projectsManage projects.
neon projects list
rolesManage Postgres roles, scoped access, and passwords.
neon roles create --name app_userneon roles create --name reporting --access read_onlyneon roles reset-password app_user
snapshotsManage snapshots
neon snapshots create --branch main --lsn 0/1F3C8A0 --expires-at 2025-12-31T23:59:59Zneon snapshots create --branch main --timestamp 2025-01-01T00:00:00Zneon snapshots create --branch main --name pre-migration

Connect to Postgres

CommandDescriptionExample
connection-stringPrint a connection URI for a branch/role/db.
neon connection-string mainneon connection-string main --pooled --prisma
psqlOpen a SQL session (embedded psql fallback built in).
neon psql main -- -c "SELECT 1"

Config as code

CommandDescriptionExample
configDrive a branch from a neon.ts policy.
neon config apply
deployAlias for config apply; reconciles the policy.
neon deploy
devRun Neon Functions locally with hot reload + branch env.
neon dev
statusShow the branch's live Neon state (alias of config status).
neon status

Functions, storage & data

CommandDescriptionExample
bucketsBranch-scoped object storage and its objects.
neon buckets create my-assets
credentialsIssue and manage scoped credentials on a branch.
neon credentials create --scope storage:read
data-apiManage the Neon Data API for a database.
neon data-api create
functionsCreate, deploy, and manage Neon Functions on a branch.
neon functions new basicneon functions deploy api --src ./api.ts
neon-authManage Neon Auth on a branch.
neon neon-auth enable
realtimeManage Neon Realtime and subscribe to live queries.
neon realtime enable --allowed-origin https://app.example.comneon realtime subscribe "SELECT * FROM items"
triggersInvoke a Neon Function on a cron schedule or when an object is created.
neon triggers create --function-slug api --name nightly --cron '0 6 * * *'

Org & network

CommandDescriptionExample
apiCall any Neon API route directly (authenticated passthrough)
neon api /projectsneon api /projects/{id}/branches -X POST -F branch.name=devneon api --list
ip-allowManage the project IP allowlist.
neon ip-allow add 203.0.113.0/24
orgsList organizations, and manage members, invitations, and the spending limit.
neon orgs listneon orgs members listneon orgs spending-limit set 500
vpcManage VPC endpoints and project restrictions.
neon vpc endpoint list

Debugging

CommandDescriptionExample
incidentsShow open Neon incidents and maintenance
neon incidentsneon incidents -o json
inspectInspect a branch's Postgres health and configuration
neon inspect <sub-command> [options]
logsQuery branch logs with structured filters, LogQL, or the Loki API
neon logs field-values service_name --since 6hneon logs loki '{entity_type="function"} |= "error"' --since 30m --limit 100neon logs loki --endpoint labels

Global options

Global options are optional and work with any Neon CLI command.

OptionDescriptionTypeDefaultRequired
--analyticsManage analytics. Example: --no-analytics, --analytics falsebooleantrueNo
--api-keyNeon API key, authenticates without neon loginstring""No
--colorColorize the output. Example: --no-color, --color falsebooleantrueNo
--config-dirPath to config directorystring~/.config/neon (or $XDG_CONFIG_HOME/neon)No
--context-fileContext file with default org, project, and branch IDs, created by neon linkstringnearest .neon file, searching upward from the current directoryNo
--help, -hShow help for a command or subcommandboolean—No
--output, -oSet output format Possible values: json, yaml, tablestringtableNo
--profileNamed credentials to use, from profiles.json (default: NEON_PROFILE, else DEFAULT)string—No
--version, -vShow version numberboolean—No

More about global options:

  • Output: table output may omit fields. Use --output json or --output yaml to see all data.
  • Authentication: the CLI checks credentials in this order: the --api-key option, the NEON_API_KEY environment variable (export NEON_API_KEY=<neon_api_key>), the credentials.json file that neon login creates in the config directory (override its location with --config-dir), then interactive web authentication. To get a key, see Create an API key.
  • Context file: sets a default organization, project, or branch so you don't repeat IDs in every command. Create one with neon link (preferred) or set-context.
  • Analytics: Neon collects anonymous data about which commands and options are used, plus context such as the CLI version, whether it ran in CI or a terminal, and which coding agent ran it, never user-defined data such as project IDs or command payloads. Each installation gets a random ID, stored as anonymous_id in the config directory, and once you sign in, your events are linked to your account. The ID isn't created in CI or when you pass --no-analytics. If the CLI crashes on an internal bug, it also sends an error report with the error type and a sanitized stack trace, without your arguments, environment variables, or file contents. Opt out of both with --no-analytics, which also asks the docs search service not to record your neon docs search and neon ask queries.
  • Help: --help works at every level: neon --help, neon branches --help, neon branches create --help.

GitHub repository

The Neon CLI is open source. See the neondatabase/neon-pkgs repository.

Last updated on

Was this page helpful?
Edit on GitHub