Stripe Link CLI Skill
Agent-initiated spend via Stripe Link — requests purchases, issues virtual cards, owner approves in the Link mobile/web app.
by hewi333·MIT license·★ 122 Stars on the repo·GitHub ↗
npx degit hewi333/Mom-n-Pop-Skills/skills/stripe-link-cli#main ~/.claude/skills/stripe-link-cliChecked ·commit main
Inside this skill
SKILL.md · the author's own words# Stripe Link CLI Skill Wraps [@stripe/link-cli](https://github.com/stripe/link-cli) so Hermes can complete purchases on the user's behalf using one-time-use virtu… US-only at the moment (Link account requirement). Windows is not supported by the upstream CLI — this skill is gated `[linux, macos]`. ## When to Use Trigger phrases: - "buy X", "pay for X", "make a purchase", "complete checkout" - "get me a card", "I need a payment method" - "log in to Link", "connect my Link wallet" - HTTP 402 response from a merchant API with `www-authenticate: ... method="stripe"` If the user wants a paid API call (HTTP 402, no checkout form), the `card` path is wrong — use SPT via this same skill, or hand off to the…
Word-for-word excerpt, not a result. Read the full SKILL.md ↓
Files of Stripe Link CLI Skill
Show the full text228 lines
Stripe Link CLI Skill
Wraps @stripe/link-cli so Hermes can complete purchases on the user's behalf using one-time-use virtual cards or Shared Payment Tokens (SPT). Every spend is gated by an in-app approval in the Link mobile/web app — Hermes cannot self-approve.
US-only at the moment (Link account requirement). Windows is not supported by the upstream CLI — this skill is gated [linux, macos].
When to Use
Trigger phrases:
- "buy X", "pay for X", "make a purchase", "complete checkout"
- "get me a card", "I need a payment method"
- "log in to Link", "connect my Link wallet"
- HTTP 402 response from a merchant API with
www-authenticate: ... method="stripe"
If the user wants a paid API call (HTTP 402, no checkout form), the card path is wrong — use SPT via this same skill, or hand off to the mpp-agent skill.
Prerequisites
- Node.js 20+ available on
PATH(node --version) - US-based (Link account requirement)
The Link account, payment method, and spend-approval app do NOT need to be set up before Hermes attempts to pay — the CLI walks the user through them on first run:
- A Link account at https://app.link.com — created/linked during first
link-cliauth - At least one payment method — added during first run at https://app.link.com/wallet
- The Link mobile/web app — opened to approve the first spend request when it's made
No env vars required — auth state is stored locally by the CLI under its own config directory.
Install
Install once, globally:
npm install -g @stripe/link-cli
Or invoke ad-hoc via npx @stripe/link-cli. The skill below uses the installed link-cli form.
How to Run
All commands run through the terminal tool. The CLI auto-detects non-TTY callers and emits compact toon output by default — fine for the model. Pass --format json if a step needs structured fields.
Discover commands: link-cli --llms-full.
Get a command's schema before invoking: link-cli <command> --schema.
Procedure
1. Check / establish auth
link-cli auth status
If not authenticated, log in with a clear client name (this label shows in the user's Link app):
link-cli auth login --client-name "Hermes" --interval 5 --timeout 300
The --interval/--timeout form polls inline so the agent doesn't need to manage a _next step. Print the verification URL + phrase to the user and wait for the CLI to return.
Background-polling pattern (when not using inline flags): If you run auth login without --interval/--timeout (or with pty=true), it returns immediately with a verification_url, phrase, and a _next.command like auth status --interval 5 --max-attempts 60. Start that poll as a background terminal process with notify_on_complete=true so you get notified when the user approves:
link-cli auth status --interval 5 --max-attempts 60
# → run with: background=true, notify_on_complete=true, timeout=330
Print the verification URL and phrase to the user immediately — don't wait for them to ask. The background poll will notify you when auth succeeds.
Do not proceed past this step until auth status confirms login.
2. Evaluate the merchant before creating a spend request
Decide the credential type:
| Merchant surface | --credential-type |
|---|---|
| Standard web checkout form / Stripe Elements | card (default) |
Returns HTTP 402 with method="stripe" in www-authenticate |
shared_payment_token |
Returns HTTP 402 without method="stripe" |
unsupported — stop |
For 402 responses, do NOT decode the challenge manually. Pass the raw header:
link-cli mpp decode --challenge '<full WWW-Authenticate header>'
This validates the challenge and extracts the network ID + decoded request body.
3. List payment methods + shipping
link-cli payment-methods list
link-cli shipping-address list
Use the first entry unless the user specifies otherwise. The id from payment-methods list is the --payment-method-id in the next step.
4. Create the spend request
Confirm the final total with the user before issuing this command. Amounts are in cents.
link-cli spend-request create \
--payment-method-id <pm_id> \
--merchant-name "<name>" \
--merchant-url "<url>" \
--context "<what is being purchased and why — MUST be ≥100 characters or the CLI returns VALIDATION_ERROR too_small>" \
--amount <cents> \
--line-item "name:<item>,unit_amount:<cents>,quantity:1" \
--total "type:total,display_text:Total,amount:<cents>" \
--request-approval
For MPP merchants add --credential-type shared_payment_token.
--request-approval sends the approval push notification to the user's Link app and returns immediately with status: "pending_approval". It does NOT poll — the response includes a _next.command (spend-request retrieve <id> --interval 2 --max-attempts 300) that you must run separately to poll for approval.
Best pattern: After create --request-approval returns, immediately start a background retrieve call that combines polling + card retrieval in one shot (see Section 5). This eliminates the gap between approval and retrieval that causes card expiry.
5. Retrieve the credential — SECURELY
Do not print card details to stdout. Use --output-file so the PAN never enters the agent's transcript or logs.
All five options are required by the schema even though they appear to have defaults — omitting any of --timeout, --interval, --max-attempts, --force, or --include can cause a terminated error. Always pass all five explicitly:
Combined poll + retrieve (preferred): Combines approval polling and card retrieval in one background call. Run this immediately after create --request-approval returns — it polls until the user approves, then retrieves the card in the same process, eliminating the approval-to-retrieval gap:
link-cli spend-request retrieve <lsrq_id> \
--include card \
--output-file /tmp/link-card.json \
--timeout 600 \
--interval 2 \
--max-attempts 0 \
--force \
--format json
# → run with: background=true, notify_on_complete=true, timeout=660
Post-approval retrieve (only when poll already confirmed approval): If you already polled separately (e.g. via a background process) and confirmed status: "approved", retrieve the card with zero interval:
link-cli spend-request retrieve <lsrq_id> \
--include card \
--output-file /tmp/link-card.json \
--timeout 30 \
--interval 0 \
--max-attempts 0 \
--force \
--format json
The file is written with 0600 perms; stdout shows only redacted fields (brand, last4, expiry) plus a card_output_file path.
6. Use the credential
For web checkout: hand the file path to the user, OR pass it to a browser-driving tool that fills the form directly from disk. Never
read_fileorcatthe card file into the agent's reasoning context.For MPP merchants:
link-cli mpp pay <merchant-url> \ --spend-request-id <lsrq_id> \ --method POST \ --data '<json body>'
7. Clean up
Delete the card file as soon as the purchase is done:
rm -f /tmp/link-card.json
Optional: run as an MCP server instead
@stripe/link-cli --mcp exposes the same commands as MCP tools over stdio. To register it with Hermes' native MCP:
hermes mcp add stripe-link --command "npx" --args "@stripe/link-cli --mcp"
Then hermes mcp list should show stripe-link. The same approval rules apply — MCP doesn't bypass the Link app approval step.
Pitfalls
- US-only. Outside the US,
auth loginwill fail. Tell the user, don't keep retrying. --contextmust be ≥100 characters. The CLI returnsVALIDATION_ERROR / too_smallif shorter. Write a detailed context string (what, why, who) — not a one-liner.--request-approvaldoes NOT poll. It returns immediately withpending_approvaland a_next.command. You must separately poll viaretrieve --interval 2 --max-attempts 300(background, notify_on_complete). The previous skill text that said it "polls until they approve or deny" was wrong.- One-time cards expire ~90 seconds after approval. The window between the user approving in the Link app and you retrieving the card is very short. If the card expires, you must recreate the entire spend request and get a new approval. To avoid this: (a) use the combined poll+retrieve pattern in Section 5 so there's no gap, or (b) if you polled separately, retrieve the card immediately after seeing
status: "approved"— do not do any other work in between. retrieverequires explicit options or it errors withterminated. Even though the schema shows defaults, omitting--timeout,--interval,--max-attempts,--force, or--includecan fail. Always pass all five. See Section 5 for exact flags.- Token refresh failures during retrieval. If
retrievefails withToken refresh failed (400), you need to re-auth (auth login --interval 5 --timeout 300) and retry. But the card may expire during re-auth — which means recreating the spend request. This is why the combined poll+retrieve pattern is strongly preferred: it retrieves the card as part of the same process that detects approval, so no token refresh gap exists. - Card PAN must never enter agent context. Use
--output-fileevery time. If you've already retrieved without it, immediatelylink-cli auth logoutis not enough — the card is one-time-use but rotate hygiene matters. --request-approvalblocks until the user acts. If the user is asleep, the CLI will hit its timeout. Set expectations.- Multi-step
_nextcommands. Some commands return_next.commandthat must be executed to continue. When in doubt, prefer the inline-polling flags (--interval/--timeout). - Output format defaults to
toonin non-TTY mode. Fine for prose, but if a downstream step needs to parse a specific field, pass--format json. - Don't default to
card. The merchant-evaluation step (Section 2) exists because picking the wrong credential type fails the purchase silently or leaks more data than needed. spend-request listonly shows active requests by default. Use--include-historyto see expired/denied/terminal-state requests. Useful for debugging.
Verification
link-cli --version && link-cli auth status
Exit code 0 means installed and logged in.
Reference
references/error-fixes.md— Session-verified error→fix log with exact commands: context ≥100 chars,terminatederror, token refresh failure, card expiry, and the full correct end-to-end sequence.
| 1 | |
| 2 | name stripe-link-cli |
| 3 | description "Agent-initiated spend via Stripe Link — requests purchases, issues virtual cards, owner approves in the Link mobile/web app. Hermes cannot self-approve. The 'spend' rail to complement stripe-payments." |
| 4 | version "1.0.0" |
| 5 | author Hermes Agent |
| 6 | license MIT |
| 7 | platforms [linux, macos] |
| 8 | metadata |
| 9 | hermes |
| 10 | tags [stripe, link, payments, agent-spend, small-business] |
| 11 | related_skills [stripe-payments, lead-to-payment] |
| 12 | |
| 13 | |
| 14 | # Stripe Link CLI Skill |
| 15 | |
| 16 | Wraps [@stripe/link-cli] so Hermes can complete purchases on the user's behalf using one-time-use virtual cards or Shared Payment Tokens (SPT). Every spend is gated by an in-app approval in the Link mobile/web app — Hermes cannot self-approve. |
| 17 | |
| 18 | US-only at the moment (Link account requirement). Windows is not supported by the upstream CLI — this skill is gated `[linux, macos]`. |
| 19 | |
| 20 | ## When to Use |
| 21 | |
| 22 | Trigger phrases: |
| 23 | |
| 24 | "buy X", "pay for X", "make a purchase", "complete checkout" |
| 25 | "get me a card", "I need a payment method" |
| 26 | "log in to Link", "connect my Link wallet" |
| 27 | HTTP 402 response from a merchant API with `www-authenticate: ... method="stripe"` |
| 28 | |
| 29 | If the user wants a paid API call (HTTP 402, no checkout form), the `card` path is wrong — use SPT via this same skill, or hand off to the `mpp-agent` skill. |
| 30 | |
| 31 | ## Prerequisites |
| 32 | |
| 33 | Node.js 20+ available on `PATH` (`node --version`) |
| 34 | US-based (Link account requirement) |
| 35 | |
| 36 | The Link account, payment method, and spend-approval app do NOT need to be set up before Hermes attempts to pay — the CLI walks the user through them on first run: |
| 37 | |
| 38 | A Link account at https://app.link.com — created/linked during first `link-cli` auth |
| 39 | At least one payment method — added during first run at https://app.link.com/wallet |
| 40 | The Link mobile/web app — opened to approve the first spend request when it's made |
| 41 | |
| 42 | No env vars required — auth state is stored locally by the CLI under its own config directory. |
| 43 | |
| 44 | ## Install |
| 45 | |
| 46 | Install once, globally: |
| 47 | |
| 48 | |
| 49 | npm install -g @stripe/link-cli |
| 50 | |
| 51 | |
| 52 | Or invoke ad-hoc via `npx @stripe/link-cli`. The skill below uses the installed `link-cli` form. |
| 53 | |
| 54 | ## How to Run |
| 55 | |
| 56 | All commands run through the `terminal` tool. The CLI auto-detects non-TTY callers and emits compact `toon` output by default — fine for the model. Pass `--format json` if a step needs structured fields. |
| 57 | |
| 58 | Discover commands: `link-cli --llms-full`. |
| 59 | Get a command's schema before invoking: `link-cli <command> --schema`. |
| 60 | |
| 61 | ## Procedure |
| 62 | |
| 63 | ### 1. Check / establish auth |
| 64 | |
| 65 | |
| 66 | link-cli auth status |
| 67 | |
| 68 | |
| 69 | If not authenticated, log in with a clear client name (this label shows in the user's Link app): |
| 70 | |
| 71 | |
| 72 | link-cli auth login --client-name "Hermes" --interval 5 --timeout 300 |
| 73 | |
| 74 | |
| 75 | The `--interval`/`--timeout` form polls inline so the agent doesn't need to manage a `_next` step. Print the verification URL + phrase to the user and wait for the CLI to return. |
| 76 | |
| 77 | **Background-polling pattern (when not using inline flags):** If you run `auth login` without `--interval`/`--timeout` (or with `pty=true`), it returns immediately with a `verification_url`, `phrase`, and a `_next.command` like `auth status --interval 5 --max-attempts 60`. Start that poll as a **background terminal process** with `notify_on_complete=true` so you get notified when the user approves: |
| 78 | |
| 79 | |
| 80 | link-cli auth status --interval 5 --max-attempts 60 |
| 81 | # → run with: background=true, notify_on_complete=true, timeout=330 |
| 82 | |
| 83 | |
| 84 | Print the verification URL and phrase to the user immediately — don't wait for them to ask. The background poll will notify you when auth succeeds. |
| 85 | |
| 86 | **Do not proceed past this step until `auth status` confirms login.** |
| 87 | |
| 88 | ### 2. Evaluate the merchant before creating a spend request |
| 89 | |
| 90 | Decide the credential type: |
| 91 | |
| 92 | | Merchant surface | `--credential-type` | |
| 93 | |---|---| |
| 94 | | Standard web checkout form / Stripe Elements | `card` (default) | |
| 95 | | Returns HTTP 402 with `method="stripe"` in `www-authenticate` | `shared_payment_token` | |
| 96 | | Returns HTTP 402 without `method="stripe"` | unsupported — stop | |
| 97 | |
| 98 | For 402 responses, do NOT decode the challenge manually. Pass the raw header: |
| 99 | |
| 100 | |
| 101 | link-cli mpp decode --challenge '<full WWW-Authenticate header>' |
| 102 | |
| 103 | |
| 104 | This validates the challenge and extracts the network ID + decoded request body. |
| 105 | |
| 106 | ### 3. List payment methods + shipping |
| 107 | |
| 108 | |
| 109 | link-cli payment-methods list |
| 110 | link-cli shipping-address list |
| 111 | |
| 112 | |
| 113 | Use the first entry unless the user specifies otherwise. The `id` from `payment-methods list` is the `--payment-method-id` in the next step. |
| 114 | |
| 115 | ### 4. Create the spend request |
| 116 | |
| 117 | Confirm the final total with the user before issuing this command. Amounts are in cents. |
| 118 | |
| 119 | |
| 120 | link-cli spend-request create \ |
| 121 | --payment-method-id <pm_id> \ |
| 122 | --merchant-name "<name>" \ |
| 123 | --merchant-url "<url>" \ |
| 124 | --context "<what is being purchased and why — MUST be ≥100 characters or the CLI returns VALIDATION_ERROR too_small>" \ |
| 125 | --amount <cents> \ |
| 126 | --line-item "name:<item>,unit_amount:<cents>,quantity:1" \ |
| 127 | --total "type:total,display_text:Total,amount:<cents>" \ |
| 128 | --request-approval |
| 129 | |
| 130 | |
| 131 | For MPP merchants add `--credential-type shared_payment_token`. |
| 132 | |
| 133 | `--request-approval` sends the approval push notification to the user's Link app and returns immediately with `status: "pending_approval"`. It does **NOT** poll — the response includes a `_next.command` (`spend-request retrieve <id> --interval 2 --max-attempts 300`) that you must run separately to poll for approval. |
| 134 | |
| 135 | **Best pattern:** After `create --request-approval` returns, immediately start a **background** `retrieve` call that combines polling + card retrieval in one shot (see Section 5). This eliminates the gap between approval and retrieval that causes card expiry. |
| 136 | |
| 137 | ### 5. Retrieve the credential — SECURELY |
| 138 | |
| 139 | **Do not print card details to stdout.** Use `--output-file` so the PAN never enters the agent's transcript or logs. |
| 140 | |
| 141 | **All five options are required by the schema** even though they appear to have defaults — omitting any of `--timeout`, `--interval`, `--max-attempts`, `--force`, or `--include` can cause a `terminated` error. Always pass all five explicitly: |
| 142 | |
| 143 | **Combined poll + retrieve (preferred):** Combines approval polling and card retrieval in one background call. Run this immediately after `create --request-approval` returns — it polls until the user approves, then retrieves the card in the same process, eliminating the approval-to-retrieval gap: |
| 144 | |
| 145 | |
| 146 | link-cli spend-request retrieve <lsrq_id> \ |
| 147 | --include card \ |
| 148 | --output-file /tmp/link-card.json \ |
| 149 | --timeout 600 \ |
| 150 | --interval 2 \ |
| 151 | --max-attempts 0 \ |
| 152 | --force \ |
| 153 | --format json |
| 154 | # → run with: background=true, notify_on_complete=true, timeout=660 |
| 155 | |
| 156 | |
| 157 | **Post-approval retrieve (only when poll already confirmed approval):** If you already polled separately (e.g. via a background process) and confirmed `status: "approved"`, retrieve the card with zero interval: |
| 158 | |
| 159 | |
| 160 | link-cli spend-request retrieve <lsrq_id> \ |
| 161 | --include card \ |
| 162 | --output-file /tmp/link-card.json \ |
| 163 | --timeout 30 \ |
| 164 | --interval 0 \ |
| 165 | --max-attempts 0 \ |
| 166 | --force \ |
| 167 | --format json |
| 168 | |
| 169 | |
| 170 | The file is written with `0600` perms; stdout shows only redacted fields (brand, last4, expiry) plus a `card_output_file` path. |
| 171 | |
| 172 | ### 6. Use the credential |
| 173 | |
| 174 | For web checkout: hand the file path to the user, OR pass it to a browser-driving tool that fills the form directly from disk. Never `read_file` or `cat` the card file into the agent's reasoning context. |
| 175 | For MPP merchants: |
| 176 | |
| 177 | |
| 178 | link-cli mpp pay <merchant-url> \ |
| 179 | --spend-request-id <lsrq_id> \ |
| 180 | --method POST \ |
| 181 | --data '<json body>' |
| 182 | |
| 183 | |
| 184 | ### 7. Clean up |
| 185 | |
| 186 | Delete the card file as soon as the purchase is done: |
| 187 | |
| 188 | |
| 189 | rm -f /tmp/link-card.json |
| 190 | |
| 191 | |
| 192 | ## Optional: run as an MCP server instead |
| 193 | |
| 194 | `@stripe/link-cli --mcp` exposes the same commands as MCP tools over stdio. To register it with Hermes' native MCP: |
| 195 | |
| 196 | |
| 197 | hermes mcp add stripe-link --command "npx" --args "@stripe/link-cli --mcp" |
| 198 | |
| 199 | |
| 200 | Then `hermes mcp list` should show `stripe-link`. The same approval rules apply — MCP doesn't bypass the Link app approval step. |
| 201 | |
| 202 | ## Pitfalls |
| 203 | |
| 204 | **US-only.** Outside the US, `auth login` will fail. Tell the user, don't keep retrying. |
| 205 | **`--context` must be ≥100 characters.** The CLI returns `VALIDATION_ERROR / too_small` if shorter. Write a detailed context string (what, why, who) — not a one-liner. |
| 206 | **`--request-approval` does NOT poll.** It returns immediately with `pending_approval` and a `_next.command`. You must separately poll via `retrieve --interval 2 --max-attempts 300` (background, notify_on_complete). The previous skill text that said it "polls until they approve or deny" was wrong. |
| 207 | **One-time cards expire ~90 seconds after approval.** The window between the user approving in the Link app and you retrieving the card is very short. If the card expires, you must recreate the entire spend request and get a new approval. To avoid this: (a) use the **combined poll+retrieve** pattern in Section 5 so there's no gap, or (b) if you polled separately, retrieve the card immediately after seeing `status: "approved"` — do not do any other work in between. |
| 208 | **`retrieve` requires explicit options or it errors with `terminated`.** Even though the schema shows defaults, omitting `--timeout`, `--interval`, `--max-attempts`, `--force`, or `--include` can fail. Always pass all five. See Section 5 for exact flags. |
| 209 | **Token refresh failures during retrieval.** If `retrieve` fails with `Token refresh failed (400)`, you need to re-auth (`auth login --interval 5 --timeout 300`) and retry. But the card may expire during re-auth — which means recreating the spend request. This is why the combined poll+retrieve pattern is strongly preferred: it retrieves the card as part of the same process that detects approval, so no token refresh gap exists. |
| 210 | **Card PAN must never enter agent context.** Use `--output-file` every time. If you've already retrieved without it, immediately `link-cli auth logout` is not enough — the card is one-time-use but rotate hygiene matters. |
| 211 | **`--request-approval` blocks until the user acts.** If the user is asleep, the CLI will hit its timeout. Set expectations. |
| 212 | **Multi-step `_next` commands.** Some commands return `_next.command` that must be executed to continue. When in doubt, prefer the inline-polling flags (`--interval`/`--timeout`). |
| 213 | **Output format defaults to `toon`** in non-TTY mode. Fine for prose, but if a downstream step needs to parse a specific field, pass `--format json`. |
| 214 | **Don't default to `card`.** The merchant-evaluation step (Section 2) exists because picking the wrong credential type fails the purchase silently or leaks more data than needed. |
| 215 | **`spend-request list` only shows active requests by default.** Use `--include-history` to see expired/denied/terminal-state requests. Useful for debugging. |
| 216 | |
| 217 | ## Verification |
| 218 | |
| 219 | |
| 220 | link-cli --version && link-cli auth status |
| 221 | |
| 222 | |
| 223 | Exit code 0 means installed and logged in. |
| 224 | |
| 225 | ## Reference |
| 226 | |
| 227 | `references/error-fixes.md` — Session-verified error→fix log with exact commands: context ≥100 chars, `terminated` error, token refresh failure, card expiry, and the full correct end-to-end sequence. |
| 228 |
Discussion
Browse more free Claude skills.