-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cli-core): add clerk enable and clerk disable commands for orgs and billing #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nicolas-angelo
wants to merge
10
commits into
main
Choose a base branch
from
feat/billing-orgs-shortcut-commands
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e81ba33
feat(cli-core): add clerk orgs and clerk billing shortcut commands
nicolas-angelo 8583f13
test(cli-core): add tests for orgs and billing shortcut commands
nicolas-angelo 8198e40
docs(changeset): add clerk orgs and clerk billing shortcut commands
nicolas-angelo a87ed32
docs: update README with orgs and billing commands
nicolas-angelo 7ea0381
feat(cli-core): rework orgs/billing toggles as top-level clerk enable…
nicolas-angelo c1cbd69
Merge remote-tracking branch 'origin/main' into feat/billing-orgs-sho…
nicolas-angelo 1cef254
feat(cli-core): offer clerk-billing agent skill install on clerk enab…
nicolas-angelo 9460de7
docs(changeset): tighten enable/disable changeset
nicolas-angelo 6bf1545
feat(cli-core): print next-steps hints after clerk enable orgs and en…
nicolas-angelo e4669c9
Merge remote-tracking branch 'origin/main' into feat/billing-orgs-sho…
nicolas-angelo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "clerk": minor | ||
| --- | ||
|
|
||
| Add `clerk enable` and `clerk disable` top-level commands for toggling features on the linked instance. | ||
|
|
||
| - `clerk enable orgs` / `clerk disable orgs` — toggle organizations, with `--force-selection`, `--auto-create`, `--max-members <n>`, and `--domains` on enable. | ||
| - `clerk enable billing [--for org,user]` / `clerk disable billing [--for org,user]` — toggle billing for organizations and/or users. `--for` defaults to both; enabling for `org` cascades to enabling organizations. Enable also offers to install the `clerk-billing` agent skill (suppress with `--no-skills`). |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # clerk billing (enable/disable) | ||
|
|
||
| Toggle Clerk billing for organizations and/or users on the linked instance. | ||
| The handlers are wired to top-level `clerk enable billing` and `clerk disable | ||
| billing` commands. | ||
|
|
||
| For arbitrary billing config edits (plans, trials, payment-method requirements) | ||
| use `clerk config patch --json '{"billing":{...}}'` until a dedicated | ||
| `clerk billing settings` command lands. | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| clerk enable billing [--for <targets>] [options] | ||
| clerk disable billing [--for <targets>] [options] | ||
| ``` | ||
|
|
||
| `<targets>` is `org` and/or `user`, accepted as space-separated, comma-separated, | ||
| or repeated `--for` flags (matching `clerk config pull --keys`). When omitted, | ||
| the command targets both: | ||
|
|
||
| ```sh | ||
| clerk enable billing --for org user | ||
| clerk enable billing --for org,user | ||
| clerk enable billing --for org --for user | ||
| clerk enable billing # defaults to both | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| | Flag | Description | | ||
| | ----------------- | ------------------------------------------------------------------------------- | | ||
| | `--for <targets>` | Targets (`org` and/or `user`), separated by spaces or commas. Defaults to both. | | ||
| | `--app <id>` | Target a specific application | | ||
| | `--instance <id>` | Target a specific instance (dev, prod) | | ||
| | `--yes` | Skip the confirmation prompt | | ||
| | `--dry-run` | Preview the patch without applying it | | ||
| | `--no-skills` | Skip the post-enable `clerk-billing` agent skill install (enable only) | | ||
|
|
||
| ## Agent skill | ||
|
|
||
| After a successful `enable billing`, the command offers to install the upstream `clerk-billing` agent skill from [`clerk/skills`](https://github.com/clerk/skills). `clerk init` doesn't bundle this one as a default — billing is opt-in — so this is the natural moment to surface it. | ||
|
|
||
| - **Human mode**: prompts `Install the` `clerk-billing` `agent skill?` defaulting to yes. Decline returns silently. | ||
| - **Agent mode (no TTY) or `--yes`**: installs non-interactively (`-y -g`). | ||
| - **`--no-skills`**: skips the install entirely. | ||
| - **`--dry-run`**: skips the install (no real side-effects in dry-run). | ||
|
|
||
| The install runs via the user's package runner (`bunx`, `pnpm dlx`, `yarn dlx`, or `npx`), matching the `clerk init` flow. | ||
|
|
||
| ## Cascade behavior | ||
|
|
||
| - `enable billing --for org` (or `org,user`, or no `--for`) **also** sets | ||
| `organization_settings.enabled = true`. Billing for organizations requires | ||
| organizations enabled, so this saves a separate command. The cascade is | ||
| idempotent — if organizations are already on, the diff is empty for that | ||
| field. | ||
| - `disable billing` **never** touches `organization_settings`. To disable | ||
| organizations themselves, run `clerk disable orgs` separately. | ||
|
|
||
| ## Clerk API endpoints | ||
|
|
||
| | Method | Endpoint | Description | | ||
| | ------ | ----------------------------------------------------------------- | ------------------------------------------------------------- | | ||
| | GET | `/v1/platform/applications/{appId}/instances/{instanceId}/config` | Fetch current config for diff before mutation | | ||
| | PATCH | `/v1/platform/applications/{appId}/instances/{instanceId}/config` | Patch `billing.*` (with `?dry_run=true` when `--dry-run` set) | |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--yesis advertised onorgs enable/disable,billing enable/disable, andplans create/update/remove, but no implementation consultsoptions.yesor callsconfirm(). The commands always mutate silently. Users who see--yeswill reasonably assume there is a prompt to skip.Compare with
config patch, which these shortcuts wrap:packages/cli-core/src/commands/config/push.ts:94-102doesif (!options.dryRun && isHuman() && !options.yes) { await confirm(...) }. Without an equivalent branch here, the shortcut is strictly more dangerous than the command it's supposed to replace.Fix: either remove
--yesand theyes?: booleanfields until a prompt exists, or add the real confirmation branch for every mutating command. Option two is the right call, these are production config edits.