Skip to content

chore(cli): map branches and backups command permissions - #7152

Merged
Prashansa-K merged 8 commits into
developfrom
chore/cli-permission-map-branches
Oct 15, 2026
Merged

Prashansa-K merged 8 commits into
developfrom
chore/cli-permission-map-branches

Conversation

@Prashansa-K

Copy link
Copy Markdown
Contributor

Maps branches create|delete|disable|get|list|pause|unpause|update and backups list|restore to the Management API operations they can call, so scoped PATs can be granted per command. Drift tests keep each declaration in step with what the command does.

Shared changes.

  • New branchPrompt block (v1-list-all-branches, required) for the branch listing shown when no branch is given on a TTY.
  • The context text of projectRefPicker, linkedProjectCache and branchRef is reworded so it fits every command that includes it. No condition or label changed.

Blocks used. projectRefPicker and linkedProjectCache (all ten), branchPrompt and branchRef (delete, pause, unpause, update; get uses branchPrompt and declares its name lookup itself), upgradeSuggestion (create, update).

Conditions. branches get names the global output flags: the branch's API keys and pooler config are read for -o other than pretty, and with no -o when the output format is json or stream-json (--output-format, --agent yes, or a detected coding agent). This is the first declaration to name global flags in when.

Findings.

  • pause and unpause call the project-level pause and restore operations, so they need project_admin_write, not a branching permission.
  • disable needs only branching_production_delete.
  • A 4xx on create or update triggers the upgrade-suggestion lookups (best-effort).

Tests. Each command's integration test runs the project picker, the branch picker where it applies, and the real linked-project cache, and checks the exact request sequence. branches get covers each output mode that changes its calls; the agent-detected case is simulated through the output format.

Not covered. Context entries (branchPrompt, branchRef, the cache, the agent-detected entry) are asserted by request sequence only. --persistent=false is not run on every command.

Docs. The branches SIDE_EFFECTS.md files now give the cache path as <workdir>/supabase/.temp/linked-project.json, and get's doc states when the API keys and pooler config are read. All ten docs now list the project picker, branch picker and linked-project cache routes, and say when the cache file is written.

🤖 Generated with Claude Code

Prashansa-K and others added 4 commits October 14, 2026 17:22
Declares the Management API operations behind `branches create|delete|
disable|get|list|pause|unpause|update` and `backups list|restore`, so
scoped PATs can be granted per command.

Adds a `branchPrompt` block for the branch listing shown when no branch
is given on a TTY, and rewords the context of the project picker,
linked-project cache and branch lookup blocks so each fits every command
that includes it. `branches get` names the output flags, since only
machine output reads the branch's API keys and pooler config.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Seven `branches` side-effect docs placed the linked-project cache under
`~/.supabase/<workdir-hash>/`; it is written to
`<workdir>/supabase/.temp/linked-project.json`. `branches get` reads the
branch's API keys and pooler config for machine output, not only when
`--output` is not `pretty`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ayers

Runs the project picker, branch picker and linked-project cache through
their real layers in each branches and backups command test, asserts the
exact request sequence, and checks the recorded requests against the
declarations. `branches get` also covers each output mode that changes
which calls it makes, including agent-detected JSON.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ps docs

Adds the project picker (`GET /v1/projects`), the branch picker
(`GET /v1/projects/{ref}/branches`) and the linked-project cache lookup
(`GET /v1/projects/{ref}`) to each command's API routes, states when the
cache file is actually written, and replaces the empty Files Written
tables in the `backups` docs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Prashansa-K
Prashansa-K requested a review from a team as a code owner October 14, 2026 12:20

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

Both independent reviews completed; Codex reported no findings. Verified both Claude findings: confirmed one documentation nit and refuted the fixture-duplication nit based on the trusted testing convention. No functional defect was established.

Findings

Severity Location Category Sources Claim
⚪ NIT apps/cli/src/command-internal/branch-ref.resolver.ts:14 documentation claude The shared branchRef permission contexts misleadingly include --project-ref as a branch identifier source. All four commands currently using this block treat --project-ref as the parent project.
Refuted findings (kept for transparency, not posted as review comments)
  • apps/cli/src/commands/branches/delete/delete.integration.test.ts:47 (test-maintainability): Nine integration test files repeat nearly identical typed PROJECT fixtures, increasing maintenance work when the API schema changes.
    Refuted: The duplication exists, but trusted/CLAUDE.md:159 explicitly permits small local fixtures and says to accept some duplication rather than introduce unnecessary test abstractions. These are short, typed data fixtures with no duplicated behavior; the restore fixture also preserves distinct existing values. No correctness problem or concrete drift was identified, so extraction is an optional preference rather than an established issue under the documented convention.

Stats

Claude findings: 2 · Codex findings: 0 · Confirmed: 1 · Refuted: 1 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread apps/cli/src/command-internal/branch-ref.resolver.ts Outdated
@Prashansa-K
Prashansa-K added this pull request to the merge queue Oct 15, 2026
Merged via the queue into develop with commit 8d4a2ee Oct 15, 2026
42 checks passed
@Prashansa-K
Prashansa-K deleted the chore/cli-permission-map-branches branch October 15, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants