Repository navigation
feat(cli): add account spending-cap commands [show] - #1613
Merged
ejanusevicius merged 3 commits intoNov 23, 2026
Merged
Conversation
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
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
marked this pull request as ready for review
November 23, 2026 08:58
ejanusevicius
deleted the
edvinas/tree-1269-cli-spending-limit-in-the-cli
branch
November 23, 2026 13:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Affected Components
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.
standingisnull, 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 throughconfirmOrAbortwith--forceand--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.InvalidInputError(exit 2).-o detail|json|md.jsonprints the API response unchanged.billing:read/billing:updateand the account must manage its plan in Checkly. The account-not-accessible 403 passes through unchanged.account:spending-capoclif topic, the new commands incommand-metadata.spec.ts, and amanage-spending-capAI-context reference.skills/checkly/SKILL.mdwas regenerated withsync:skills.Notes for the Reviewer
Depends on an backend API.
GET/PUT /v1/billing/spending-caplive on branchedvinas/tree-1269-cli-spending-limit-in-the-cliin 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:
billing:*permission apart from a missingSTRIPE_PLAN_MANAGEMENTfeature without a backenderrorCode, so the 403 message names both.REACHED.-odefault isdetail(likeaccount usage summary);members updateusestable.--output json, not in the terminal view.AuthCommandauthenticates beforerun(), so a bad amount is only rejected after the credential check. It never reaches the spending-cap API.checkly account --helplistsspending-capboth 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 summarycould fetch the cap for the terminal and md views and add a line such asSpending 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).Testing
1. Configuration
4c62d696(head of #1613). Clean build.http://localhost:3000. Monorepo commit8b2ae8a333.route-spending-cap.bb-spec.ts.CHECKLY_ENV=local,CHECKLY_API_URL=http://localhost:3000,CHECKLY_NO_DELEGATION=1.accountUsageTeamaccountUsageHobbypublicSpendingCapStarterspendingCapPrepaidspendingCapNoFeatureSTRIPE_PLAN_MANAGEMENT.2. Procedure
tilt up api-tests. Wait until the seed is complete.pnpm install, thenpnpm --filter checkly run prepare.CHECKLY_CLI_MODE=ci. Exceptions are marked.publicSpendingCapStarterat the end. This gives the seed state again.3. Results
All 41 commands gave the expected result.
3.1 Show
account spending-cap -o detail|json|mdaccount spending-cap -o detail|json|mdaccount spending-cap -o detail|mdaccount spending-cap -o detail|json|mdOutput: TEAM account with a cap.
-o detail:-o md:-o json:{ "spendingCapCents": 3000, "standing": { "measuredAt": "2099-11-15T00:00:00.000Z", "pools": { "API": { "used": 17230, "included": 100000, "overageRuns": 0, "overageCents": 0 }, "BROWSER": { "used": 14890, "included": 12000, "overageRuns": 2890, "overageCents": 1806.25 } }, "overageCents": 1806.25, "limit": { "capCents": 3000, "state": "UNDER", "closeAtCents": 2400 } } }3.2 Set and remove
set 20 --dry-runset 20(agent mode)confirmation_required. Confirm command has--force. No change.set 20 --forceset 12.50 --force -o json{"spendingCapCents": 1250}set 15 --force -o mdset 0 --dry-run,set 0.20 --dry-runset 5 --dry-runset 0.20(interactive, answer "no")remove --dry-runremove(agent mode)confirmation_required. No change.remove --force [-o json|md]{"spendingCapCents": null}.3.3 Errors
set abc,set 1.234,set -5set 10000.01set 1 --force [-o json]account spending-cap [-o json]account spending-capset 1 --forceaccount spending-cap4. Defects and observations
closeAtCents: nullfor a $0 cap. In #1613, the type isnumber.setandremovewith-o mdgive the same success line as-o detail.