Skip to main content
The Spree CLI (@spree/cli) does two things from your terminal:
  1. Manages your Spree project — boot the Docker stack, run generators and migrations, tail logs, open a console, upgrade versions.
  2. Calls the Admin API — generic get/post/patch/delete commands to read, write, and explore your store’s data, with zero-config credentials in local dev. See Admin API from the CLI.
The 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 with create-spree-app. You can also install it globally:
Then run commands from your project directory:
Or use 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.
Not appropriate for Gemfile changes (use 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.
Production upgrades only need the third stage — 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.
After ejecting, the Docker image is built from 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 shell

Open an interactive bash shell inside the web container — the system-shell sibling of spree console (Rails) and spree db:console (psql). If the web container is down, it starts a one-off container against the same volumes instead. For one-off non-interactive commands, use spree exec.

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 through docker 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.

spree rspec

Run the RSpec test suite inside the web container with RAILS_ENV=test, so tests hit the spree_test database — never your development data. Everything after rspec passes through, so file paths, line numbers, and flags work as usual.
Before the first run, create the test database with spree rails db:test:prepare. See the Testing tutorial for writing specs.

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.