Skip to main content
To interact with PlanetScale and manage your databases, you can use the pscale CLI to do the following:
  • Create, delete and list your databases and branches
  • Run non-interactive SQL for agents and scripts (pscale sql)
  • Open a secure MySQL or PostgreSQL shell instance
  • Manage your deploy requests
  • Bootstrap AI agents (pscale agent-guide)
  • …and more!

Install pscale

Install or upgrade the PlanetScale CLI for macOS, Linux, or Windows.
Agents and automation should start with the Agent setup prompt or pscale agent-guide --format json. Agent automation commands require pscale 0.292.0 or later; run brew upgrade pscale if agent-guide is unknown. Always pass --format json in automation.
pscale can use the MySQL command-line client to quickly open an interactive shell for a database branch. Optional instructions for installing the MySQL client can be found for each platform below.

Getting Started

Make sure to first set up your PlanetScale developer environment. Once you’ve installed the pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.

Available Commands

Use pscale [command] [command] to start up the pscale CLI in your terminal.
CommandSubcommands/OptionsFlagsProductDescription
agent-guide--format jsonVitess, PostgresBootstrap JSON for AI agents; embeds CLI conventions and skills/MCP hints
api--help, --org string, --database string, --branch string, --field key=value, --header stringArray, --input string, --method string, --query key=valueVitess, PostgresPerforms authenticated calls against the PlanetScale API and prints the response to stdout.
audit-loglist--help, --org stringVitess, PostgresList all audit logs
authlogin, logout, check--help, --format jsonVitess, PostgresAuthenticate via console or JSON device login for agents
backupcreate, delete, list, restore, show--help, --org stringVitess, PostgresManage branch backups
branchconnections, create, delete, diff, keyspaces, list, promote, query-patterns, refresh-schema, schema, show, switch, vschema--help, --org stringVitess, PostgresManage branches
completionbash, zsh, fish, powershell--helpVitess, PostgresGenerate completion script for specified shell
connect<database_name> <branch_name>--execute string, --execute-env-url string, --execute-protocol string, --help, --host string, --org string, --port string, --remote-addr string, --role stringVitessCreate a secure connection to the given database and branch
databasecreate, delete, dump, list, restore-dump, show--helpVitess, PostgresManage databases
deploy-requestapply, cancel, close, create, deploy, diff, edit, list, revert, review, show, skip-revert--helpVitessManage deploy requests including gated deployments
helpagent-guide, audit-log, auth, backup, branch, completion, connect, database, deploy-request, help, import, mcp, org, password, ping, region, role, service-token, shell, signup, size, sql, traffic-control, webhook, workflow--helpVitess, PostgresView help for any command
importd1 doctor, d1 lint, d1 convert-schema, d1 start, d1 verify, d1 status, d1 complete--help, --org stringPostgresImport external databases (Cloudflare D1) into PlanetScale Postgres
orglist, show, switch--helpVitess, PostgresManage and switch organizations
mcpinstall, server--target string (cursor|claude-code|zed), --format json, --helpVitess, PostgresInstall hosted MCP config (docs)
passwordcreate, delete, list--help, --org stringVitessManage branch credentials
ping--help, --count, -n int, --concurrency int, --provider, -p string --timeout durationVitess, PostgresCheck latency between your machine and PlanetScale’s public regions
regionlist--org stringVitess, PostgresView available regions
rolecreate, delete, get, list, reassign, renew, reset, reset-default, update--help, --org string, --inherited-roles string, --ttl duration, --force, --successor string, --name string, --webPostgresManage Postgres roles
service-tokenadd-access, create, delete, delete-access, list, show-access--help, --org stringVitess, PostgresManage access of service tokens
sizecluster list--help, --org string, --region string, --metalVitess, PostgresView available cluster sizes
traffic-controlbudget, rule--help, --org stringPostgresManage Database Traffic Control budgets and rules for a Postgres database branch
shell<database_name> <branch_name>--help, --local-addr string, --org string, --remote-addr string, --role string, --replicaVitess, PostgresOpen an interactive shell to the specified database and branch
signup--helpVitess, PostgresSign up for a new PlanetScale account
sql<database> <branch>--org string, --query string, --role string, --replica, --dbname string, --keyspace string, --force, --format jsonVitess, PostgresExecute a SQL query without an interactive shell (agents/scripts)
webhookcreate, delete, list, show, test, update--help, --org string, --events string, --url string, --enabledVitess, PostgresManage webhooks for databases
workflowcancel, complete, create, cutover, list, retry, reverse-cutover, reverse-traffic, show, switch-traffic, verify-data--help, --org stringVitessManage the workflows for PlanetScale databases

Flags

You may use the following flags with the PlanetScale CLI commands.
FlagDescription
--api-token stringThe API token to use for authenticating against the PlanetScale API
--api-url stringThe base URL for the PlanetScale API. (default “https://api.planetscale.com/“)
--config stringConfig file (default: $HOME/.config/planetscale/pscale.yml)
--debugEnable debug mode
-f, --format stringShow output in specific format. Possible values: [human, json, csv] (default: “human”)
-h, --helpGet more information about a command
--no-colorDisable color output
--service-token stringService Token for authenticating
--service-token-id stringThe Service Token ID for authenticating
--versionShow pscale version

Service tokens permissions

A complete list of access permissions available for use with service tokens can be found in the PlanetScale API documentation.

Service token automation

Running pscale in CI or an AI agent uses a service token instead of pscale auth login. Provide the token as environment variables (recommended) or as flags on each command; both are equivalent:
# Environment variables (recommended for CI and agents)
export PLANETSCALE_SERVICE_TOKEN_ID="<SERVICE_TOKEN_ID>"
export PLANETSCALE_SERVICE_TOKEN="<SERVICE_TOKEN>"

# Or per-command flags
pscale database list --org <org> \
  --service-token-id "<SERVICE_TOKEN_ID>" \
  --service-token "<SERVICE_TOKEN>"
A service token has no active organization, so resource commands need the org supplied explicitly. Set it with PLANETSCALE_ORG, the --org flag on the subcommand, or pscale org switch <org> (which works with a service token):
export PLANETSCALE_ORG="<org>"
pscale database list --format json          # uses PLANETSCALE_ORG
pscale database list --org <org> --format json   # explicit flag
--org goes on the resource subcommand (database, branch, sql, api, …), never on root pscale. pscale --org <org> database list fails with unknown flag: --org.
Per-command-family matrices (env-var auth, --service-token flag, required --org, Postgres/Vitess, --format json, API equivalent): org · service-token · database · branch · role · password.

Commands to avoid under a service token

Do not retry these with service-token auth. The failure is by design, not transient. This is the most common cause of agent retry loops.
CommandWhyDo this insteadExact error
pscale org showA service token has no “current” organizationpscale org list --format json, then pass --org or PLANETSCALE_ORGnot authenticated yet. Please run 'pscale auth login'
pscale service-token listToken management is blocked when authenticated with a tokenpscale api organizations/<org>/service-tokens --format jsonpscale service-token list is unavailable when authenticated with a service token
pscale service-token show-accessSame as listpscale api organizations/<org>/service-tokens/<id> --format jsonpscale service-token show-access is unavailable when authenticated with a service token
pscale service-token (other sub-commands)Create/manage tokens blocked under service-token authpscale auth login, then CLI; or Service tokens APIpscale service-token <sub-command> is unavailable when authenticated with a service token
pscale auth login / logoutNot needed; the token is the credentialSet the token env vars; run pscale auth check --format json to confirmrequires an interactive browser device flow
pscale shell / connectInteractive sessionsUse pscale sql for non-interactive queriesopens an interactive session
pscale org show prints not authenticated yet. Please run 'pscale auth login' under a valid service token. This is the no-current-org state, not an auth failure. Do not respond by running pscale auth login. Discover the org with pscale org list and pass it with --org or PLANETSCALE_ORG.
pscale auth check --format json confirms a token is wired up. Expect "authenticated": true, "auth_method": "service_token", and (until an org is set) an action_required status with a NO_ORG issue and a non-zero exit code. Resolve it by passing --org/PLANETSCALE_ORG on your commands.

pscale api fallback for hard-to-parse output

When a command’s human output is hard to parse, prefer --format json, or drop to the raw API with pscale api, which returns the API response verbatim and uses the same token:
# org list
pscale api organizations --format json

# database list / show
pscale api organizations/<org>/databases --format json
pscale api organizations/<org>/databases/<database> --format json

# branch list / show
pscale api organizations/<org>/databases/<database>/branches --format json
pscale api organizations/<org>/databases/<database>/branches/<branch> --format json

# service-token list / show-access (CLI blocked under service-token auth)
pscale api organizations/<org>/service-tokens --format json
pscale api organizations/<org>/service-tokens/<id> --format json

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.