08. reeve
reeve is the Avelon CLI. It creates apps, writes code into the right folders, syncs routes, and checks your project.
Running It
From an app with @avelonjs/cli in its devDependencies:
bunx --no-install reeve --help
Scripts in package.json can call reeve directly. From this repo's root, use bun packages/cli/src/bin.ts instead.
reevewith no arguments opens the TUIreeve help make:modelprints a command's usage, flags, and an examplereeve make:model --helpdoes the same
Asking for help never runs the command.
Create an App
bunx --package @avelonjs/cli reeve new my-app
cd my-app
bun install
bun run dev
The app needs no database or credentials. From a framework checkout, bun run create:app ../my-app does the same thing.
Your App's Config
These load avelon.config.ts from the current folder before they run:
migrate,db:seed, andward:syncconfig:show,capabilities, andaboutevent:list,tinker, anddoctor- the TUI header
So run them from the app root. Without the file, migrate, config:show, capabilities, ward:sync, and event:list stop and name the file they looked for. The rest run without it.
A config loaded earlier in the same process still counts, for example one loaded with bun --preload.
The TUI
┌─ avelon ────────────────────────────── my-app · supabase · next · local ─┐
│ │
│ Make model, controller, request, policy, ward, event, listener, │
│ errand, action, command, middleware, view, driver, package │
│ Database migrate, rollback, fresh, seed, schema:pull │
│ Wards list, sync, check, explain │
│ Routes list, sync │
│ Errands work, failed, retry, flush │
│ Inspect event:list, config:show, capabilities, about │
│ Doctor doctor, bailiff, docs:check │
│ │
│ ↑↓ navigate · ⏎ select · ? help · / search · q quit │
└───────────────────────────────────────────────────────────────────────────┘
- Before it runs anything, the TUI prints the plain command, so you learn the scriptable version as you go
?shows the highlighted command's usage and example. Escape goes back to the list- The header shows the app, database driver, adapter, and environment from
avelon.config.ts. "Which database am I pointed at" is the question that comes before most disasters AVELON_APP,AVELON_DATABASE, andAVELON_ADAPTERoverride what the header shows- Any command with arguments skips the TUI. So do
--no-tuiand a non-interactive terminal, which keeps CI free of prompts
Generate Code
A whole resource in one command:
reeve make:model Post -mfcp --resource
That writes the model, its ward, a migration, a factory, a policy, and a resource controller with its requests and pages. Then it registers the ward and policy.
The flags:
-mmigration-ffactory-ccontroller, and--resourcegives it the 7 resource actions-ppolicy
There's no flag for the ward. Every model gets one, because Bailiff fails a model without it.
Every Generator
| Command | Writes |
|---|---|
make:model Post | The model and its ward |
make:controller Post --resource | 7 actions, 2 requests, and 4 pages |
make:controller Dashboard | A controller and the page its index action renders |
make:request StorePostRequest | A request validator |
make:policy PostPolicy | A policy. --model=Post names the model |
make:ward PostWard | A ward. --model=Post names the model |
make:event PostPublished | An event |
make:listener NotifySubscribers | A listener. --event=PostPublished types and registers it. --queued makes it a queued listener with retries |
make:errand GenerateThumbnail | A queued errand |
make:action PublishPost | An action |
make:middleware EnsureSubscribed | Kernel middleware |
make:command PruneDrafts | A command. Run it with bun app/Commands/PruneDrafts.ts |
make:view posts/Index | A React view at resources/views/posts/Index.tsx |
make:auth | A session controller, sign-in and sign-out requests, and a sign-in page |
make:migration add_slug_to_posts | A timestamped migration |
make:driver storage r2 | A driver package with its conformance suite wired up |
make:package billing | A package README in the house style |
Every generated file type-checks and passes Bailiff in a fresh app. bun run scaffold:check in this repo runs every generator to keep it that way.
What Gets Wired Up
Generators also register what they write:
- Wards and policies get
defineWardordefinePolicyinregisterApp(), which lives inapp/Providers/AppProvider.ts - A listener made with
--eventgetsEvents.listenthere too, and the event is created if it's missing - Errands get
registerErrand - Migrations get added to
database/migrations/index.ts, which is created if it's missing
reeve new creates the provider and avelon.config.ts calls it. If the provider or registerApp() is missing, reeve prints the line to add instead. Routes and middleware are yours to place, so reeve prints those lines too.
When a File Exists
If the main file is already there, the generator writes nothing and exits 1. Supporting files that already exist, like a request a resource controller reuses, are kept as they are.
Custom Templates
reeve stub:publish
Copies the generator templates into stubs/. A file there replaces the built-in stub with the same name, so a team can change what generated code looks like without forking the framework.
Database
reeve migrate
reeve migrate:status
reeve migrate:rollback
reeve migrate:fresh --seed
reeve make:migration create_posts_table
reeve db:seed
migrate:freshrolls back up to 100 migrations, then applies them again. Outside thelocalenvironment it needs--confirm=<environment>--seedrunsdatabase/seedsafterwardschema:pullwrites an emptyDatabaseinterface todatabase/types.ts
Wards
reeve ward:list
reeve ward:check
reeve ward:explain Post
reeve ward:sync
ward:listshows each model and its ward fileward:checkfails when a model has no wardward:explainshows the SQL each ward rule adds to queriesward:syncturns wards into row-level security on drivers that support it
Debugging Row Access
ward:explain reads app/Wards/PostWard.ts and compiles each rule twice, once for a guest and once for a signed-in actor:
$ reeve ward:explain Post read --actor=42
PostWard on posts. Each row shows the SQL condition a query receives.
read
guest "published_at" IS NOT NULL
actor 42 ("published_at" IS NOT NULL OR "user_id" = $1) $1 = "42"
That condition gets added to every query on the table. Leave off the action to see all 4.
Syncing to the Database
ward:sync calls the driver's syncWards() when the driver declares rowSecurity: true, like Supabase does. Postgres and Neon apply wards inside each query instead, so for them ward:sync says there's nothing to sync.
Routes
reeve route:list
reeve route:sync
reeve route:sync --check
route:listprints the method, path, name, action, and middleware.--jsonprints the same for scriptsroute:syncregenerates pages, server actions, API handlers, and typed URLs fromroutes/web.tsroute:sync --checkreports missing, changed, and stale files without writing anything, and exits 1 if anything drifted
Run --check in CI if your app commits its router. After changing a route locally, run reeve route:sync.
Typed URLs
Views and client components can build links without booting the router:
import { url } from '@/framework/routing/urls.generated'
const href = url('posts.show', { post: 42 }) // /posts/42
TypeScript checks the route name and its required params against routes/web.ts. Each value is encoded as one path segment. For writes, use the generated server actions.
Events
reeve event:list
EVENT LISTENER DELIVERY QUEUE TRIES PRIORITY
PostPublished NotifySubscribers queued notifications 3 10
It loads avelon.config.ts, and if that registers no listeners it calls registerApp() from app/Providers/AppProvider.ts. Listener names come from the exports in app/Listeners/. --json prints the same rows.
Errands
reeve errand:work
reeve errand:failed
reeve errand:retry <id|all>
reeve errand:flush
errand:work drains the queue and prints how many errands ran.
Queued errands wait on the job board of the process that dispatched them. So these commands only see errands queued in that same process - for example, a script that dispatches errands and then calls runReeve.
Doctor
reeve doctor
Doctor
ok Bailiff clean
ok Wards every model has a ward
ok Config gazette (avelon.config.ts)
ok Router up to date
info Environment local
It exits 1 when:
- Bailiff reports an error
- a model has no ward
avelon.config.tsfails to load
An out of date router is only a warning, since apps that keep generated files out of Git won't have them until bun run generate. Doctor ends with the capability matrix.
The SaaS starter has its own bun run doctor that checks its environment and services.
Capabilities
reeve capabilities
Prints what your drivers can and can't do. It's the fastest way to find out why a driver has no transaction().
Inspect
reeve tinker
reeve tinker --execute 'await Post.query().count()'
reeve config:show
reeve about
tinkeropens a REPL with your app, its models,DB,Events, andRouteloaded. You can await a promise right on the line, andconst posts = await Post.query().get()keepspostsfor later lines. Type.exitto leaveconfig:showprints the app name, adapter, and the driver for each contract as JSONaboutshows the app, environment, drivers, and installed package versions
Documentation
reeve docs:check
reeve docs:check packages/orm
reeve docs:check --workspace
Lints package READMEs against the house style in 10-conventions.md. A package fails when:
- a required section is missing
- a TypeScript or JSON code block doesn't parse
- a public export is missing from the Method Reference table
To waive one, add <!-- docs:check-waiver: section Testing --> or <!-- docs:check-waiver: export name -->. make:package writes a README that already passes.