Skip to content

feat(cli): add account spending-cap commands - #1613

Draft
ejanusevicius wants to merge 2 commits into
mainfrom
edvinas/tree-1269-cli-spending-limit-in-the-cli
Draft

ejanusevicius wants to merge 2 commits into
mainfrom
edvinas/tree-1269-cli-spending-limit-in-the-cli

Conversation

@ejanusevicius

@ejanusevicius ejanusevicius commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Affected Components

  • CLI
  • Create CLI
  • Test
  • Docs (AI context / skill reference)
  • Examples
  • Other

Implements TREE-1269 "[CLI] Spending limit in the CLI". Customers can check and manage their overage spending cap from the CLI. The API calls it "spending cap", so the commands and the wording use that name too.

checkly account spending-cap                  # show (readOnly, idempotent)
checkly account spending-cap set <dollars>    # e.g. 50 or 12.50, 0 to 10000 (idempotent)
checkly account spending-cap remove           # destructive, idempotent
  • Show: prints the cap ("No cap", or "$0.00 (no overage allowed)"), the overage so far, the cap status (under / close / reached), whether checks are stopped, and when runs were measured. When standing is null, overage reads "Not measured" and the stopped and measured lines are left out, so it never shows $0.
  • set / remove: fetch the current cap first, then go through confirmOrAbort with --force and --dry-run. The preview shows the change ("Change the spending cap from $50.00 to $12.50"). It also warns when the new cap is at or below the overage so far (checks stop at once), or when it is $0.
  • Dollar input: converted to integer cents from the digits (no float drift), at most 2 decimals, 0 to 10000. Anything else throws InvalidInputError (exit 2).
  • Output: every command takes -o detail|json|md. json prints the API response unchanged.
  • Errors:
    • 409: the plan can't hold a spending cap (e.g. prepaid or contract).
    • 403: the role needs billing:read / billing:update and the account must manage its plan in Checkly. The account-not-accessible 403 passes through unchanged.
    • 401: legacy account API keys are not accepted; use a user or service key.
  • Also adds the account:spending-cap oclif topic, the new commands in command-metadata.spec.ts, and a manage-spending-cap AI-context reference. skills/checkly/SKILL.md was regenerated with sync:skills.

Notes for the Reviewer

Depends on an unmerged backend API. GET / PUT /v1/billing/spending-cap live on branch edvinas/tree-1269-cli-spending-limit-in-the-cli in the backend monorepo and are not merged or deployed yet. This PR is blocked from merge and release until that API ships. It has only been tested against mocks.

Open questions:

  • I can't tell a missing billing:* permission apart from a missing STRIPE_PLAN_MANAGEMENT feature without a backend errorCode, so the 403 message names both.
  • A $0 cap with $0 overage gets the "$0 allows no overage" warning, not "checks stop at once". This depends on whether the backend treats 0 ≥ 0 as REACHED.
  • The -o default is detail (like account usage summary); members update uses table.
  • The per-pool breakdown is only in --output json, not in the terminal view.
  • AuthCommand authenticates before run(), so a bad amount is only rejected after the credential check. It never reaches the spending-cap API.
  • checkly account --help lists spending-cap both as a topic and as a command (oclif's behaviour for a command that is also a topic, below the root).

Follow-up idea (not in this PR): account usage summary could fetch the cap for the terminal and md views and add a line such as Spending cap: $30.00 · overage so far $18.06 (close to cap), keeping its JSON unchanged.

Verified: pnpm --filter checkly run prepare (incl. tsc --build), pnpm lint, pnpm --filter checkly test (255 files, 4897 passed, 8 skipped).

🤖 Generated with Claude Code

Show, set and remove the overage spending limit from the CLI
(`checkly account spending-limit [set <dollars> | remove]`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ejanusevicius
ejanusevicius marked this pull request as draft November 20, 2026 13:18
Match the API: `/v1/billing/spending-cap`, `checkly account spending-cap`,
"spending cap" in user-facing text. Explain the 401 legacy account API
keys get.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ejanusevicius ejanusevicius changed the title feat(cli): add account spending-limit commands feat(cli): add account spending-cap commands Nov 20, 2026

This branch has not been deployed

No deployments
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.

1 participant