packages/cli/README.md
CLI for managing Spree Commerce projects.
Automatically included in projects created with create-spree-app. Can also be installed standalone.
Already included when you scaffold a project with create-spree-app. To install separately:
npm install @spree/cli
Or run directly with npx:
npx @spree/cli <command>
Or install globally:
npm install -g @spree/cli
spree <command>
Run these from your Spree project directory.
spree devRun the app in the foreground — prints connection info, then streams web + worker logs (like vite dev).
spree dev
Press Ctrl+C to stop web + worker. The databases (postgres, redis, meilisearch) keep running for a fast next boot — spree stop shuts everything down.
spree stopStop all running services.
spree stop
spree updatePull the latest Spree Docker image and recreate containers. Database migrations run automatically on startup via db:prepare.
spree update
To pin a specific version, edit SPREE_VERSION_TAG in your .env file:
SPREE_VERSION_TAG=5.4
spree ejectSwitch from the prebuilt Docker image to building from your local backend/ directory. This lets you customize the Rails app — add gems, override models, add migrations, etc.
spree eject
After ejecting, edit files in backend/ and run spree dev to rebuild and restart.
spree logs [service]Stream logs from a service. Defaults to web.
spree logs # web server logs
spree logs worker # background job logs
spree consoleOpen an interactive Rails console inside the running container.
spree console
spree user createCreate an admin user. Prompts interactively for email and password, or accepts flags for scripting.
# Interactive
spree user create
# Non-interactive
spree user create --email [email protected] --password secret123
The user is automatically assigned the admin role on the default store.
spree api-key createCreate a Store API (publishable) or Admin API (secret) key. Prompts interactively for name and type, or accepts flags.
# Interactive
spree api-key create
# Non-interactive
spree api-key create --name "My Storefront" --type publishable
spree api-key create --name "Admin Integration" --type secret --scopes read_orders,write_products
Secret keys require at least one scope (read_all for a read-only key, write_all for full access, or granular read_*/write_* pairs).
Important: Secret key tokens are displayed only once at creation time and cannot be retrieved later. Save them immediately.
spree api-key listList all API keys for the default store with their name, type, token/prefix, creation date, and status.
spree api-key list
spree api-key revokeRevoke an API key by its token (publishable) or token prefix (secret).
spree api-key revoke pk_abc123def456...
spree apiCall the Admin API directly with generic get/post/patch/delete commands. Works against any Spree 5.5+ instance — inside a project it self-provisions a read-only key via the dev stack on first use (saved to .spree/credentials.json, gitignored). For other servers set SPREE_API_KEY (the host defaults to http://localhost:3000; add SPREE_BASE_URL for a remote store) or save a profile with spree auth login.
spree api get /products -q status_eq=active --sort -created_at --limit 10
spree api get /orders/ord_x8k2J9aQ --expand items,payments
spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'
spree api patch /orders/ord_x8k2J9aQ/cancel
spree api delete /products/prod_86Rf07xd
spree api endpoints --resource orders # endpoints + required scopes (offline)
spree api schema "POST /orders" # request/response schema (offline)
spree api status # resolved credentials + server check
Output is JSON on stdout — indented and colored in a terminal, compact and uncolored when piped (so it feeds cleanly into jq). --format table renders collections for humans. --fields name,price trims the response (the id is always included). API errors exit 1 with the error envelope on stderr — scope denials include the exact --scopes remediation.
spree completionOutput a shell completion script (bash, zsh, or fish). Tab-completion suggests resource paths, Ransack predicate stems, and scope names — offline from the bundled spec.
eval "$(spree completion zsh)" # add to ~/.zshrc (bash/fish also supported)
spree authManage saved Admin API credentials for remote stores (profiles in ~/.config/spree/config.json).
spree auth login --profile prod --base-url https://store.example.com # key read from a prompt
spree api get /orders --profile prod
spree auth status
spree auth list
spree auth logout --profile prod
spree seedRun database seeds.
spree seed
spree sample-dataLoad sample products, categories, customers, and images.
spree sample-data
The CLI detects your project by looking for docker-compose.yml in the current directory. All commands execute via docker compose against the running Spree containers.
SPREE_PORT in your .env file (default: 3000)docker compose exec web bin/rails runnerdev, stop, update) are thin wrappers around docker composeProjects created with create-spree-app include convenience scripts in package.json:
npm run dev # spree dev
npm run stop # spree stop
npm run update # spree update
npm run eject # spree eject
npm run logs # spree logs
npm run logs:worker # spree logs worker
npm run console # spree console
npm run seed # spree seed
npm run load-sample-data # spree sample-data
MIT