Sources: the stripe/stripe-cli source at commit 78a032ff933e9924ff306123fbe373c1ee885c55 (2026-11-13), shallow-cloned to ~/scratch/stripe-src/stripe-cli, plus docs.stripe.com/cli/* (fetched 2026-11-15).
Code links are pinned to that commit (https://github.com/stripe/stripe-cli/blob/78a032ff…/<path>).
Repo files were read as data. Nothing was built or run.
Note:
docs.stripe.com/stripe-cli/*now redirects todocs.stripe.com/cli/*. The old/stripe-cli/telemetryand/stripe-cli/keyspages are gone (404), so the telemetry claims below come from source code only.
go 1.27.3), cobra + viper + pflag, TOML config at ~/.config/stripe/config.toml, OS keyring through zalando/go-keyring with a 0600 file fallback.stripe customers create --name=…) are generated by go generate from a CLI-specific OpenAPI file. The generator depends on Stripe’s own x-stripeOperations extension (method_name, method_on). Generic NewOperationCmd executors do the actual work at runtime.stripe charges capture <id>, stripe payment_intents confirm <id>. Path params become positional args. Body params become --kebab-flags, and -d key[nested]=v is the escape hatch.access.stripe.com, with a refresh token in the keyring and silent refresh. --interactive still lets you paste a key, and --non-interactive prints JSON for agents.listen depends on Stripe server infrastructure. POST /v1/stripecli/sessions returns a websocket URL and a whsec_ secret. Stripe signs each event server-side, and the CLI passes the headers through to --forward-to.trigger is a client-side fixture runner: embedded JSON sequences of API calls with ${step:path} references. It creates real objects, and the events come out of that as a side effect.--limit / --starting-after / --ending-before. Other request flags: -i sets Idempotency-Key, -v/--stripe-version, --stripe-account, -e expand, -s show headers, --dry-run, --live.--format on API calls; --format json exists only for listen and logs tail. Non-401 HTTP errors print the body and appear to exit 0.r.stripe.com/0 and Sentry. Opt out with STRIPE_CLI_TELEMETRY_OPTOUT=1 or DO_NOT_TRACK=1. Self-update is signed and applies only to script installs. Plugins are HashiCorp go-plugin over gRPC.go 1.27.3 (go.mod). CI tests that version on ubuntu, macOS and windows (.github/workflows/test.yml).cobra.OnInitialize(Config.InitConfig, ReBindKeys) and bindEnv("project-name","STRIPE_PROJECT_NAME").cmd/stripe/main.go: entry point (telemetry, Sentry, auto-update hooks).pkg/cmd/: one file per handwritten command. root.go registers everything. pkg/cmd/resources/*_gen.go holds the generated resource commands.pkg/gen/: code generators and *.go.tpl templates.api/openapi-spec/spec3.cli.json (about 7.7 MB) and spec3.cli.preview.json (about 9.8 MB): CLI-specific specs, synced by a bot workflow (.github/workflows/sync-openapi-artifacts.yml).pkg/requests/ builds requests, pkg/stripe/ is the low-level HTTP client, pkg/config/ holds profiles, pkg/login/ the auth flows, pkg/keyring/ secret storage.pkg/proxy/ and pkg/websocket/ implement listen. pkg/logtailing/ implements logs tail. pkg/fixtures/ drives trigger and fixtures.pkg/plugins/ is the go-plugin system and rpc/ holds the gRPC protos for daemon.pkg/autoupdate/ handles self-update. pkg/reporting/ wraps Sentry.canary/ holds end-to-end tests against the compiled binary. npm/ holds the npm wrapper packages. .goreleaser/ has mac.yml, linux.yml and windows.yml.Key dependencies (go.mod):
| Area | Packages |
|---|---|
| CLI and config | spf13/cobra, spf13/viper, spf13/pflag, spf13/afero (filesystem mocking), BurntSushi/toml |
| Secrets and network | zalando/go-keyring, gorilla/websocket |
| JSON output | tidwall/gjson, tidwall/pretty |
| Terminal UI | logrus, briandowns/spinner, manifoldco/promptui, charm bubbletea/lipgloss/glamour (TUI and stripe docs markdown rendering) |
| Plugins and RPC | hashicorp/go-plugin with grpc/protobuf, hashicorp/go-version |
| Release and errors | google/go-github (release lookups), getsentry/sentry-go |
| Tests | stretchr/testify |
| Codegen and versions | iancoleman/strcase, Khan/genqlient |
Registered in init() of pkg/cmd/root.go:
| Command | What it does | Source |
|---|---|---|
login (list, switch) |
Browser/device auth. --interactive pastes a key, --non-interactive prints JSON, --complete <poll-url>, --new-session |
pkg/cmd/login.go |
logout, reauth, whoami, switch |
Revoke session, change granted permissions, show identity and authorized accounts, pick an account or sandbox (live/test) | pkg/cmd/logout.go, reauth.go, whoami.go, switch.go |
listen |
Webhook forwarding over a websocket (section 6) | pkg/cmd/listen.go |
trigger <event> |
Runs an embedded fixture that produces the event | pkg/cmd/trigger.go |
fixtures <file> |
Runs a user-supplied fixture JSON | pkg/cmd/fixtures.go |
logs tail |
Live API request log stream over a websocket, with --filter-* flags and --format json |
pkg/cmd/logs/tail.go |
events resend <id> |
Handwritten override of the generated events resource. Posts /v1/events/{event}/retry and adds for_stripecli=true unless --webhook-endpoint is given |
pkg/cmd/resource/events_resend.go |
get / post / delete <path or id> |
Raw HTTP verbs. get ch_123 infers the path from the ID prefix. Also available under stripe preview |
pkg/cmd/http.go, get.go |
<resource> <operation> |
Generated from OpenAPI (section 3). Also stripe v2 … and stripe preview … namespaces. stripe resources lists them |
pkg/cmd/resources/resources_gen.go |
open <shortcut> |
Opens Dashboard or docs pages from a static map | pkg/cmd/open.go |
config |
--list, --set, --unset, -e edit, --remove-profile |
pkg/cmd/config.go |
completion |
Writes bash, zsh or fish scripts (no PowerShell flag) | pkg/cmd/completion.go |
version (-v) |
Prints the version and checks GitHub for a newer release | pkg/cmd/version.go |
docs, docs api, docs search |
Renders docs.stripe.com in the terminal | pkg/cmd/docs/ |
sandboxes (create, claim, list, delete) |
Provisions a claimable sandbox without a browser, aimed at agents | pkg/cmd/sandbox.go |
plugin (install, upgrade, uninstall, list, auto-update) |
Plugin management (section 8) | pkg/cmd/plugin/ |
agent setup, daemon, data, reporting, feedback, community, provision, postinstall |
Agent tooling, gRPC daemon, metrics/Sigma previews, misc | pkg/cmd/agent.go, daemon.go |
samples, serve, status, terminal quickstart |
Removed in v1.51.0. They remain as hidden stubs that print guidance and exit non-zero | pkg/cmd/samples.go |
The global --map [tree|compact|paths|json] flag prints the whole command tree, which is useful for agents (pkg/cmd/map.go). Agent detection runs throughout the CLI: AIAgentHelpAnnotationKey adds help text for agents, and useragent.DetectAIAgent switches login to non-interactive mode (pkg/cmd/root.go, pkg/cmd/login.go).
//go:generate go run ../gen/gen_resources_cmds.go at the top of pkg/cmd/root.go. Build tag gen_resources (pkg/gen/gen_resources_cmds.go).
api/openapi-spec/spec3.cli.json and the preview spec (pkg/gen/openapi_paths.go).pkg/cmd/resources/resources_gen.go (wiring, about 1.2k lines) and specs_gen.go (OperationSpec literals, about 56k lines) from resources_cmds.go.tpl and resource_specs.go.tpl.pkg/requests/stripe_version_header.go, which pins Stripe-Version to the spec’s info.version (2026-10-28.endive) (pkg/requests/stripe_version_header.go).resources_cmds.go. The file has since been split.operationId or tags.
components.schemas and only considers schemas that carry x-stripeOperations: [{method_name, method_on, method_type, operation, path}] (pkg/spec/spec.go StripeOperation).method_on == "service" operations become commands. Deprecated operations and x-stripeNotPublic schemas are skipped.issuing.card yields the namespace issuing and the resource card. Paths containing test_helpers get a test_helpers sub-resource (pkg/gen/gen_resources_cmds.go genCmdTemplate).capability→capabilities, balance stays singular, everything else gets an appended s (pkg/cmd/resource/resource.go GetResourceCmdName).aliasedCmds (line_item→invoice_line_item) (pkg/cmd/resource/alias.go).method_name verbatim, so CRUD verbs and custom methods share one namespace. Example: payment_intents has apply_customer_balance, cancel, capture, confirm, create, increment_authorization, list, retrieve, search, update, verify_microdeposits (pkg/cmd/resources/resources_gen.go lines ~350–360). V1ChargesCapture maps to POST /v1/charges/{charge}/capture (pkg/cmd/resources/specs_gen.go).stripe customers create --email=… --name=… and stripe customers update cus_… -d "metadata[key]=value" (docs.stripe.com/cli/resources).NewOperationCmd):
{params} become exact positional args (validators.ExactArgs(len(urlParams)))._→-. Nested object properties are flattened to dotted flags (--usage-threshold.gte) by addDenormalizedParams (pkg/gen/gen_resources_cmds.go). metadata and expand are deliberately skipped.string/number → string flag, integer → int flag with sentinel -1, boolean → bool flag, array → StringArray.--help examples (buildExamples).--parent[child]=value is normalized to the dotted flag (pkg/cmd/resource/nested_flags.go).-d "nested[param]=value", which is form-encoded for v1. For v2 paths, -d is parsed into a JSON body (BuildDataForV2Request, pkg/requests/base.go).PostProcessResourceCommands patches events (adds resend), keys, approval_requests and climate, removes apps, and hides aliased names (pkg/cmd/resource/resource.go).-c/--confirm is passed (pkg/cmd/resource/operation.go, pkg/requests/base.go).login.Login calls GetLinks on the dashboard /stripecli/auth. A 3xx response means the machine is enrolled in OAuth, and the CLI runs LoginWithDeviceCode (pkg/login/login.go).https://access.stripe.com/stripecli/oauth2/device/authorization and /token, with scope=stripecli and public client id oacli_V18aOD6v0hs9CU (pkg/login/oauth_device.go).urn:ietf:params:oauth:grant-type:device_code, polled every 2 s, honoring slow_down. The browser URL prefers verification_uri_complete.oak_ prefix) and its expiry go to the keyring under uat and oauth_uat_expires_at. The refresh token goes under oauth_refresh_token. The active account/mode context goes under oauth_active_context (pkg/config/profile.go).RefreshUATIfNeeded refreshes when less than 60 s remain (pkg/config/profile.go).refreshOAuthToken stores the rotated refresh token. If the response omits one, it deletes the stored token. On invalid_grant or invalid_scope it wipes the credentials and asks the user to run stripe login (pkg/login/oauth_refresh.go).unauthorized on an oak_ token triggers one refresh and retry (pkg/requests/base.go performRequest).sync.Mutex (refreshMu). Two concurrent CLI processes can race a rotating refresh token.PollURL until the Dashboard confirms. It then saves a restricted key (pkg/login/client_login.go, pkg/login/keys/).KeyValidInDays = 90, recorded as test_mode_key_expires_at / live_mode_key_expires_at (pkg/config/profile.go).api_key_expired 401 gets a dedicated “run stripe login” message (pkg/cmd/root.go apiKeyExpiredMessage).--non-interactive is automatic when stdin isn’t a TTY. It prints {browser_url, verification_code, next_step} JSON and exits.next_step is stripe login --complete '<poll-url>' (legacy) or stripe login --complete-device (OAuth, with pending state saved to disk) (pkg/login/login.go, docs/cli/login).-i/--interactive prompts for a pasted API key (pkg/login/interactive_login.go).STRIPE_API_KEY env, then --api-key, then the profile (pkg/config/profile.go, docs/cli/api_keys).STRIPE_DEVICE_NAME sets the device label.stripe config --set test_mode_api_key sk_test_….-p/--project-name (default default, env STRIPE_PROJECT_NAME) selects a TOML table (pkg/cmd/root.go).PersistentPreRunE and leaves config.toml.v1.bak behind (pkg/config/migrate.go, pkg/cmd/config_migration.go).$XDG_CONFIG_HOME/stripe/config.toml, falling back to ~/.config/stripe/config.toml. Override with --config.InitConfig).writeProfile, pkg/config/profile.go).~/.config/stripe/credentials.json (0600). The CLI warns: “the system keyring is unavailable…” (pkg/keyring/keyring.go, pkg/login/login.go). The code comment says this copies the GitHub CLI pattern.--live flag, default test (pkg/requests/base.go InitFlags).ResolveCredentials).stripe switch changes the active account or sandbox. A context banner prints before requests (PrintActiveContextBanner).--api-base, --dashboard-base and --access-base flags exist for QA. --access-base is allow-listed so it can’t exfiltrate tokens (pkg/cmd/root.go PersistentPreRunE, pkg/login/access_base.go).ansi.ColorizeJSON, which runs tidwall/pretty and colors the result only when stdout is a TTY. Otherwise the raw body is printed unchanged (pkg/ansi/ansi.go, pkg/requests/base.go performRequest).--dark-style switches the palette.<id>.pdf instead of printed.--color on|off|auto, plus CLICOLOR / CLICOLOR_FORCE (pkg/ansi/ansi.go shouldUseColors). I found no NO_COLOR handling in that function.--format: API/resource commands have none. Only listen and logs tail take --format JSON. listen --print-json is deprecated in favor of --format json plus jq (pkg/cmd/listen.go, pkg/cmd/logs/tail.go).-s/--show-headers turns on a verbose transport that dumps the request and response headers (pkg/stripe/verbosetransport.go).--dry-run prints {dry_run:{method,url,params,headers}} with the bearer token redacted (pkg/requests/base.go BuildDryRunOutput).-H adds custom headers. --log-level debug|trace covers internals.Stripe-Notice response header is echoed to stderr.Execute prints errors to stderr and calls os.Exit(1) on any command error. Special-cased messages cover expired keys, more_permissions_required, login required (with auto-login on a TTY), and unknown commands (“Did you mean…”) (pkg/cmd/root.go).MakeRequest(..., errOnStatus=false). Only 401 becomes an error. Other 4xx/5xx bodies are printed as normal JSON and the function returns nil, so by code reading they exit 0 (pkg/requests/base.go performRequest; pkg/cmd/resource/operation.go). The canary tests only assert exit 0 on success paths (canary/api_test.go).errorcategory (UserInput, Auth, Network, Internal…), and a custom linter enforces it (pkg/errorcategory/category.go, Makefile lint).listen and triggerlisten POSTs /v1/stripecli/sessions with device_name, websocket_features[]=webhooks, optional filters, and forward URLs.{websocket_url, websocket_id, websocket_authorized_feature, secret, reconnect_delay, default_version, latest_version, …} (pkg/stripeauth/client.go, pkg/stripeauth/messages.go).secret is the whsec_… printed as “Ready! Your webhook signing secret is…”. It doesn’t change between restarts (docs/cli/listen). --print-secret prints it and exits (proxy.GetSessionSecret, pkg/proxy/proxy.go).webhook_event messages carry event_payload plus http_headers. Stripe has already computed Stripe-Signature server-side.--forward-to (pkg/websocket/webhook_messages.go, pkg/proxy/endpoint.go Post).event_ack and a webhook_response (status, body, headers) so the Dashboard can show the local endpoint’s result (pkg/proxy/webhook_event_processor.go).--events a,b, --all-snapshot, --all-thin, --events-from @self|@accounts|all.--forward-connect-to, -H headers, --latest (latest API version), --use-configured-webhooks (mirror the Dashboard endpoints), --skip-verify.--forward-to requires an explicit event selection (pkg/cmd/listen.go, docs/cli/listen).events resend replays an event to the CLI session via for_stripecli=true (section 2).trigger / fixtures:
//go:embed triggers/*, pkg/fixtures/triggers.go).{_meta:{template_version}, fixtures:[{name,path,method,params}]}. Later steps reference earlier responses with ${customer:id} and env vars with ${.env:VAR|default} (pkg/fixtures/triggers/customer.subscription.created.json, pkg/cmd/fixtures.go).--override step:path=val, --add, --remove, --skip step, --raw, --edit, --api-version, --stripe-account (pkg/cmd/trigger.go).All of these are registered in Base.InitFlags (pkg/requests/base.go):
-l/--limit, -a/--starting-after and -b/--ending-before. That is manual cursoring only; I found no auto-paging or --all anywhere in pkg/.-i/--idempotency sets Idempotency-Key. It warns when used on GET/DELETE. Nothing auto-generates a key.-v/--stripe-version overrides the version. Otherwise v2 paths send the generated pinned version, preview commands send the preview version, and v1 sends nothing, so the account default applies (computeVersionHeader).--stripe-account and --stripe-context.-e/--expand (repeatable). It is sent as the expand[] param for v1 and isn’t supported on v2.version, listen, trigger, fixtures and open call version.CheckLatestVersion(). It asks the GitHub releases API once every 24 h, waits a 24 h grace period after a release (so package managers can catch up), prints install-method-specific upgrade advice, and is disabled by STRIPE_NO_UPDATE_CHECK (pkg/version/version.go).-X …/pkg/version.Version={{.Version}}) and defaults to master (.goreleaser/mac.yml).CheckForUpdate stages a signed marker at most daily and skips major-version jumps.ApplyIfPending downloads the archive, verifies its checksum against the signed checksum file (RSA-3072 PKCS#1 v1.5 key embedded at pkg/autoupdate/release-key.pub), swaps the binary, and re-execs (pkg/autoupdate/checker.go, updater.go, signature.go, docs/release-signing.md).STRIPE_NO_AUTO_UPDATE=1 or auto_update = false in config.toml.AnalyticsTelemetryClient POSTs to https://r.stripe.com/0 (3 s timeout, async; overridable via STRIPE_TELEMETRY_URL) (cmd/stripe/main.go, pkg/stripe/analytics_telemetry.go).CLIAnalyticsEventMetadata): invocation_id, user_agent, command_path, flag names only (no values), merchant (acct_…), cli_version, os, arch, persistent machine_uuid, generated_resource, AI agent, agent host and version, install_method, tmux/screen, terminal program, and a bucketed http_outcome.PersistentPreRunE) and one API-request event per request, keyed by the Request-Id (pkg/stripe/client.go).errors.stripe.com, with scrubbing (pkg/reporting/).STRIPE_CLI_TELEMETRY_OPTOUT=1|true or DO_NOT_TRACK=1|true turns off both telemetry and Sentry (cmd/stripe/main.go TelemetryOptedOut). Dev builds (non-semver versions) also skip it.MagicCookieValue handshake.plugins.toml) lists releases per OS/arch with a Sum checksum. Binaries are downloaded from Stripe’s artifact host (pkg/plugins/plugin.go).registerInstalledPlugins, pkg/cmd/root.go). Known-but-missing plugins get hint or auto-install stubs (pkg/cmd/pluginhints/).CoreCLIHelper (login, config) (pkg/plugins/core_cli_helper.go). Subprocesses are reaped on SIGINT/SIGTERM.make release tags vX.Y.Z and pushes the tag. The release workflow runs canary tests first, then each platform job enters the protected GitHub release environment, which requires reviewers (Makefile, .github/workflows/release.yml).stripe_<v>_mac-os_<arch>.notarize.macos, which needs a P12 plus App Store Connect API key.stripe/homebrew-stripe-cli. The formula generates and installs bash/zsh/fish completions.nfpms produce deb + rpm, pushed by scripts/publish-to-artifactory.sh to packages.stripe.dev. The README’s yum repo has gpgcheck=0 (README.md).stripe/stripe-cli:{latest,<tag>}-{amd64,arm64} plus manifests, from an alpine image that only copies the binary (Dockerfile).stripe/scoop-stripe-cli.Stripe.StripeCli, submitted as a PR to microsoft/winget-pkgs.signs: → go run ./scripts/sign-release-checksums). The install scripts (curl -fsSL https://cli.stripe.com/install.sh | sh, install.ps1) refuse unsigned releases (docs/release-signing.md, scripts/install.sh).@stripe/cli is a shim with optionalDependencies on @stripe/cli-{darwin-arm64,darwin-x64,linux-x64,linux-arm64,win32-x64}, published with npm provenance after the GitHub release (npm/wrapper/package.json, release.yml npm job). This is the esbuild/biome pattern.--release-notes (.github/actions/generate-release-notes)._test.go files using testify. HTTP is mocked with httptest.NewServer, the filesystem with afero, the keyring with an in-memory store (pkg/keyring/testing.go).revokeToken, initiateLogin in pkg/cmd/login.go).make test: -race, coverage, 2 min timeout (Makefile, CLAUDE.md).canary/ runs the compiled binary (STRIPE_CLI_BINARY) to catch packaging, signal, env and exit-code problems.TestOffline* tests need no key. The full suite needs STRIPE_API_KEY (canary/README.md).test.yml runs a 3-OS matrix: golangci-lint v2 (.golangci.yml), the errorcategory linter, then make ci.make ci covers build-all-platforms, test, the go mod tidy diff check and the protoc diff check.docs/release-signing.md. User docs live on docs.stripe.com/cli, and stripe docs renders them in the terminal.Our API, from ~/scratch/tmh-sdks/openapi/openapi.developer.json, has these properties:
operationId and one of 15 tags. No x- vendor extensions.api.tme.so/v1 and sandbox.api.tme.so/v1.console.teachmehipaa.com/oauth/authorize (rotating refresh).cursor, or after on events.Idempotency-Key.:verb style (:cancel, :renew, :remind, :resendInvite, :redrive…).GET /organizations/{orgId}/operations/{operationId}.x-tmh-* headers: an HMAC-SHA256 over POST\n<path+query>\n<timestamp>\n<body-hash>, with a per-subscription secret.GET /organizations/{orgId}/events?after=&type= is the events pull log.| Stripe CLI capability | Verdict | teachmehipaa-cli mapping |
|---|---|---|
| Cobra + Viper + TOML config, XDG path, 0600 | Adopt | ~/.config/teachmehipaa/config.toml with [profiles.<name>] (start with the v2 nested layout so no migration is needed later). --profile/-p, env TMH_PROFILE. |
Spec-driven resource commands (go generate → generated wiring + OperationSpec table + generic executor) |
Adopt (pattern) / Adapt (input) | Stripe’s generator depends on x-stripeOperations, which we don’t have. Derive from tag + operationId instead: tag → resource (enrollments), operationId minus the noun → verb (createEnrollment→create, cancelEnrollment→cancel, resendEnrollmentInvite→resend-invite). Add an optional x-tmh-cli: {resource, verb, hidden} override instead of a hand switch like GetResourceCmdName. Path params become positional args, but orgId becomes a persistent --org flag / profile default because nearly every path starts with it. |
| AIP-136 custom methods as sub-verbs | Adopt | tmh enrollments cancel <id> → POST …/enrollments/{id}:cancel. Collection-level methods (enrollments:batch, :import, :export) become tmh enrollments batch. Escape the colon correctly in path templating. |
Body params as --kebab flags, nested as dotted, -d key[sub]=v escape hatch |
Adapt | Our bodies are JSON, so follow Stripe’s v2 path (BuildDataForV2Request): flags plus -d path.to.key=value assembled into JSON, plus --data @file.json / - for stdin. Skip the form-encoding (v1) path entirely. |
get/post/delete <path> raw verbs |
Adopt | tmh api <METHOD> <path> (gh-style) or tmh get/post/patch/put/delete. We need PATCH and PUT, which Stripe lacks at the top level. No ID-prefix inference unless our IDs become prefixed. |
stripe login browser pairing → restricted key / device code |
Adapt | Two modes. (a) tmh login = auth-code + PKCE (S256) through a loopback redirect (http://127.0.0.1:<random>/callback) to console.teachmehipaa.com/oauth/authorize. The rotating refresh token goes in the keyring, with silent refresh like refreshOAuthToken. Add --no-browser that prints the URL (and a paste-the-code fallback), plus --non-interactive JSON {browser_url, next_step} for agents, copying Stripe’s two-step design. (b) tmh login --client-credentials (or TMH_CLIENT_ID/TMH_CLIENT_SECRET env) stores the client id and secret in the keyring and mints a 15-min JWT on demand, caching it in memory or keyring with its exp. There’s no refresh token, so we just re-run the grant. Device code (RFC 8628) would need a new server endpoint; consider it later. |
| Rotating-refresh handling | Adopt + fix | Copy the logic: store a new refresh token when one is returned, wipe on invalid_grant, retry once on 401. Use a cross-process file lock (flock on ~/.config/teachmehipaa/.refresh.lock) instead of Stripe’s in-process sync.Mutex, because a rotating token raced by two shells logs the user out. |
| Keyring with 0600 file fallback + warning | Adopt | Never write secrets to the TOML. Stripe writes test keys in plaintext; skip that. |
--live per-command flag (default test) |
Adapt | --sandbox vs live per profile (environment = "sandbox"\|"live" → base URL), plus a --sandbox override flag. Print a context banner the way PrintActiveContextBanner does, and require confirmation for live DELETE or cancel-type custom methods (copy the DELETE confirm, -y/--yes to skip). |
| Pretty and colorized JSON on TTY, raw when piped | Adopt + extend | Add --output json\|yaml\|table and --jq <expr> / --template (gh-style), which Stripe lacks for API calls. Honor NO_COLOR. |
| Exit 0 on non-401 HTTP errors | Skip (do better) | Parse problem+json and render title/detail/errors[] to stderr. Map exit codes: 0 ok, 1 generic, 2 usage, 3 auth (401/403), 4 not found, 5 conflict/precondition (409/412), 6 validation (422), 7 rate-limited, 8 server. Keep the raw body available via --output json. |
-s/--show-headers, --dry-run, -H custom header, --log-level |
Adopt | Add --verbose that dumps request and response with Authorization redacted. --dry-run with a redacted token, exactly like BuildDryRunOutput. |
| Manual cursor flags only | Adapt | Generate --limit and --cursor (or --after for events). Add --all/--page-limit N, which follows nextCursor and streams NDJSON. Stripe has no auto-pager; ours should. |
-i/--idempotency |
Adopt + extend | --idempotency-key. Auto-generate a UUIDv4 for every POST to an operation whose spec declares the idempotencyKey header, and print it with --verbose so retries can reuse it. Stripe doesn’t auto-generate. |
--stripe-version pinned from the spec info.version |
Adapt | Pin the generated spec version in User-Agent/X-TMH-Client for diagnostics. We version by URL (/v1), so we don’t need a version flag. |
-e/--expand |
Adapt | Map onto our include query param where the spec has it (e.g. listEnrollments). Generated automatically as a normal flag. |
| AIP-151 LROs | New (no Stripe analog) | For operations returning an Operation (:import, :export, :batch), add --wait that polls getOperation with backoff and a spinner, then prints the result or the problem. Add tmh operations get <id> / tmh operations wait <id>. Exports end in a download, so add --out <file> (Stripe’s PDF auto-save is the precedent). |
listen (server websocket relay; Stripe signs server-side) |
Adapt (major) | We have no relay. Build tmh events tail: poll GET /organizations/{orgId}/events?after=<cursor>&type=… (cursor persisted per profile so restarts resume), print one line per event or NDJSON with --output json, and filter with --type a,b. --forward-to <url> POSTs each event locally and re-signs it locally: generate a per-profile local secret (tmh events tail --print-secret, stable across restarts like Stripe’s whsec_) and compute x-tmh-signature the same way production does. The signature covers the forward-to path+query, so compute it per destination. That lets the user’s verifier run unchanged against the local secret. Show the local status like Stripe’s webhook_response. Latency is the poll interval (2–5 s default, --interval). A server-side SSE or websocket relay could come later. |
events resend |
Adapt | Map to webhook-subscriptions redrive / test (already AIP-136 verbs in the spec). Locally, add tmh events forward <eventId> --forward-to … to replay one event from the pull log through the local re-signer. |
trigger (fixture runner creating real objects) |
Adapt | tmh trigger enrollment.created runs embedded fixture JSON against sandbox only (create learner → create enrollment → :cancel…), using the same ${step:path} reference syntax. Or call webhook-subscriptions:test where a synthetic event is fine. Refuse to run against live. |
fixtures <file> |
Adopt (later) | Same engine as trigger, for seeding sandbox orgs. |
logs tail (request log websocket) |
Skip (for now) | We have no request-log stream API. Revisit if we expose one. audit-events list --all covers part of it. |
open shortcuts |
Adopt (cheap) | tmh open console\|docs\|api-clients\|webhooks → static URL map. |
config --set/--list/--edit, whoami, logout (revoke), switch |
Adopt | whoami calls GET /auth/introspection. logout revokes the refresh token and clears the keyring. switch changes the default org for partner (multi-org) tokens via listPartnerOrganizations. |
completion |
Adopt + extend | cobra bash/zsh/fish plus PowerShell (Stripe omits it). |
--map json / agent annotations / non-interactive auto-detect |
Adopt | Cheap, and our API’s audience includes AI agents. |
samples, serve, status, sandboxes create, docs, data, reporting, daemon/gRPC |
Skip | Stripe-specific or already deprecated (samples/serve/status removed in v1.51.0). |
| Plugin system (go-plugin + gRPC + manifest) | Skip (v1) | Heavy. If ever needed, use gh-style tmh-<name> executables found on PATH. |
Version check (GitHub API, 24 h cache, grace period, install-method advice, *_NO_UPDATE_CHECK) |
Adopt | Same, with TMH_NO_UPDATE_CHECK. |
| Signed self-update (script installs only) | Adapt (phase 2) | Copy the model: RSA- or ed25519-signed checksums, verify before swap, never cross a major version, TMH_NO_AUTO_UPDATE. Ship the install script with signature checks first. |
Telemetry (r.stripe.com + Sentry, flag names only, *_TELEMETRY_OPTOUT, DO_NOT_TRACK) |
Adapt | HIPAA context: telemetry off by default (or opt-in on first run), never send org/learner IDs, honor DO_NOT_TRACK and TMH_TELEMETRY_OPTOUT. If enabled, send command path + flag names + version/os/arch + http outcome bucket, and send it to our own PostHog proxy, not a third party. |
| GoReleaser: Homebrew tap, Scoop, winget, deb/rpm, Docker multi-arch, npm optionalDeps shim, macOS notarize, signed checksums | Adopt (staged) | v1: GitHub Releases + Homebrew tap (teachmehipaa/homebrew-tap) + signed checksums + macOS notarization + install script. v1.1: Scoop, winget, npm shim (@teachmehipaa/cli, which fits our Node users), Docker ghcr.io/teachmehipaa/cli. Skip Artifactory deb/rpm until someone asks. Add Windows Authenticode, which Stripe lacks. |
| Canary E2E against the compiled binary + offline subset; 3-OS CI matrix; generator diff check | Adopt | Offline canaries against a mock server built from the spec (e.g. Prism) plus a sandbox suite. CI fails if go generate output differs from what’s committed. |
| Spec sync bot PR | Adopt | Workflow pulls openapi.developer.json from the platform repo, regenerates, and opens a PR. |
Go, as a standalone binary, with its own thin generated client. Don’t layer it on one of our SDKs.
CGO_ENABLED=1 on darwin) of about 15 MB. GoReleaser then gives us Homebrew, Scoop, winget, deb/rpm, Docker, notarization and signed checksums from YAML we can copy almost line for line from .goreleaser/*.yml. A Bun --compile binary built from teachmehipaa-node is roughly 60–100 MB and has weaker keyring support (it needs native addons or shelling out to security/secret-tool).pkg/browser, golang.org/x/oauth2 (PKCE and client-credentials built in), gorilla/websocket, testify. Stripe, gh and flyctl show the shape. We can lift Stripe’s patterns (generated OperationSpec table + generic executor, keyring fallback, non-interactive login JSON, signed self-update) directly. Stripe’s code is Apache-2.0, so keep attribution if we copy anything.pkg/requests. Our generator would output the cobra wiring plus an OperationSpec table from openapi.developer.json. Shared HTTP behavior (auth, retries, problem+json, idempotency) is about 1–2k lines of Go.events tail, --wait, and output. If Go staffing is a hard no, the fallback is TypeScript on Bun, compiled with bun build --compile, reusing @tmh/api-contracts Zod schemas for validation. Expect bigger binaries and hand-rolled packaging (no GoReleaser equivalent).