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

# CLI

The `copper` CLI scaffolds projects, builds binaries, runs your app with hot reload, and manages database migrations. Run `copper help` to see all commands.

### copper create

```
copper create [-frontend=] [-storage=] github.com/user/myapp
```

Creates a new project in `./myapp` (the last segment of the module path).

| Flag        | Default         | Options                                |
| ----------- | --------------- | -------------------------------------- |
| `-frontend` | `inertia:react` | `inertia:react`, `none`                |
| `-storage`  | `postgres`      | `postgres`, `sqlite3`, `mysql`, `none` |

With the default stack you get a React + Inertia + Vite frontend and a Postgres-backed data layer with migrations. `-frontend=none` creates a JSON API server; `-storage=none` skips the database entirely.

### copper run

```
copper run [target] [-migrate] [-web] [-watch]
```

Builds and runs a target from `cmd/`, defaulting to `app`. On the first run, it also runs database migrations and starts the Vite dev server.

| Flag       | Default                             | Description                              |
| ---------- | ----------------------------------- | ---------------------------------------- |
| `-migrate` | `true`                              | Run database migrations before starting  |
| `-web`     | `true` for `app`, `false` otherwise | Start the frontend dev server in `./web` |
| `-watch`   | `false`                             | Rebuild and restart on source changes    |

<Note>
  `-migrate` only exists in projects with a `cmd/migrate` target, and `-web` only in projects with a `web/` frontend.
</Note>

With `-watch`, Copper watches `.go` files under `pkg/` (and `web/wire.go`), debounces changes, then rebuilds and restarts the target, sending desktop notifications on build success and failure.

```
copper run              # runs app with migrations and web
copper run jobs         # runs the jobs target (no web by default)
copper run app -web=false
```

### copper build

```
copper build [--only=<targets>]
```

Builds every binary under `cmd/` into `./build/<target>.out`. If the project has a frontend, it copies the static assets from `web/public` and embeds the frontend's production build output (`web/build`) into the binary. Note that you should run the frontend build itself (`npm run build` in `web/`) beforehand. You may use `--only` to build specific targets:

```
copper build --only=app,migrate
```

### copper migrate

```
copper migrate [-direction=up|down]
```

Builds the `migrate` target and runs database migrations.

| Flag         | Default | Description                                                                |
| ------------ | ------- | -------------------------------------------------------------------------- |
| `-direction` | `up`    | `up` applies all pending migrations; `down` rolls back the most recent one |

### copper scaffold:pkg

```
copper scaffold:pkg rockets
```

Creates a new feature package:

* `pkg/rockets/wire.go` — the package's `WireModule`
* `pkg/rockets/models.go` — a home for your models

It also registers `rockets.WireModule` in `pkg/app/wire.go`.

### copper scaffold:queries

```
copper scaffold:queries rockets
```

Creates `pkg/rockets/queries.go` with a `Queries` struct wrapping `csql.Querier`, and adds `NewQueries` to the package's wire module. Run `scaffold:pkg` first if the package doesn't exist yet.

### copper scaffold:router

```
copper scaffold:router rockets
```

Creates `pkg/rockets/router.go` with an empty router, adds `NewRouter` to the package's wire module, and registers the router in `pkg/app/handler.go` so its routes are served immediately.

### copper version

```
copper version
```

Prints the CLI version.
