数据分析

PlanetScale CLI Skills

PlanetScale CLI(pscale)命令参考与工作流:分支、部署请求、Schema 变更、SQL、查询分析与 D1 导入。

它能做什么

pscale 命令的统一参考入口,将认证、分支、部署请求、数据库、SQL、insights、诊断 inspect、备份 backup、密码 password、组织 org、服务令牌 service-token 以及 pscale import d1 等任务路由到对应子技能。内置三组决策树:分支 vs 部署请求、服务令牌 vs 密码、直推 vs 评审流程,并整理了 Schema 迁移、分支开发、CI/CD 接入以及 Cloudflare D1 导入到 PlanetScale Postgres 的完整流程。同时强调配置与凭据安全、JSON 错误码处理,以及无需加载到上下文即可执行的脚本。

什么时候用它

  • 在 Schema 变更场景下选择分支还是部署请求
  • 调整 VTGate 规格或管理 Vitess 只读区域及区域限定密码
  • 执行非交互 SQL、做 inspect 诊断或分析生产查询 insights
  • 将 Cloudflare D1 SQLite 导出导入 PlanetScale Postgres

技能文档

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.

Sub-Skills

CommandSkillUse When
authpscale-authLogin, logout, service tokens, authentication management
branchpscale-branchCreate, delete, promote, diff, list branches, inspect branch infra, manage Postgres size/replicas/parameters, resize Vitess VTGates, manage Vitess tablet throttling, download/query-stream query pattern reports, manage Vitess MoveTables workflows
deploy-requestpscale-deploy-requestCreate, review, deploy, revert schema changes
databasepscale-databaseCreate, list, show, delete, and dump databases, including Vitess read-only-region dumps
sqlpscale-sqlRun non-interactive SQL queries with JSON output and ephemeral credentials
insightspscale-insightsAnalyze production query statistics, errors, anomalies, and schema recommendations
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, delete branch backups
passwordpscale-passwordCreate, list, delete, and scope Vitess connection passwords to read-only regions
orgpscale-orgList, show, switch organizations
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  

# 2. Make schema changes (via shell, ORM, or direct SQL)
pscale shell  

# 3. View schema diff
pscale branch diff  

# 4. Create deploy request
pscale deploy-request create  

# 5. Review and deploy
pscale deploy-request deploy  

# 6. Verify deployment
pscale deploy-request show  

See scripts/ directory for automation.

Branch Development Workflow

# Create branch from main
pscale branch create   --from main

# Work on schema changes
pscale shell  

# Check diff before deploying
pscale branch diff  

# Create deploy request when ready
pscale deploy-request create  

CI/CD Integration

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

# Use in CI/CD pipelines (GitHub Actions, GitLab CI, etc.)
export PLANETSCALE_SERVICE_TOKEN_ID=
export PLANETSCALE_SERVICE_TOKEN=

# Create and deploy via CI/CD after review/approval gates pass
pscale deploy-request create   --format json
pscale deploy-request deploy  

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   --input ./d1-export.sql --dry-run --format json

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

Quick Reference

Most Common Commands

# Authentication
pscale auth login
pscale auth logout

# Branch management
pscale branch create   [--from ]
pscale branch list 
pscale branch delete  
pscale branch parameters list   --format json
pscale branch resize status   --format json
pscale branch vtgate show   --format json

# Discover and use a Vitess read-only region
pscale keyspace read-only-regions    --format json
pscale password create    --read-only-region  --format json

# Deploy requests
pscale deploy-request create  
pscale deploy-request list 
pscale deploy-request deploy  

# Database operations
pscale database create  --org 
pscale database list
pscale shell  

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

# Point-in-time diagnostics plus server-side production-traffic analysis
pscale inspect all   --org  --format json
pscale insights queries   --org  --sort p99Latency --period 1h --format json
pscale insights recommendations  --org  --format json

# Cloudflare D1 import dry-run
pscale import d1 start   --input ./d1-export.sql --dry-run --format json
  • 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

相关技能

面向 Checkly CLI 与 Monitoring as Code 的参考与路由指南,按领域分发到对应的子技能。

38 次安装2 星标

通过 curl 调用 JSON-RPC API 发布 Web 应用,并获得一个公开访问的网址。

152 次安装8 星标

根据风险信号决定先规划还是直接执行,并按风险等级匹配规划深度,包含步骤、估算与回滚。

96 次安装2 星标

Provision instant temporary Postgres databases via Claimable Postgres by Neon (neon.new) with no login, signup, or credit card. Supports REST API, CLI, and SDK. Use when users ask for a quick Postgres environment, a throwaway DATABASE_URL for prototyping/tests, or "just give me a DB now". Triggers include: "quick postgres", "temporary postgres", "no signup database", "no credit card database", "instant DATABASE_URL", "npx neon-new", "neon.new", "neon.new API", "claimable postgres API".

33 次安装

为 Node 与 TypeScript 项目设计 Prisma schema、编写类型安全查询,并解决迁移、连接池与 N+1 关联加载问题。

101 次安装2 星标

Guides and best practices for working with Lakebase Postgres, the database behind Neon. Covers setup, connection methods and drivers, pooled vs direct connections, branching, autoscaling, scale-to-zero, instant restore, read replicas, connection pooling, IP allow lists, and logical replication. Use when users ask about "Lakebase Postgres", "Neon setup", "connect to Neon", "Neon project", "DATABASE_URL", "serverless Postgres", "Neon CLI", "neon", "Neon MCP", "Neon Auth", "@neondatabase/serverless", "@neondatabase/neon-js", "scale to zero", "Neon autoscaling", "Neon read replica", or "Neon connection pooling".

44 次安装