/spree:spree-clifrom spree
Calls the Spree 6 Admin API from the terminal for debugging, exploring endpoints, and mutating store data. Includes project dev commands like shell, test, and console.
Ships in spree. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
@spree/cli ships a spree api command group: a generic Admin API v3 client modeled on gh api. It is the fastest way to inspect and manipulate store data from a terminal, and the most reliable way for an agent to debug — no SDK boilerplate, structured JSON in/out, and offline endpoint discovery.
spree api talks to the Admin API only (/api/v3/admin, secret key auth). It can't call the Store or Seller APIs; use curl or the SDKs for those. It works against any Spree 6 instance (and 5.5+). Inside a local project it provisions a read-only key for itself; for any other server you supply a key.
or_x in?", "why did this 403?", "does this product have the variant I expect?". One command, JSON back, pipe to jq.For building an app, prefer @spree/admin-sdk (see spree-typescript-sdk). The CLI is for interactive work, scripts, and agents.
The CLI is @spree/cli (binary: spree). Verify it's available:
spree --version # or: pnpm exec spree --version
If not installed: npm i -g @spree/cli (or run via pnpm exec spree / npx @spree/cli inside a project).
Credentials resolve in this order (first match wins); host and key always resolve together per source:
--api-key sk_xxx, or --profile prod to select a saved profile. Outrank everything below.SPREE_API_KEY; the host defaults to http://localhost:3000, so local dev needs only the key. Set SPREE_BASE_URL for a remote store. Note an exported SPREE_API_KEY outranks a local project's saved key:
SPREE_API_KEY=sk_xxx spree api get /products # → localhost:3000
SPREE_BASE_URL=https://store.example.com SPREE_API_KEY=sk_xxx spree api get /orders
docker-compose.yml, Rails app in server/, or legacy backend/, and the dev stack running): zero config. The first spree api call mints a read-only key via the dev stack and saves it to .spree/credentials.json (gitignored). Just run commands.spree auth login becomes the default; key read from a prompt, never a flag):
spree auth login --profile prod --base-url https://store.example.com
spree api get /orders --profile prod # or omit --profile once it's the default
Confirm what's resolved and that the server is reachable:
spree api status
Auto-minted project keys are read_all only. For writes, create a scoped secret key (in a project):
spree api-key create --type secret --scopes read_orders,write_products
Scopes follow read_<resource> / write_<resource> (write_* implies read_*); read_all / write_all are the catch-alls. spree api endpoints shows the scope each endpoint needs.
# Read — Ransack filters as repeatable -q, plus sort/page/limit/expand/fields
spree api get /products -q status_eq=active -q name_cont=shirt --sort -created_at --limit 10
spree api get /orders/or_x8k2J9aQ --expand items,payments,fulfillments
spree api get /products --fields name,slug,status # id is always returned
# Write — JSON body inline, from @file, or '-' for stdin
spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'
spree api patch /orders/or_x8k2J9aQ/cancel
spree api post /orders/or_x8k2J9aQ/refunds -d @refund.json
cat prices.json | spree api post /prices/bulk_upsert -d -
spree api delete /products/prod_86Rf07xd
/api/v3/admin prefix is optional (paste a full path and it still works).jq). --format table renders collections for humans.Idempotency-Key, so retries are safe.The CLI bundles a snapshot of the Admin API OpenAPI spec:
spree api endpoints --resource orders # every orders endpoint + required scope
spree api endpoints --search "gift card" # fuzzy search across method/path/summary
spree api schema "POST /orders" # full request/response schema for one op
Use endpoints/schema to find the right path and body shape before calling — this is how an agent should orient instead of guessing.
eval "$(spree completion zsh)" # bash and fish also supported
Completes resource paths, Ransack predicate stems (status_eq=, name_cont=…), and scope names.
When a request or app behavior is wrong, the CLI is the fastest probe. A typical loop:
# 1. Reproduce the read and see the actual state
spree api get /orders/or_x8k2J9aQ --expand payments,fulfillments | jq '.status, .payment_status, .fulfillment_status'
# 2. If a write failed, find the endpoint's contract
spree api schema "PATCH /orders/{id}/cancel"
# 3. Re-run the write and read the error envelope verbatim
spree api patch /orders/or_x8k2J9aQ/cancel
Errors print the Stripe-style envelope to stderr and set the exit code:
0 success · 1 API error (4xx/5xx — the {error: {code, message, details}} envelope) · 2 usage/config error (bad flag, no credentials, unreachable host).A scope denial (403, code: access_denied) prints details.required_scope and the exact remediation — mint a key with that scope and pass it via --api-key or SPREE_API_KEY:
access_denied: API key lacks scope: write_products
{ "details": { "required_scope": "write_products" } }
Hint: this key lacks `write_products`. Create one that has it and use it:
spree api-key create --type secret --scopes write_products
then pass it via --api-key <sk_...> or export SPREE_API_KEY=<sk_...>
A validation error (422, code: validation_error) puts per-attribute messages in details — read them to see which fields the body got wrong, then check spree api schema for the correct shape.
spree api status diagnoses the credential/reachability layer when calls fail before reaching the API at all (wrong host, expired/typo'd key).
spree api: project commands for debuggingIn a scaffolded project (Docker dev stack), these commands run inside the web container. In a classic Rails app without Docker, use the native equivalents (bin/rails console, bundle exec rspec, …).
spree console # Rails console: Spree::Cart.find_by_prefix_id!('cart_…')
spree shell # interactive bash in the web container (alias: spree bash)
spree test spec/models/spree/brand_spec.rb:15 # RSpec with RAILS_ENV=test; args pass straight through
spree logs # web logs (spree logs worker for jobs)
spree db:console # psql against the dev database
spree add dashboard # scaffold apps/dashboard (or: spree add seller-dashboard)
spree plugin new brands # scaffold a dashboard plugin repo (the Rails engine half is a separate spree_extension gem)
spree encryption init [--print] # add Active Record encryption keys to .env (never overwrites; --print only prints a set)
spree add mcp # add the Admin MCP server gem (spree_mcp) — see spree-mcp
spree add paypal # add spree_paypal_checkout at the project's Spree version (6.0.3+)
spree task openapi:generate # write server/openapi/admin.yaml from the app's rswag specs — see spree-resource
spree filters types # TypeScript typings for your app's custom list filters, into each app under apps/
spree sdk generate (extension packages)Run it in an npm package that ships a typed client for an extension's endpoints, with "spree": { "extension": "../my_extension" } in its package.json. It doesn't need the dev stack; it runs the gem's own rake spree:openapi:generate spree:sdk:serializer_types, then writes src/generated/<api>/ (client.ts, params/, filters.ts, types/, spree.ts).
spree sdk generate # regenerate after an endpoint or serializer change
spree sdk generate --no-backend # from the committed openapi/*.yaml only
spree sdk generate --check # CI: fail when generated files are stale
See spree-typescript-sdk § Generating an extension's client.
spree shell and spree test still work when the web container is crash-looping: they fall back to a one-off compose run.
spree api can't see/orders, /order_groups) but not in-progress carts. Inspect those in spree console or through the Store API with the cart token.curl with a pk_ key (Store) or the seller SDK.spree api vs the Admin MCP serverspree api uses a secret key and suits scripts and debugging. The Admin MCP server (/api/v3/admin/mcp) is for an AI client acting for a signed-in person through OAuth, and it refuses sk_ keys. See spree-mcp.
endpoints/schema reflects the CLI's Spree version, not necessarily the live server's — spree api status shows the bundled version. If an endpoint is missing from endpoints but exists on the server, the CLI may be older.--api-key on the command line leaks into shell history — prefer SPREE_API_KEY or a profile.spree api-key revoke <id>).--store-id <store_…> (sent as X-Spree-Store-Id).spree dev).What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub spree/agent-skills --plugin spree39 skills in this plugin
/spree-api-v3Use when the user is calling or debugging Spree 6's REST API v3 — the Store API (storefronts, mobile apps, customers), the Admin API (integrations, back-office tools) or the Seller API (marketplace sellers). Covers auth (publishable/secret keys, JWT audiences), scopes and permissions, prefixed IDs, the cart → order split, checkout `requirements[]`, order statuses, the `{data, meta}` envelope, expand/fields, Ransack filters, errors, idempotency, localization headers and rate limits. Common phrasings include "Spree API", "Store API", "Admin API", "publishable key", "secret key", "X-Spree-Api-Key", "X-Spree-Token", "API scopes", "403 required_scope", "cart_ vs or_", "complete cart", "cart 404 after checkout", "prefixed IDs", "expand", "Idempotency-Key", "429 rate limit", "v3 endpoint", "Admin API OpenAPI spec". For ADDING or documenting (OpenAPI) a new endpoint use spree-resource; for AI agents driving the store over MCP use spree-mcp; for roles/permissions internals use spree-auth-permissions./spree-auth-permissionsUse when the user is working on who can sign in to Spree 6 and what they may do — staff roles and permission keys, secret-key scopes, registering permission scopes for an extension, 403 errors with `required_permission` / `required_scope`, storefront ownership rules (`Spree::Storefront::AccessPolicy`), custom login strategies (SSO, OIDC, Auth0/Okta/Entra/Firebase), JWT audiences, or swapping the customer/admin user class. Common phrasings include "Spree roles", "staff permissions", "add a role", "read_orders permission", "Spree.permissions.register_scope", "API key scopes", "403 Missing permission", "who can see this order", "SSO for the dashboard", "OIDC login", "custom authentication strategy", "Spree.customer_class", "admin_user_class", "CanCanCan in Spree 6". Spree 6./spree-b2bUse when building B2B or wholesale commerce on Spree 6 — companies and buyer organizations (company trees, divisions, members, invitations, buying on a company's behalf), catalogs and negotiated pricing (owned price lists, assignment to companies or customer groups), customer groups, gated storefronts (`storefront_access` login_required / prices_hidden), the Next.js wholesale portal, minimum order quantity / order multiples / order minimums, PO numbers, orders on account (pay by invoice, staff-keyed draft orders, `payment_pending`) and freight shipping (cartons, pallets, unpriced freight rates). Common phrasings include "B2B", "wholesale", "build a B2B store", "pay by invoice", "net terms", "draft order for a company", "company account", "Spree::Company", "division", "negotiated prices", "customer-specific pricing", "price list per company", "MOQ", "order multiple", "case pack", "order minimum", "PO number", "login to see prices", "wholesale portal", "X-Spree-Channel", "freight", "pallet"./spree-catalogUse when the user is working with the Spree 6 product catalog — products, variants, option types/values, the default variant, product types (templates), categories vs collections, custom fields, media (images, video, media library), channel publications, search providers (database, spree_meilisearch, custom), digital assets, or catalog imports/exports. Common phrasings include "create a product", "add variants", "size and color options", "product type", "category tree", "collection", "brand", "custom field on products", "product images", "product video", "primary_media", "product not showing in store", "publish product on channel", "Meilisearch", "reindex", "custom search provider", "digital download", "master variant". Covers the catalog graph and how to read/write it from Ruby, the Admin SDK and `spree api`./spree-checkoutUse when the user is working on Spree 6 checkout — the Cart → Order split, checkout requirements and advisory steps, `Spree::Checkout::Registry` (add_requirement / register_step / base_steps), cart completion (`Spree::Carts::Complete`), `carts.complete` / `carts.add_item` workflow hooks, addresses, payment sessions, guest checkout, cart association/merge on login, or the Store API / `@spree/sdk` checkout sequence. Common phrasings include "checkout broken", "cart won't complete", "why can't this cart complete", "add a checkout step", "require a field before checkout", "require terms acceptance", "skip the delivery step", "order stuck", "double charge", "guest checkout", "cart not found after checkout", "merge carts on login", "custom checkout validation", "block checkout if…". Covers where each customization belongs and how completion guarantees idempotency./spree-customizationUse FIRST when a Spree 6 customization is on the table and the right pattern isn't obvious — "how do I customize X", "where should this logic go", "decorator or subscriber?", "hook or event?", "how do I block checkout when…", "add a field to products", "change how tax/shipping/search works", "extend Spree without forking". A decision tree that routes each need to the right extension point (store settings, SPREE_* config, model preferences, workflow hooks, events, webhooks, Checkout::Registry, providers, custom fields vs metadata, validators, permitted attributes, permission scopes, new resources, dependencies, decorators, dashboard plugins) and to the skill that covers it in depth.Other plugins' skills for the same job