PlanetScale CLI Skills

PlanetScale CLI (pscale) command reference and workflows. Use for authentication, organizations and members, databases, branches, branch maintenance, extension catalogs, metrics, i…

Vince Lozada

@vince-winkintel

What This Skill Does

Command-line interface for managing PlanetScale databases, including branches, deploy requests, schema migrations, non-interactive SQL queries, and Cloudflare D1 imports. Provides automation scripts for common workflows like creating branches for merge requests and deploying schema changes.

Replaces manual database management through PlanetScale's web console by exposing all major operations through a single CLI with automation scripts.

When to Use It

  • Create a new database branch for a feature or bug fix
  • Review and deploy a schema change via a deploy request
  • Run a non-interactive SQL query against a PlanetScale database
  • Import a Cloudflare D1 SQLite export into a PlanetScale Postgres database
  • List and manage database backups for a specific branch
  • Automate branch creation and schema deployment in CI/CD pipelines

Install

$ openclaw skills install @vince-winkintel/planetscale-cli-skills

PlanetScale CLI Skills

Comprehensive pscale command reference and workflows for managing PlanetScale databases via terminal.

Overview

The PlanetScale CLI brings database branches, deploy requests, and schema migrations to your fingertips. This skill provides command references, automation scripts, and decision trees for all pscale operations.

Configuration and credential safety

  • Directory-local .pscale.yml files are project configuration, not trusted credential configuration. The CLI accepts only org, database, and branch from them and warns while ignoring keys such as API endpoints or tokens.
  • Keep API URLs and credentials in the user config, environment/secret manager, or explicit approved flags. Never commit them to a repository-local config.
  • pscale api follows cross-host redirects without forwarding authentication or caller-supplied headers. Even with this protection, pass secret-bearing headers only to an explicitly verified API host and do not expose them in logs.
  • When --format json is active, API error codes are preserved in the top-level code field instead of being collapsed to COMMAND_FAILED. Branch automation should branch on exact codes when present; for schema_mutation_blocked, wait for the active vtctld mutation or deploy to finish before retrying.

Binary-native agent bootstrap

  • pscale --skill prints the current binary's installable pscale-cli skill file to stdout when no positional arguments follow it. pscale agent-guide --skill is equivalent.
  • Both forms still emit the raw Markdown skill when --format json is present; redirect the output to an approved skills directory when a standalone binary-native guide is wanted.
  • Validate automated bootstrap output starts with ---\nname: pscale-cli; pscale --skill <extra-arg> prints root help and exits zero instead of emitting the skill.
  • The binary-native guide is useful for first-party command discovery, but it does not replace this repository's specialized safety workflows, focused references, and helper scripts.
  • When a command name is assembled dynamically, validate the expected JSON/resource shape as well as the exit code. A bare unrecognized root token currently prints root help and exits zero, so zero alone does not prove that a resource operation ran.

Sub-Skills

CommandSkillUse When
authpscale-authLogin, logout, service tokens, authentication management
branchpscale-branchCreate, rename, protect, delete, promote, diff, list, and switchover branches; inspect branch infra, manage Postgres size/replicas/parameters/maintenance/extensions, resize Vitess VTGates, manage live keyspace routing rules and tablet throttling, manage query pattern reports, manage Vitess MoveTables workflows
deploy-requestpscale-deploy-requestCreate, review, inspect queues/operations, check storage, throttle, deploy, update auto-apply/auto-delete settings, unblock failed deploy/revert queues, force cutover, and revert schema changes
databasepscale-databaseCreate, list, show, update, delete, and dump databases; manage database-level Vitess throttler/aggressive-cutover defaults, keyspaces, PostgreSQL IP restrictions, and read-only regions
maintenancepscale-maintenanceInspect Vitess Enterprise maintenance schedules, pending versions, deadlines, and historical windows
sqlpscale-sqlRun non-interactive SQL queries with JSON output and ephemeral credentials
metricspscale-metricsQuery historical/current branch metrics and engine-aware grouped performance reports
insightspscale-insightsAnalyze production query statistics, execution samples, query tags, error details, anomaly correlations, and schema recommendations
traffic-controlpscale-traffic-controlInventory and safely manage Postgres Traffic Control budgets and fingerprint/keyspace/tag rules
inspectpscale-inspectRun point-in-time, read-only MySQL/Vitess and PostgreSQL diagnostic checks
import d1pscale-import-d1Import Cloudflare D1 SQLite exports into PlanetScale Postgres
backuppscale-backupCreate, list, show, restore, and delete branch backups; manage scheduled backup policies
audit-logpscale-audit-logList audit events and export filtered authentication attempts
passwordpscale-passwordCreate, list, show, update, delete, and scope Vitess connection passwords to read-only regions
pgbouncerpscale-pgbouncerList, inspect, create, resize, cancel, and delete dedicated PostgreSQL PgBouncers
orgpscale-orgList, show, switch organizations, and inspect or manage members
service-tokenpscale-service-tokenCreate, manage CI/CD service tokens

Decision Trees

Should I use a branch or deploy request?

What's your goal?
├─ Experimenting with schema changes → Create branch (pscale-branch)
├─ Testing schema in isolation → Create branch (pscale-branch)
├─ Ready to deploy schema to production → Create deploy request (pscale-deploy-request)
└─ Reviewing schema changes before production → Review deploy request (pscale-deploy-request)

Service token vs password?

What's your use case?
├─ CI/CD pipeline → Service token (pscale-service-token)
├─ Local development → Password (pscale-password)
├─ Production application → Service token (rotatable, secure)
└─ One-off admin task → Password (temporary)

Direct promotion vs deploy request?

Production readiness?
├─ Immediate promotion (dangerous) → pscale branch promote (pscale-branch)
├─ Review + approval workflow → pscale deploy-request create (pscale-deploy-request)
└─ Safe production deployment → Always use deploy requests

Common Workflows

Schema Migration Workflow

Complete workflow from branch creation to production deployment:

# 1. Create development branch
pscale branch create <database> <branch-name>

# 2. Make schema changes (via shell, ORM, or direct SQL)
pscale shell <database> <branch-name>

# 3. View schema diff
pscale branch diff <database> <branch-name>

# 4. Create deploy request
pscale deploy-request create <database> <branch-name>

# 5. Review and deploy
pscale deploy-request deploy <database> <deploy-request-number>

# 6. Verify deployment
pscale deploy-request show <database> <deploy-request-number>

See scripts/ directory for automation.

Branch Development Workflow

# Create branch from main
pscale branch create <database> <feature-branch> --from main

# Work on schema changes
pscale shell <database> <feature-branch>

# Check diff before deploying
pscale branch diff <database> <feature-branch>

# Create deploy request when ready
pscale deploy-request create <database> <feature-branch>

CI/CD Integration

# Create service token for CI/CD
pscale service-token create --org <org>

# Use in CI/CD pipelines (GitHub Actions, GitLab CI, etc.)
export PLANETSCALE_SERVICE_TOKEN_ID=<token-id>
export PLANETSCALE_SERVICE_TOKEN=<token>

# Create and deploy via CI/CD after review/approval gates pass
pscale deploy-request create <database> <branch> --format json
pscale deploy-request deploy <database> <deploy-request-number>

Cloudflare D1 to PlanetScale Postgres import

# Lint and dry-run first; review the JSON migration ID and warnings
pscale import d1 lint --input ./d1-export.sql --format json
pscale import d1 start <database> <branch> --input ./d1-export.sql --dry-run --format json

# After explicit confirmation, run and verify the import
pscale import d1 start <database> <branch> --input ./d1-export.sql --migration-id <id> --format json
pscale import d1 verify <database> <branch> --migration-id <id> --input ./d1-export.sql --format json

Quick Reference

Most Common Commands

# Authentication
pscale auth login
pscale auth logout

# Branch management
pscale branch create <database> <branch> [--from <source-branch>]
pscale branch list <database>
pscale branch delete <database> <branch>
pscale branch parameters list <database> <branch> --format json
pscale branch resize status <database> <branch> --format json
pscale branch vtgate show <database> <branch> --format json
pscale branch update <database> <branch> --deletion-protected=true --format json

# Discover and use a Vitess read-only region
pscale keyspace read-only-regions <database> <branch> <keyspace> --format json
pscale keyspace read-only-regions add <database> <branch> <keyspace> <region> --cluster-size <size> --replicas <count>
pscale password create <database> <branch> <name> --read-only-region <region> --format json

# Deploy requests
pscale deploy-request create <database> <branch>
pscale deploy-request list <database>
pscale deploy-request storage-check <database> <number> --format json
pscale deploy-request operations <database> <number> --format json
pscale deploy-request deploy <database> <number>

# Dedicated PostgreSQL PgBouncers
pscale pgbouncer list <database> <branch> --format json
pscale pgbouncer show <database> <branch> <name> --format json

# Database operations
pscale database create <database> --org <org>
pscale database list
pscale database show <database> --format json
pscale database ip-restriction list <database> --format json
pscale database throttler show <database> --org <org> --format json
pscale database aggressive-cutover show <database> --org <org> --format json
pscale shell <database> <branch>

# Maintenance schedules and windows (Vitess Enterprise)
pscale maintenance list <database> --org <org> --format json
pscale maintenance windows <database> <schedule-id> --org <org> --format json

# Backup policies and authentication-attempt exports
pscale backup policy list <database> --format json
pscale audit-log auth-attempts download --org <org> --since 24h --outcome deny

# Non-interactive read query for agents/scripts
pscale sql <database> <branch> --org <org> --format json --query "SELECT 1"

# Point-in-time diagnostics, branch metrics, and query-fingerprint analysis
pscale inspect all <database> <branch> --org <org> --format json
pscale metrics report <database> <branch> --org <org> --period 1d --format json
pscale metrics show <database> <branch> --org <org> --metric queries --metric latency_p99 --period 1h --format json
pscale insights queries <database> <branch> --org <org> --sort p99Latency --period 1h --format json
pscale insights queries samples <database> <branch> <fingerprint> --org <org> --keyspace <keyspace> --format json
pscale insights tags summaries <database> <branch> --org <org> --tags app --sort totalTime --format json
pscale insights errors show <database> <branch> <full-error-fingerprint> --org <org> --format json
pscale insights anomalies show <database> <branch> <anomaly-id> --org <org> --format json
pscale insights recommendations <database> --org <org> --format json

# Postgres Traffic Control inventory
pscale traffic-control budget list <database> <branch> --org <org> --format json

# Cloudflare D1 import dry-run
pscale import d1 start <database> <branch> --input ./d1-export.sql --dry-run --format json

Related Skills

  • drizzle-kit - ORM schema management and migrations
  • gitlab-cli-skills - GitLab MR workflow integration
  • github - GitHub PR and CI/CD integration

Automation Scripts

See scripts/ directory for token-efficient automation:

  • create-branch-for-mr.sh - Create PlanetScale branch matching your MR/PR branch name
  • deploy-schema-change.sh - Complete schema migration workflow
  • sync-branch-with-main.sh - Create a replacement branch from main/base for conflict resolution

Scripts execute without loading into context (~90% token savings).

Resources

Top skills in this category