Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# PlanetScale CLI — agent guide

> **Developing the CLI?** The API client is vendored at `internal/planetscale/`;
> this repo **no longer depends on `planetscale-go`**. Read `doc/api-client.md`
> before touching API-facing code. The rest of this file is about *using* `pscale`.

For **any** automated agent or script using `pscale`. Always pass **`--format json`**. Substitute placeholders from the user's request or from prior command output (`org list`, `database list`, `branch list`).

If you only have the installed `pscale` binary, start here:
Expand Down
41 changes: 41 additions & 0 deletions doc/api-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# API client (`internal/planetscale`)

**The CLI no longer depends on `github.com/planetscale/planetscale-go`.**

As of July 2026, the Go API client that used to live in the planetscale-go
repository is vendored into this repo at `internal/planetscale/` and is
maintained here. The import path is:

```go
import ps "github.com/planetscale/cli/internal/planetscale"
```

## Why

Every API change used to require two PRs and a release dance: change
planetscale-go, tag a release, bump `go.mod` here, then write the CLI
feature. The CLI was the only internal consumer of planetscale-go, and the
published OpenAPI spec covers under half of the endpoints the CLI uses
(none of the vtctld/workflow/data-import surface), so generating a client
from the spec was not an option. Copying the client in removes the
cross-repo step entirely.

## What this means when adding or changing an endpoint

- Add the endpoint to api-bb, then add the method/types directly in
`internal/planetscale/` in the same CLI PR. There is no SDK release to
wait for and no version to bump.
- Do **not** add `github.com/planetscale/planetscale-go` back to `go.mod`,
and do not update the planetscale-go repo as a prerequisite for CLI work.
- Service interfaces (e.g. `DatabasesService`) live next to their
implementations; hand-written mocks are in `internal/mock/` and must be
updated when an interface changes, same as before.
- The client's `User-Agent` is `pscale-cli/<version>`, set by the CLI at
startup via `planetscale.WithUserAgent` (see `internal/cmd/root.go`).
There is no separate library version anymore.

## The planetscale-go repository

The public planetscale-go SDK still exists for external users, but this
repo does not consume it and changes there do not affect the CLI. Its
future (maintenance mode, archive, etc.) is tracked separately.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/muesli/termenv v0.16.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/planetscale/planetscale-go v0.176.0
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4
github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7
github.com/spf13/cobra v1.10.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjL
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e h1:MZ8D+Z3m2vvqGZLvoQfpaGg/j1fNDr4j03s3PRz4rVY=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e/go.mod h1:hwAsSPQdvPa3WcfKfzTXxtEq/HlqwLjQasfO6QbGo4Q=
github.com/planetscale/planetscale-go v0.176.0 h1:EkwiSM0+GbRVZ7/sCMP+AXD7VK1cO/gPBdMziY2JEMA=
github.com/planetscale/planetscale-go v0.176.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0=
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4 h1:Xv5pj20Rhfty1Tv0OVcidg4ez4PvGrpKvb6rvUwQgDs=
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4/go.mod h1:M52h5IWxAcbdQ1hSZrLAGQC4ZXslxEsK/Wh9nu3wdWs=
github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7 h1:aRd6vdE1fyuSI4RVj7oCr8lFmgqXvpnPUmN85VbZCp8=
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auditlog/auditlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"golang.org/x/text/cases"
"golang.org/x/text/language"

ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

// AuditLogCmd handles audit logs.
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auditlog/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/url"

"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auditlog/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
psauth "github.com/planetscale/cli/internal/auth"
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/planetscale-go/planetscale"

"github.com/fatih/color"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/spf13/cobra"

ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

// BackupCmd handles branch backups.
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/printer"

"github.com/planetscale/planetscale-go/planetscale"
"github.com/planetscale/cli/internal/planetscale"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/planetscale-go/planetscale"

"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/printer"

"github.com/planetscale/planetscale-go/planetscale"
"github.com/planetscale/cli/internal/planetscale"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/printer"

"github.com/planetscale/planetscale-go/planetscale"
"github.com/planetscale/cli/internal/planetscale"

"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/planetscale/cli/internal/cmd/branch/vtctld"
"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/connections/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/planetscale/cli/internal/cmdutil"
live "github.com/planetscale/cli/internal/connections"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"
)

type actionResult struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/connections/engine_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package connections
import (
"errors"

ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

// ValidateEngineFlags rejects flags that only apply to another database engine.
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/connections/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
live "github.com/planetscale/cli/internal/connections"
"github.com/planetscale/cli/internal/connections/history"
"github.com/planetscale/cli/internal/connections/tui"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/cli/internal/promptutil"
ps "github.com/planetscale/planetscale-go/planetscale"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/connections/top_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/planetscale/cli/internal/config"
live "github.com/planetscale/cli/internal/connections"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/connections_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/planetscale/cli/internal/cmd/branch/connections"
"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/planetscale/cli/internal/printer"

qt "github.com/frankban/quicktest"
ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

func TestBranch_CreateCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"

"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/planetscale-go/planetscale"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/planetscale/cli/internal/printer"

qt "github.com/frankban/quicktest"
ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

func TestBranch_DeleteCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/demote.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/planetscale/cli/internal/printer"
"github.com/spf13/cobra"

ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

func DemoteCmd(ch *cmdutil.Helper) *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/demote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"
)

func TestBranch_DemoteCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/fatih/color"
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/planetscale-go/planetscale"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/planetscale/cli/internal/mock"
"github.com/planetscale/cli/internal/printer"

ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

func TestBranchDiffCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"time"

"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"

"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"
)

func TestBranch_LintCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/planetscale-go/planetscale"

"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand Down
Loading