Skip to main content
skill CX Codex

planetscale-pscale-cli-automation — Claude Code skill setup

Teaches coding agents to run the PlanetScale CLI non-interactively with JSON output. Useful when automating database tasks and verifying authentication.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add planetscale/skills --skill planetscale-pscale-cli-automation -a claude-code
Open on GitHub

What planetscale-pscale-cli-automation does

This skill configures agents to invoke the pscale command-line tool in headless scripts. It enforces passing --format json on commands and replacing interactive pscale shell sessions with pscale sql, preventing agent hangs caused by missing TTY terminals.

Parameter order matters here. Positional arguments must appear before flags, while the --org <org> flag belongs on resource subcommands like database or sql rather than the root command. By default, queries run under the reader role; write operations require explicit flags such as --role admin or --role writer.

Passing --format json never bypasses confirmation prompts on destructive actions. You must supply --force directly to individual subcommands because pscale does not provide an engine-wide global force flag or environment variable.

What it helps with

  • invoke PlanetScale CLI commands in headless automation
  • verify pscale authentication state from an agent
  • execute SQL queries without requiring a TTY terminal
  • handle destructive database subcommands with per-command force flags

Example prompts for the agent

  • Verify authentication status using pscale auth check --format json
  • Query mydb on branch main with admin role using pscale sql
  • List databases for organization my-org using pscale database list --format json

How to install planetscale-pscale-cli-automation

1Skills CLI (Vercel)

npx skills add planetscale/skills --skill planetscale-pscale-cli-automation -a claude-code

2Manually: put the files in place

~/.claude/skills/planetscale-pscale-cli-automation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/planetscale-pscale-cli-automation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about planetscale-pscale-cli-automation

How do I install planetscale-pscale-cli-automation in Claude Code?

Run npx skills add planetscale/skills --skill planetscale-pscale-cli-automation -a claude-code.

What does planetscale-pscale-cli-automation do?

It guides automated agents on how to run pscale non-interactively using --format json, correct flag positioning, and proper SQL roles.

Why does this skill require pscale sql instead of pscale shell?

The pscale shell command expects an interactive TTY session and fails in headless automation. pscale sql handles non-interactive queries cleanly.

Source text

SKILL.md · MIT
---
name: planetscale-pscale-cli-automation
description: >-
  Use the PlanetScale CLI (pscale) from automated agents with --format json,
  auth check, pscale sql, and per-command --force. Run before other PlanetScale
  skills when driving pscale directly. Use when the user asks to automate
  pscale, run CLI commands headless, or verify pscale auth from an agent.
---

# PlanetScale CLI automation

## Purpose

Teach agents how to invoke `pscale` non-interactively. This skill covers **CLI
conventions only**. Operational workflows (inventory, safety review, schema
recommendations) use the other skills in this repo — start with
`../planetscale-safe-orchestrator/SKILL.md` for a full assessment.

## Two AGENTS.md files (do not confuse them)

| Document | Where | Purpose |
|----------|-------|---------|
| **CLI agent guide** | Shipped with `pscale` (`AGENTS.md` in the CLI repo, or `pscale agent-guide`) | How to call `pscale`: auth, `--format json`, flag placement, `pscale sql` |
| **Project agent guide** | Your application repository's `AGENTS.md` | Which org, database, branch, engine, prod branch, MCP scope, approval rules |

Do not edit project `AGENTS.md` without operator approval (see
`../planetscale-mcp-agent-operating-model/SKILL.md`).

## Bootstrap (always start here)

```bash
pscale agent-guide --format json
pscale auth check --format json
```

If `auth check` returns `"status": "action_required"`, follow `issues` and
`next_steps` in the JSON. For login, the human may need to approve in the
browser; use `pscale auth login --format json`.

## Conventions

- Always pass **`--format json`** for automation.
- Put **`--org <org>`** on resource subcommands (`database`, `branch`, `sql`,
  `api`, …) — not on root `pscale`.
- Put **positional arguments before flags** (`pscale sql mydb main --org bb …`).
- Use **`pscale sql`**, not `pscale shell` (shell requires a TTY).
- Default SQL role is **reader**; pass `--role admin` (or writer/readwriter) for
  writes. Match `pscale shell` semantics for `--role` and `--replica`.
- **`--force`** is per subcommand only (e.g. `database delete … --force`, `pscale
  sql … --force`). There is no global `--force` or `PSCALE_FORCE`.
- **`--format json` alone never skips confirmations** — add `--force` on the
  destructive subcommand after explicit user approval.

## Typical workflow

```bash
pscale auth check --format json
pscale org list --format json
pscale database list --org <org> --format json
pscale branch list <database> --org <org> --format json
pscale sql <database> <branch> --org <org> --format json --query "SELECT 1"
```

MySQL uses `@primary` by default (same as `pscale shell`); pass `--keyspace` only
for multi-keyspace databases.

## MCP vs CLI

- **MCP clients** — use the hosted PlanetScale MCP server (see `pscale agent-guide
  --format json` for the current URL).
- **Shell scripts and coding agents** — use `pscale` with `--format json` as above.

## When this skill is not enough

Install the full PlanetScale skills pack (if not already):

```sh
git clone https://github.com/planetscale/skills.git && cd skills && script/setup
# or: npx skills add planetscale/skills -g -y
```

Then run sub-skills or `../planetscale-safe-orchestrator/SKILL.md` for database operations
beyond basic CLI invocation.

## Current conventions source of truth

Prefer live output over memorized flag syntax:

```bash
pscale agent-guide --format json
```

The embedded `guide` field contains the full CLI agent guide shipped with your
`pscale` binary.

© planetscale · MIT · planetscale/skills

Similar skills

All skills for Data and databases →

From the same set14

planetscale-postgres-safety-review Reviews PlanetScale Postgres setups across roles, pg_strict, Traffic Control, and backups. It flags database reliability gaps without applying unapproved changes. CX Codex +1 1,800installs planetscale-best-practices-matrix The skill maps database findings to PlanetScale recommendations and tells you what applies to Vitess and what to Postgres. CX Codex +1 1,800installs planetscale-vitess-safety-review Reviews a PlanetScale Vitess database for safe migrations, deploy requests, Insights and webhooks. Produces a report, applies nothing. CX Codex +1 1,700installs planetscale-webhook-automation-recommendations Recommends PlanetScale webhook subscriptions and safe automation patterns for database alerts, anomalies, and deploy requests. CX Codex +1 1,700installs planetscale-customer-report-template Turns inventory and review results into the final PlanetScale best-practices report for a customer database, with recommendations tied to measurements. CX Codex +1 1,700installs planetscale-traffic-control-recommendations This skill drafts a recommendation plan for PlanetScale Postgres Traffic Control budgets and rules, and applies nothing without approval. CX Codex +1 1,700installs planetscale-readonly-inventory Collects read-only inventory data from PlanetScale databases, branches, backups, and Query Insights. It audits infrastructure setup without risking mutations or secret generation. CX Codex +1 1,700installs planetscale-codebase-sqlcommenter-instrumentation Inspects a repo connected to PlanetScale and recommends an SQLCommenter-compatible package for tagging queries. Use it when queries in Insights and Traffic Control need to map back to code paths. CX Codex +1 1,700installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor