Skip to content

feat(cli): add variable and variable-group commands - #395

Draft
clankergoose wants to merge 4 commits into
mainfrom
feat/variable-groups-cli
Draft

clankergoose wants to merge 4 commits into
mainfrom
feat/variable-groups-cli

Conversation

@clankergoose

@clankergoose clankergoose commented Nov 20, 2026 •

Copy link
Copy Markdown

Demo only. Not for merge. CLI side of the variable groups demo. Platform PRs: prisma/pdp-control-plane#6109 (API) and #6110 (Console). Spec: prisma/pdp-control-plane#5916. Review comments will not get replies.

Summary

Adds prisma variable (add / update / delete / list) and prisma variable group (list / create / update / delete) commands.

Key design decisions

  • --group <name> or --role production|preview select the target group; the two flags are mutually exclusive.
  • --branch is rejected on write commands with VARIABLE.NO_BRANCH_WRITE; branch overrides are deprecated and the new command writes to groups only.
  • Strict --role preview check (Decided 37): if the project has any custom groups, --role preview fails with VARIABLE.CUSTOM_GROUP_CONFLICT; use --group preview instead.
  • New API endpoints are not in @prisma/management-api-sdk v1.80.0. lib/variable/api.ts holds typed wrappers that cast once to the raw client. Every call site imports from that module rather than casting inline.
  • prisma deploy --variable lives in Composer (packages/composer) and is out of scope for this PR; noted as a known gap.
  • prisma branch list column renamed from "Env map" to "Variable group".
  • prisma project env commands warn on stderr that they are deprecated.

New commands

Command Description
prisma variable add KEY=VALUE --group <n> Add a variable to a group
prisma variable update KEY=VALUE --group <n> Update a variable's value
prisma variable delete KEY --group <n> Delete a variable
prisma variable list [--group <n>] [--branch <n>] List variables by group or what a branch receives
prisma variable group list List all groups with rule and branch count
prisma variable group create <name> --equals|--starts-with <val> Create a custom group
prisma variable group update <name> [--name] [--equals|--starts-with] Rename or change a group's rule
prisma variable group delete <name> [--confirm <name>] Delete a custom group

Tests

tests/variable.test.ts covers:

  • --group/--role mutual exclusion → VARIABLE.CONFLICTING_FLAGS

  • Missing both → VARIABLE.MISSING_GROUP

  • --branch on write commands → VARIABLE.NO_BRANCH_WRITE

  • --role preview with custom groups → VARIABLE.CUSTOM_GROUP_CONFLICT

  • variable add POST with correct groupId

  • variable update PATCH via looked-up id

  • variable delete DELETE via looked-up id

  • Dotenv file import

  • variable group list table rendering

  • variable group create --equals and --starts-with request bodies

  • Rule conflict / missing rule errors

  • variable group delete --confirm with built-in group rejection

  • variable update --file in a custom group: updates the group's rows, looked up by group id.

Checks

  • pnpm lint: passes.
  • pnpm typecheck: passes (9 of 9 tasks).
  • tests/variable.test.ts: 25 of 25 pass.
  • pnpm test in @prisma/cli: 700 pass, 4 fail. The same 4 fail on main in the same environment (auth-ops UI context and composer-isolation), and main also fails 15 test files there. They come from the local setup, not from this branch. One more auth-ops test fails intermittently on both.

tests/branch.test.ts: updated column header "Env map" → "Variable group".
tests/mount-coverage.test.ts: 8 new commands added to the snapshot.
tests/e2e-coverage.test.ts: 8 new commands excluded with reason (endpoints not yet in published SDK or standard CI environment).

🤖 Generated with Claude Code

Adds `prisma variable` with add/update/delete/list subcommands and
`prisma variable group` with list/create/update/delete subcommands.

Variables write to named groups (--group <name> or --role
production|preview). --branch is rejected on write commands; use a
variable group or send a service variable with the deploy. --role
preview fails when the project has custom groups (Decided 37).

New API endpoints (variable-groups, resolved-variables, groupId filter
on environment-variables) are not in @prisma/management-api-sdk v1.80.0
so they are called through typed wrappers in lib/variable/api.ts that
cast once to the raw client.

Also:
- Renames "Env map" column to "Variable group" in `branch list`.
- Adds a deprecation warning to all `project env` write/list commands.
- Adds the 8 new commands to the e2e-coverage exclusion list (endpoints
  not yet deployed to the standard CI environment) and to the
  mount-coverage snapshot.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@prisma/cli@395
npx https://pkg.pr.new/@prisma/cli-engine@395

commit: a2fc73c

tylerhogarth and others added 3 commits November 20, 2026 08:08
…lint

`variable update --file` looked each key up by role, so in a custom
group it changed the preview group's row. It now looks keys up by group
id, the same way the single-key path does. Also fixes lint: removes an
unused import and test helper, a nested ternary and non-null assertions,
and gives a reason for each remaining cast and sequential await.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…verrides

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xamples

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants