> ## Documentation Index
> Fetch the complete documentation index at: https://spreecommerce.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Spree CLI

> Manage your Spree Commerce project from the command line.

The Spree CLI (`@spree/cli`) manages Docker-based Spree projects created with [create-spree-app](/developer/create-spree-app/quickstart).

## Installation

The CLI is included automatically when you scaffold a project with `create-spree-app`. You can also install it globally:

```bash theme={"theme":"night-owl"}
npm install -g @spree/cli
```

Then run commands from your project directory:

```bash theme={"theme":"night-owl"}
spree dev
```

Or use `npx` without installing:

```bash theme={"theme":"night-owl"}
npx @spree/cli dev
```

## Commands

### `spree init`

First-run setup. Starts Docker services, seeds the database, generates an API key, and optionally loads sample data.

```bash theme={"theme":"night-owl"}
spree init
spree init --no-sample-data   # Skip sample data
spree init --no-open           # Skip opening browser
```

### `spree dev`

Start services and stream logs.

```bash theme={"theme":"night-owl"}
spree dev
```

### `spree stop`

Stop all services.

```bash theme={"theme":"night-owl"}
spree stop
```

### `spree update`

Pull the latest Spree Docker image and recreate containers. Migrations run automatically on startup.

```bash theme={"theme":"night-owl"}
spree update
```

### `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.

```bash theme={"theme":"night-owl"}
spree eject
```

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](/developer/create-spree-app/quickstart#customizing-the-backend) for details on what you can customize.

### `spree logs`

Stream service logs.

```bash theme={"theme":"night-owl"}
spree logs         # Web service (default)
spree logs worker  # Worker service
```

### `spree console`

Open a Rails console.

```bash theme={"theme":"night-owl"}
spree console
```

### `spree open`

Open the admin dashboard in the browser.

```bash theme={"theme":"night-owl"}
spree open
```

### `spree seed`

Seed the database.

```bash theme={"theme":"night-owl"}
spree seed
```

### `spree sample-data`

Load sample products, categories, and images.

```bash theme={"theme":"night-owl"}
spree sample-data
```

### `spree user create`

Create an admin user. Prompts for email and password interactively, or pass them as flags:

```bash theme={"theme":"night-owl"}
spree user create
spree user create --email admin@example.com --password secret123
```

### `spree api-key`

Manage Store and Admin API keys.

```bash theme={"theme":"night-owl"}
spree api-key list                                     # List all keys
spree api-key create                                   # Interactive
spree api-key create --name "Storefront" --type publishable  # Store API key
spree api-key create --name "Admin" --type secret            # Admin API key
spree api-key revoke <id>                              # Revoke a key
```
