How to protect Stripe from Claude Code

Last updated ยท OsmoSync LLC

Short answer

Give the agent a restricted or test-mode key, never your full live secret key, and add a hook that blocks refunds, payouts and transfers before they run. Passkey for AI's free Stripe preset does that: money-out actions are blocked, any amount over $1,000 is blocked, and every other call that touches the account asks for Touch ID with the amount and LIVE or test in the dialog.

What can go wrong

An agent with a Stripe key can do anything the key allows. In a coding session that includes the Stripe CLI, the Stripe MCP server and plain HTTPS calls to api.stripe.com. The risky calls are the ones you cannot undo: refunds, payouts, transfers, deleting customers or webhooks, creating payment links, and anything over a sensible amount. A prompt injection hidden in a web page or an issue can steer an agent toward them.

Step 1: use test mode for agent work

Do development against test mode keys (sk_test_). Live keys should not sit in the environment of a coding agent at all. Passkey blocks live secret keys (sk_live_, rk_live_) pasted into shell commands, but the safest key is the one the agent never has.

Step 2: give it a restricted key

When the agent needs live access, create a restricted key in the Stripe Dashboard with only the scopes the task needs. Leave refund, payout and transfer scopes off. Stripe then refuses those calls on its own, whatever the agent tries.

Step 3: prefer MCP tools over shell

A Stripe MCP call has structured inputs (an action name, an amount, a customer), so a rule can match it exactly. A shell command is free text that an agent can reshape. Use the MCP server for sensitive work and keep the shell rules as the backstop.

Step 4: add the Stripe preset

The Stripe preset is free and on by default in the installer. It works like this:

ActionWhat happens
Refunds, payouts, transfers, top-ups, credit notes, disputes, deletes, coupons, API keys, webhooks, connected accounts, bank accounts, Treasury, IssuingBlocked, no prompt
Any amount over $1,000 (an amount it cannot read also blocks)Blocked
Live secret keys in shell commands, and tools whose names mean money out or cancellationsBlocked
Finalize, send, payment links, checkout, subscriptions, void, quotesTouch ID, always
Everything else that touches the account, including readsTouch ID with a plain-words dialog
Docs search and API schema lookupsPasses

The dialog says what and how much, for example create a payment link for $100.00 (LIVE). You read it, you touch the sensor, or you do not.

Step 5: read the log

Each block, ask and approval goes to ~/.claude/passkey/audit.log. Skim it after a long agent session. Touch ID proves you were present, not that you read the dialog, so the log is your second look.

Frequently asked questions

Does the Stripe preset cost anything?

No. The Stripe preset and the built-in guard are in the free plan. Pro adds the git, publish and shell-danger presets and custom rules.

Does it cover the Stripe CLI, the MCP server and raw API calls?

Yes. The preset matches Stripe MCP tools, the Stripe CLI and requests to api.stripe.com. MCP calls have structured inputs, so amounts and actions match exactly. Shell commands are free text, so prefer MCP for sensitive work.

Can I change the $1,000 limit?

Yes. The limit is a rule field in the preset and in your config. Edit it to fit your business, then run passkey approve to confirm the change with Touch ID.

Is a hook a replacement for restricted keys?

No. A restricted key without refund or payout scopes means Stripe itself refuses the call. The hook is a second line, and it also covers calls your key is allowed to make but you want a human to confirm.