@spree/cli) does two things from your terminal:
- Manages your Spree project — boot the Docker stack, run generators and migrations, tail logs, open a console, upgrade versions.
- Calls the Admin API — generic
get/post/patch/deletecommands to read, write, and explore your store’s data, with zero-config credentials in local dev. See Admin API from the CLI.
spree api commands work against any Spree 5.5+ instance and are built for both humans and AI agents — see the dedicated Admin API from the CLI guide. The rest of this page covers project management.
Installation
The CLI is included automatically when you scaffold a project withcreate-spree-app. You can also install it globally:
npx without installing:
Commands
spree init
First-run setup. Starts Docker services, seeds the database, generates an API key, and optionally loads sample data.
spree dev
Run the app in the foreground — streams web + worker logs; Ctrl+C stops them. The databases keep running for a fast next boot (spree stop shuts everything down).
spree stop
Stop all services.
spree restart
Restart web and worker in place — same image, same volumes, fresh Rails process. Good for config/initializers/*.rb changes or anything Zeitwerk doesn’t auto-reload.
spree bundle install, then Ctrl+C and re-run spree dev), Dockerfile / .ruby-version changes (use spree build), or compose file changes (Ctrl+C and re-run spree dev).
spree update
Pull the latest Spree Docker image and recreate containers. Migrations run automatically on startup.
spree build
Rebuild the dev image after Dockerfile or .ruby-version changes. Only relevant after spree eject.
spree bundle add does NOT require a rebuild — gems land in the bundle_cache volume which survives image rebuilds.
--reset-bundle only drops bundle_cache. Postgres, Redis, Meilisearch, and storage volumes are preserved.
spree upgrade
Walk a Spree version upgrade end-to-end inside the dev stack. Runs bundle update, applies pending migrations, then walks the version-specific data backfills from the upgrade manifest.
bundle install and db:migrate happen in your deploy pipeline. The CLI runs all three for local development. See Upgrades for the manual production path.
spree eject
Switch 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.
backend/Dockerfile. Edit files in backend/ and run spree dev to rebuild and restart with your changes.
See Customizing the Backend for details on what you can customize.
spree logs
Stream service logs.
spree console
Open a Rails console.
spree open
Open the admin dashboard in the browser.
spree seed
Seed the database.
spree sample-data
Load sample products, categories, and images.
spree user create
Create an admin user. Prompts for email and password interactively, or pass them as flags:
spree api-key
Manage Store and Admin API keys. Secret keys carry scopes and require at least one.
spree api
Call the Admin API with generic get/post/patch/delete commands — zero-config inside a project (a read-only key is minted on first use), env vars or profiles for remote stores. See Admin API from the CLI for the full guide.
spree auth
Save Admin API credentials for remote stores as named profiles.
Dev workflow commands
These mirror the Rails commands you’d run if you were running the app directly on your host — but each is routed throughdocker compose exec against the running stack.
spree generate
Run a generator inside the container. Bare generator names are auto-prefixed with spree: — model runs spree:model, api_resource runs spree:api_resource — so you get the Spree conventions (Spree:: namespace, spree_-prefixed table, prefixed IDs, null: false, no FK constraints) by default. Rails built-ins (migration, scaffold, mailer, job, …) and any name containing : are forwarded as-is.
spree:api_resource scaffolds the full v3 surface: model, migration, Store + Admin controllers and serializers, factory, controller specs, and routes.
spree migrate
Install pending Spree migrations from gems, then run db:migrate — the canonical post-update sequence.
spree db:reset
Drop, recreate, migrate, and seed the database. Destructive — wipes everything. Asks for confirmation.
spree db:console
Open a psql session against the dev Postgres database (runs inside the postgres container).
spree routes
Show Rails routes. All flags pass through to bin/rails routes.
Running things inside the container
These are passthrough commands — anything after the subcommand reaches the inner Rails/Bundle/Rake invocation as-is. Useful for ad-hoc commands that don’t have a dedicated wrapper.spree exec
Run an arbitrary command inside the web container.
spree rails
Run a bin/rails command.
spree bundle
Run a bundle command. Gems land in the bundle_cache volume (no image rebuild needed).
spree rake
Run a Rake task.
spree task
Shortcut for bin/rails <task> (Spree-style rake tasks registered as Rails tasks).
Pair with AI agents
The CLI’s predictable command surface is what AI coding agents drive when working on Spree projects. The Spree agent skills teach agents these commands and conventions, and the Claude Code plugin adds/spree:doctor (stack diagnosis) and /spree:audit-upgrade (upgrade-readiness audit) on top. See Agentic Development.
