Always-loaded guidance for work inside packages/cli. Keep this file small. The CLI UX design system lives in packages/cli/.agents/skills/cli-ux/ and should be loaded only when the task touches user-facing CLI behavior.
- Inspect the current source and tests before changing behavior.
- Identify whether the task changes implementation only, or CLI UX/copy/output/help/errors/prompts/non-interactive behavior.
- For CLI UX work, use
packages/cli/.agents/skills/cli-ux/SKILL.mdand its references. Thecli-uxskill folder is the canonical source for CLI design, copywriting, output layout, prompts, machine-readable output, agent behavior, and command-specific UX contracts. - Reuse local helpers and command-family patterns before adding new abstractions.
- Preserve compatibility for command names, flags, exit codes, env vars, config files, JSON fields, parseable stdout, and telemetry semantics unless the change intentionally migrates them with tests.
- UX/copy/prompt/output/help/error/JSON/agent behavior: use
packages/cli/.agents/skills/cli-ux/SKILL.mdand load the references it names. - New or changed command metadata: update
src/commands/<name>/command.ts, telemetry, help snapshots, and tests. - Command implementation: follow the surrounding command family in
src/commands/<name>/and shared helpers insrc/util/. - Shared output, prompt, target resolution, or remote-mutation behavior: inspect parallel command paths before editing one path.
- New durable CLI UX rule or command-specific UX contract: update the
cli-uxskill, not this file.
src/commands/<name>/
command.ts command metadata: description, args, options, examples
index.ts routing, parsing, telemetry, errors
<action>.ts subcommand/action implementation
src/util/telemetry/commands/<name>/
index.ts telemetry client
test/unit/commands/<name>/
*.test.ts
Common shared areas:
src/util/arg-common.tsfor shared flags and command-string helperssrc/util/agent-output*for non-interactive/agent payloadssrc/util/output/*and output-manager helpers for terminal outputsrc/util/input/*for prompts and validated interactive inputsrc/util/{projects,teams,target,config}for shared resource and target resolutionsrc/util/{deploy,link,env,domains,alias}for high-impact remote mutation flows
- Define commands in
command.tsas const command objects. - Use lowercase kebab-case for flags.
- Reuse shared options from
src/util/arg-common.ts. - Parse flags with
parseArguments(args, getFlagsSpecification(command.options)). - Parent commands with subcommands may use permissive parsing to route; subcommands should parse strictly.
- Resolve subcommands with the
src/util/get-subcommanddefault export and the namedgetCommandAliaseshelper. - Return
0for completed success,1for operational failure, and preserve existing usage/help exit codes such as2unless intentionally normalizing them with tests. - Wrap top-level command logic in
try/catch, print user-facing errors, and return1. - Track telemetry after parsing and before command execution.
- Do not record tokens, secrets, env values, file contents, request bodies, or unredacted user content in telemetry.
- Unit tests live under
packages/cli/test/unit/commands/<name>/. - Prefer focused tests for changed command behavior before broad test runs.
- Use existing mock client/scenario patterns for API behavior.
- When changing output, update direct expectations and add negative assertions for removed strings.
- When changing JSON, parse stdout and assert shape; do not snapshot incidental formatting only.
- When changing interactive behavior, test both TTY and non-interactive paths when both exist.
- When changing shared output, prompt, target-resolution, or remote-mutation helpers, inspect and test parallel command paths.
Focused examples:
cd packages/cli
pnpm test test/unit/commands/<name>/<file>.test.ts
pnpm vitest-run test/unit/commands/<name>/<file>.test.tsRepo-level checks when appropriate:
pnpm build
pnpm type-check
pnpm lint
pnpm test-unitRun the local CLI against an external project without installing globally:
cd packages/cli
pnpm vercel --cwd /path/to/projectAlways-loaded digest; full CLI UX gates live in packages/cli/.agents/skills/cli-ux/references/verification.md.
- Do not prompt in non-interactive mode.
- Do not put human prose, warnings, ANSI, or spinners on JSON stdout.
- Do not expose secrets in output, JSON, debug logs, telemetry, or suggested commands.
- Validate local input before remote mutations.
- Do not retry non-idempotent remote mutations in a way that can duplicate resources.
- Do not edit examples, fixtures, generated files, or package-lock artifacts unless they are directly required for the task.
- Every PR needs a changeset. Use an empty changeset only for guide-only or
packages/cli/.agents-only changes.