# aerostack init

> Scaffold a new Aerostack project with your choice of template and database. Generates all config files, wrangler.toml, and SDK setup.

Scaffold a new Aerostack project with your choice of template and database.

## Usage

```bash
aerostack init [project-name] [flags]
```

Running without arguments launches an interactive prompt.

## Flags

| Flag | Default | Description |
|------|---------|-------------|
| `-t, --template` | interactive | Starter template (see list below) |
| `--db` | interactive | Database type: `d1` or `neon` |
| `--dev` | false | Start `aerostack dev` immediately after init |

## Templates

| Template | Description |
|----------|-------------|
| `blank` | Empty project, no routes |
| `api` | REST API with typed routes and D1 |
| `api-neon` | REST API backed by Neon Postgres |
| `multi-func` | Multi-service project (API + background worker) |
| `cron-neon` | Scheduled cron job with Neon Postgres |
| `webhook-neon` | Webhook receiver with Neon Postgres |
| `ws-chat` | WebSocket chat with Durable Objects |
| `ws-chat-neon` | WebSocket chat with Neon persistence |
| `ws-voice-agent` | Real-time voice AI agent |
| `ws-multiplayer-game` | Multiplayer game with Durable Objects |
| `ai-stream` | AI streaming API with SSE |

## Examples

```bash
# Interactive
aerostack init

# Named project with a specific template
aerostack init my-backend --template api --db d1

# Start dev server immediately after setup
aerostack init my-app --template ws-chat --dev

# Neon Postgres backend
aerostack init my-app --template api-neon --db neon
```

## What it does

1. Creates the project directory with `src/`, `migrations/`, `shared/`, and config files
2. Generates `aerostack.toml` with your project configuration
3. Runs `npm install` and pins all dependencies to latest versions
4. If `--dev` is set, starts the local dev server automatically

## Project structure after init

```
my-app/
├── aerostack.toml        # Project config (Aerostack equivalent of wrangler.toml)
├── src/
│   └── index.ts          # Main entry point
├── migrations/           # SQL migration files
├── shared/               # Shared utilities (importable as @shared/*)
├── package.json
└── tsconfig.json
```

`aerostack.toml` is the source of truth for your project. The CLI generates an internal `.aerostack/wrangler.toml` from it automatically — you should never edit that generated file directly.
