/spree:spree-projectfrom spree
Orients developers in Spree Commerce 6 projects: detects project flavor (create-spree-app vs classic Rails), runs commands via spree CLI or native Rails, and explains Spree conventions (namespacing, scoping, custom fields).
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 6 is a headless commerce platform. The backend runs in Docker, from the prebuilt ghcr.io/spree/spree image, and serves the Store, Admin and Seller REST APIs. On top sit TypeScript apps you own: a React admin dashboard and a Next.js storefront, built on typed SDKs. Customization happens around the engine — configuration, hooks, events, providers — not by forking it.
server/).spree-mcp), spree api calls the Admin API from the terminal (spree-cli), and the docs ship with the project (below).spree-marketplace, spree-b2b).Spree 6 differs greatly from Spree 4 and 5. Those were full-stack Rails applications; the Rails admin (
spree_admin), the Rails storefront, API v2 and state machines are gone, and most older code and tutorials do not work. For what changed, read https://spreecommerce.org/docs/developer/upgrades/spree-6-vs-older-versions.md. To upgrade a 5.x project, use thespree-upgrade-5-to-6skill.
| Signal | Flavor | How commands run |
|---|---|---|
server/Gemfile (or legacy backend/Gemfile) + docker-compose.yml + package.json with @spree/cli | create-spree-app project | spree <cmd> — the CLI routes into the Docker web container |
Rails app at the repo root (config/application.rb, Gemfile with spree gems), no server/ | classic Rails app | Native from the app root: bin/rails …, bundle exec rake … |
If spree isn't on PATH, use pnpm exec spree … or npx @spree/cli …. Never run npx spree …: outside a project that has @spree/cli installed, npx downloads the unrelated spree package from npm. The CLI accepts both server/ and the older backend/ directory name.
| Task | Spree CLI | Classic Rails app |
|---|---|---|
| Run the stack | spree dev | bin/dev or bin/rails server |
| Rails console | spree console | bin/rails console |
| Shell in the container | spree shell | (you're already in one) |
| Install + run migrations | spree migrate | bin/rails spree:install:migrations && bin/rails db:migrate |
| Generator | spree generate api_resource Brand … (bare names auto-prefix spree:) | bin/rails g spree:api_resource Brand … |
| Run specs | spree test spec/models/… (RAILS_ENV=test) | bundle exec rspec spec/models/… |
| Rake task | spree task <name> for Spree tasks (the CLI adds spree:, so leave it off); spree exec bin/rake <task> for any other | bundle exec rake <task> |
| Sample data | spree sample-data (default store; another store: spree task load_sample_data STORE_CODE=eu) | bin/rails spree:load_sample_data (STORE_ID=store_… or STORE_CODE=… to target a non-default store) |
| Version upgrade | spree upgrade | bundle update spree…, migrate, bin/rails spree:upgrade |
| Anything else | spree exec <cmd> | <cmd> |
Paths written server/app/... in these skills mean app/... in a classic app.
my-store/
├── server/ # The Spree API — a full Rails 8.1 app (spree-starter). Your Ruby code lives here.
│ ├── app/{models,services,workflows,subscribers,controllers,serializers}/
│ ├── config/initializers/spree.rb # hooks, registries, dependencies, subscribers
│ ├── Dockerfile # builds the production image (API + dashboard)
│ └── Gemfile
├── apps/
│ ├── dashboard/ # React admin (@spree/dashboard) — plugins in src/plugins.ts
│ ├── seller-dashboard/ # Marketplace seller panel (optional)
│ └── storefront/ # Next.js storefront on @spree/sdk (optional)
├── docker-compose.yml # prebuilt ghcr.io/spree/spree image + Postgres (Meilisearch optional, commented out)
├── .env # SECRET_KEY_BASE, ACTIVE_RECORD_ENCRYPTION_* keys, SPREE_PORT, SPREE_VERSION_TAG… (mode 0600)
├── AGENTS.md / CLAUDE.md # generated agent instructions
└── package.json # pins @spree/cli
server/ is the only part that is Spree's. The apps are ordinary Vite/Next.js projects you own.spree eject once — compose then builds from server/. If eject fails on a fresh stack with service "web" is not running, the dev server exited because its database didn't exist yet. @spree/cli 3.1.0 has this bug. Releases after it build the dev image, start and wait for Postgres, and prepare the database in a one-off container before starting the stack (also on spree init of an ejected project), and they switch older dev compose files to a pg_isready -h 127.0.0.1 health check. Bump @spree/cli in package.json and re-run./jobs), Solid Cache; Sidekiq/Redis is optional. The dashboard is served at /dashboard by the spree_dashboard gem in production (one image, same origin)./api/v3/store (publishable key pk_…), Admin /api/v3/admin (secret key sk_… or staff JWT), Seller /api/v3/seller (seller JWT + X-Spree-Seller-Id). See spree-api-v3.Spree::, files under server/app/models/spree/… etc. Your own non-Spree classes can use your app namespace (MyApp::…).Spree.base_class (defaults to Spree::Base), not ApplicationRecord. It brings preferences, prefixed IDs, ransack allowlists, document numbers, additional_permitted_attributes.Spree.customer_class (default Spree::Customer, table spree_customers, cust_…) and Spree.admin_user_class (Spree::AdminUser, adm_…). Never hardcode either. Spree.user_class is a deprecated alias.current_store.products, store.orders — never Spree::Order.all in request code. In dev/test SPREE_STORE_SCOPE_GUARD=log|raise|off flags unscoped queries.Spree::Current carries per-request store, channel, market, currency, locale. Spree::Current.store falls back to Spree::Store.default, which can be nil (no store flagged default) — set Spree::Current.store = store explicitly in jobs, rake tasks and specs. Assigning it also arms the dev/test StoreScopeGuard for the rest of that job/script, so unscoped queries there get flagged too (wrap deliberately global lookups in Spree::StoreScopeGuard.skip { … }). An installation-wide job (a nightly sweep over every store's records) must run each record in its own store, or its emails, events and store settings come from the default store. Use Spree::Current.with_store(store) { … }, which starts from a clean context and restores the previous one afterwards. Jobs subclassing Spree::BaseJob can call the private each_store_of(relation) { |store_records| … }, which core's own sweeps (stale drafts, expired carts, time-based collections, payouts) use.status columns declared with has_status (Spree::HasStatus); transitions are workflows (app/workflows). Extend with Model.add_status('on_hold', after: 'approved') — plus your own workflow to move records into it. See spree-workflows.belongs_to is required by default — pass optional: true when the FK may be nil, or saves fail with "… must exist". Always pass class_name: and an explicit dependent: on has_many.prod_…, cart_…, or_…, py_…). Look up with Model.find_by_prefix_id!(id); never .to_i an ID and never expose integer IDs. Full table: spree-data-model.Spree::Cart is mutable checkout state; completing it creates an immutable Spree::Order (status draft/placed/canceled). Code that runs on both reads line_item.owner, not .order.product.set_custom_field('custom.material', 'Cotton'), get_custom_field). Machine/integration data → metadata (schemaless JSON, write-only in Store API). A new column only when your own code queries it heavily.Spree::Subscriber (order.placed, …); run inside a flow with Spree.hooks.register('carts.complete.validate', …). Don't add after_save to Spree models.Spree::Product.additional_permitted_attributes += [:brand_id] — +=, never << (the default is frozen).result = Spree.cart_add_item_workflow.call(...); check result.success?."135.60") with a display_… twin — render the display one.SPREE_* env vars (see spree-customization). Active Record encryption keys (ACTIVE_RECORD_ENCRYPTION_*) must be set in every environment — create-spree-app generates a dev set; spree encryption init adds one to older projects (see spree-security).Walk this list top-down — higher options are cheaper and survive upgrades better. The spree-customization skill has the full decision table.
SPREE_* env vars / Spree.config; per-record preferences.Spree.hooks.register('<flow>.<hook>', 'MyApp::Handler') to veto or extend a core flow (spree-workflows).spree-events-webhooks).Spree::Checkout::Registry.add_requirement / register_step (spree-checkout).spree-providers).Spree.ransack.add_attribute(Spree::Product, :erp_id).Spree::Dependencies.cart_add_item_workflow = 'MyApp::Carts::AddItem' (spree-dependencies).spree-decorators).Admin UI changes happen in the React dashboard via plugins (spree-dashboard, spree-dashboard-plugins), not in Rails views.
spree dev # run API (+ dashboard dev server if apps/dashboard exists); first run completes setup
spree stop | restart | logs [worker]
spree console | shell | db:console
spree migrate | migrate:status | migrate:rollback
spree generate api_resource Brand name:string # → spree:api_resource
spree generate subscriber ErpSync order.placed # class + registration in initializers/spree.rb
spree test [path[:line]] # tests in RAILS_ENV=test; creates the test DB if missing (CLI 3.6+; older: spree rspec)
spree add --gem <gem> # adds the gem, runs its installer + migrations; a prebuilt project is ejected first (asks; new dev DB)
spree eject # build from server/ instead of the prebuilt image
spree build [--production] # rebuild dev image / build the production image (API + dashboard)
spree add dashboard # add apps/dashboard (also: spree add seller-dashboard)
spree plugin new <name> # scaffold a dashboard plugin monorepo
spree update # pull latest image, recreate containers (migrations run on boot)
spree upgrade [--plan] # bundle update + migrate + spree:upgrade data steps
spree seed | sample-data | user create | api-key create|list|revoke
spree encryption init [--print] # add ACTIVE_RECORD_ENCRYPTION_* keys to .env (never overwrites); --print for production
spree exec bin/rails spree:setup:token # reprint the first-run admin setup link
spree api <verb> <path> # call the Admin API from the terminal (see spree-cli)
spree db:reset is destructive — confirm with the user before running it.
Read the installed docs before guessing from training data — they match the installed version:
node_modules/@spree/docs/dist/
├── developer/
│ ├── getting-started/ create-spree-app/ cli/
│ ├── core-concepts/ # products, carts, orders, payments, fulfillments, markets, …
│ ├── customization/ # quickstart, configuration, workflows, dependencies, decorators, permissions, validations
│ ├── providers/ # ERP, PIM, DAM, fulfillment, payouts, SSO, observability
│ ├── how-to/ # custom payment method, delivery rate provider, search provider, B2B, marketplace…
│ ├── dashboard/ # React admin: customization, plugins, recipes
│ ├── sdk/ storefront/ multi-tenant/ security/ deployment/ upgrades/ tutorial/
└── api-reference/ # Store/Admin API guides + OpenAPI specs
.md to any docs URL.dist/developer/upgrades/spree-6-vs-older-versions.md, when the installed docs have it).https://spreecommerce.org/docs/mcp) searches the latest published docs: claude mcp add --transport http spree-docs https://spreecommerce.org/docs/mcp.docs/v5/ pages for a Spree 6 project.spree-customizationspree-data-modelspree-resourcespree-workflowsspree-testing. Upgrading? → spree-upgrade / spree-upgrade-5-to-6.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.Other plugins' skills for the same job