CLI Reference
Exhaustive reference for every mandu subcommand: flags, environment variables, exit codes.
On this page
CLI Reference
Every Mandu command-line entry point registered in @mandujs/cli at the version
pinned by your project. The list below is generated from the command registry
(commands/registry.ts); if a command is not in this page, it is not part of
the supported CLI surface.
This list reflects v0.22 / v0.23. Check
@mandujs/cli@0.23release notes (and later) for any commands added after this snapshot.
Global behavior
The binary is declared as #!/usr/bin/env bun — running Mandu commands under
Node.js will fail. Argument parsing follows one rule:
--flag valueand--flag=valueboth work.- Short flags are single-letter:
-h,-q,-v,-d,-y(mapped to--help,--quiet,--verify,--diff,--yes). - The first non-flag argument is the command; the second is the positional
target (e.g.
mandu generate page admin→ commandgenerate, subcommandpage, targetadmin).
Global flags
| Flag | Short | Effect |
|---|---|---|
--help |
-h |
Print top-level help and exit 0 |
--quiet |
-q |
Reduce log output (honored by commands that support it) |
--yes |
-y |
Skip interactive prompts (used by init) |
Exit codes
| Code | Meaning |
|---|---|
0 |
Command succeeded |
1 |
Command failed, unknown command, unknown subcommand, or missing required argument |
Individual commands may exit with 0 specifically through exitOnSuccess —
init, build, clean, info, generate, cache, middleware, session,
auth, ws, collection, fix, review, ask, explain, scaffold,
new, mcp, deploy, upgrade, desktop, completion.
Command index
Project lifecycle
mandu init
Create a new project. Tailwind + shadcn/ui are included by default.
| Flag | Type | Description |
|---|---|---|
--name |
string | Project name (positional also accepted) |
--template |
string | Template identifier |
--css |
string | CSS framework choice |
--ui |
string | UI library choice |
--theme |
boolean | Install theme scaffolding |
--minimal |
boolean | Minimal scaffold (skip optional features) |
--with-ci |
boolean | Add CI workflow files |
--yes / -y |
boolean | Non-interactive mode |
--no-install |
boolean | Skip dependency install |
Exits 0 on success.
mandu dev
Start the dev server. FS Routes and Guard are enabled by default.
| Flag | Type | Description |
|---|---|---|
--port |
number | Override port (env: PORT) |
--open |
boolean | Open default browser after start |
Env vars: PORT, MANDU_PERF (set 1 for perf traces), MANDU_HDR
(set 0 to disable HMR dynamic reload payloads).
mandu build
Build client bundles for hydration.
| Flag | Type | Description |
|---|---|---|
--watch |
boolean | Rebuild on changes |
Exits 0 on success.
mandu start
Start production server. Requires a prior mandu build.
| Flag | Type | Description |
|---|---|---|
--port |
number | Override port (env: PORT) |
mandu preview
Build and then start the production server in one step.
| Flag | Type | Description |
|---|---|---|
--port |
number | Override port |
mandu clean
Remove build artifacts under .mandu/client and .mandu/static.
| Flag | Type | Description |
|---|---|---|
--all |
boolean | Remove additional artifacts as well |
mandu info
Print project and environment information. No flags.
Quality gates
mandu check
Integrated FS Routes + Guard check. Honors CI=true for strict warning
treatment.
mandu guard [subcommand]
Architecture violation check. Default subcommand: arch.
| Subcommand | Purpose |
|---|---|
arch |
Run architecture guard (default) |
legacy |
Legacy compatibility check |
spec |
Specification check |
manifest |
Manifest check |
Flags (forwarded to guard):
| Flag | Type | Description |
|---|---|---|
--watch |
boolean | Re-run on file change |
--output |
string | Output format |
Env: CI=true enables agent/JSON output conventions.
mandu doctor
Analyze Guard failures and suggest patches.
| Flag | Type | Description |
|---|---|---|
--no-llm |
boolean | Skip LLM-based analysis |
--output |
string | Output format |
mandu fix
Run Guard healing, diagnostics, and optional build verification.
| Flag | Type | Description |
|---|---|---|
--apply / --auto-fix |
boolean | Apply healing patches |
--no-build |
boolean | Skip final build verification |
--file |
string | Limit scope to a path |
--json |
boolean | JSON output |
--preset |
string | Guard preset override |
--verify / -v |
boolean | Verification-only mode |
mandu review
Review changed files with guard and contract diagnostics.
| Flag | Type | Description |
|---|---|---|
--base |
string | Git base ref |
--staged |
boolean | Review staged files only |
--json |
boolean | JSON output |
--no-llm |
boolean | Skip LLM-based commentary |
Routes, contracts, OpenAPI
mandu routes [subcommand]
FS Routes management. Default: list.
| Subcommand | Purpose |
|---|---|
list |
List discovered routes |
generate |
Regenerate the route manifest |
watch |
Watch routes and regenerate |
Flags: --output, --verbose.
mandu contract <subcommand>
Contract-first API development. No default — a subcommand is required.
| Subcommand | Purpose |
|---|---|
create <routeId> |
Create a contract for a route |
validate |
Validate existing contracts (--verbose) |
build |
Build contract artifacts (--output) |
diff |
Diff contracts (--from, --to, --output, --json) |
mandu openapi <subcommand>
Generate or serve an OpenAPI spec.
| Subcommand | Flags | Purpose |
|---|---|---|
generate |
--output, --title, --version |
Emit OpenAPI JSON |
serve |
— | Serve spec over HTTP |
Code generation and scaffolds
mandu generate [subcommand]
Code generation. Subcommands: resource, page, api, feature, both.
| Flag | Type | Description |
|---|---|---|
--ai |
string | Route through the AI generator with this prompt |
--fields |
string | Resource fields (for generate resource) |
--timestamps |
boolean | Add timestamps (for generate resource) |
--methods |
string | Method allow-list |
--force |
boolean | Overwrite existing files |
--dry-run |
boolean | Preview without writing (AI path) |
--with-contract |
boolean | Also scaffold a contract (AI path) |
--with-island |
boolean | Also scaffold an island (AI path) |
mandu scaffold <type> [name] and mandu new <type> [name]
Generate boilerplate. new is an alias for scaffold.
Types: middleware, ws, session, auth, collection.
| Flag | Type | Description |
|---|---|---|
--preset |
string | Preset name (e.g., middleware preset) |
--schema |
string | Schema reference (e.g., collection schema) |
mandu add <subcommand>
Add features to an existing project.
| Subcommand | Purpose |
|---|---|
test |
Add ATE test scaffolding |
mandu middleware init
Generate middleware scaffolding. Flag: --preset.
mandu session init
Generate session storage scaffolding. No flags.
mandu auth init
Generate auth scaffolding and example routes. Flag: --strategy.
Env: JWT_SECRET (dev fallback mandu-dev-jwt-secret),
SESSION_SECRET (dev fallback mandu-dev-secret),
NODE_ENV (sets cookie secure).
mandu ws [name]
Generate a WebSocket route scaffold.
mandu collection create [name]
Create content collection scaffolding. Flag: --schema.
Tests and automation
mandu test:auto
ATE auto E2E generation/execution.
| Flag | Type | Description |
|---|---|---|
--ci |
boolean | CI mode (non-interactive, deterministic) |
--impact |
boolean | Only run impacted tests |
--base-url / --baseURL / --baseUrl |
string | Target base URL |
mandu test:watch
Watch mode: re-run ATE for affected routes on file changes.
| Flag | Type | Description |
|---|---|---|
--oracle |
string | Oracle level: L0, L1 (default), L2, L3 |
--base-url |
string | Default http://localhost:3333 |
--debounce |
number | Debounce window (ms) |
Terminated via SIGINT / SIGTERM.
mandu test:heal
Generate ATE healing suggestions (no auto-commit). No flags.
Database
mandu db <subcommand>
Schema migrations.
| Subcommand | Purpose |
|---|---|
plan |
Plan migrations |
apply |
Apply migrations |
status |
Show migration status |
reset |
Reset database |
Env: DATABASE_URL (primary), MANDU_DB_RESET_CONFIRM (destructive
confirmation for reset). db dispatches to subcommand handlers which exit
with their own explicit codes (EXIT_USAGE for invalid usage).
Observability and runtime
mandu watch
Real-time file watching.
| Flag | Type | Description |
|---|---|---|
--status |
boolean | Status report mode |
--debounce |
number | Debounce window (ms) |
mandu monitor
Observability event monitor.
| Flag | Type | Description |
|---|---|---|
--summary |
boolean | Summary mode |
--since |
string | Filter window |
--follow |
boolean | Follow new events (default true; pass --follow=false to disable) |
--file |
string | Log file to tail |
--type |
string | Event type filter |
--severity |
string | Severity filter |
--stats |
boolean | Print stats |
--trace |
string | Filter by trace id |
--source |
string | Source filter |
--no-server |
boolean | Skip local server mode |
--export |
string | Export format: jsonl or otlp |
--limit |
number | Max events |
mandu brain <subcommand>
Brain (sLLM) management.
| Subcommand | Flags | Purpose |
|---|---|---|
setup |
--model, --url, --skip-check |
Configure local sLLM |
status |
--verbose |
Print current status |
mandu ask [...query]
Ask the local Mandu assistant for codebase-aware guidance.
| Flag | Type | Description |
|---|---|---|
--json |
boolean | JSON output |
--no-llm |
boolean | Skip LLM; static guidance only |
mandu explain [codeOrType]
Explain a Guard rule or violation pattern.
| Flag | Type | Description |
|---|---|---|
--from / --fromLayer |
string | Source layer |
--to / --toLayer |
string | Destination layer |
--preset |
string | Guard preset |
--json |
boolean | JSON output |
Build, deploy, upgrade
mandu cache <action>
Cache management.
| Action | Purpose |
|---|---|
clear |
Clear cache (optional path positional) |
stats |
Show cache stats |
Flags: --tag, --all, --json.
mandu deploy
Validate, build, and generate deployment artifacts.
| Flag | Type | Description |
|---|---|---|
--target |
string | Deployment target |
mandu upgrade
Check for or install the latest @mandujs/* package versions.
| Flag | Type | Description |
|---|---|---|
--check |
boolean | Check only; do not install |
Change transactions, locks, MCP, desktop, completion
mandu change <subcommand>
Change transaction management.
| Subcommand | Flags | Purpose |
|---|---|---|
begin |
--message |
Begin a change transaction |
commit |
— | Commit current change |
rollback |
--id |
Roll back a specific change |
status |
— | Show current change |
list |
— | List changes |
prune |
--keep |
Prune old changes |
mandu lock
Lockfile management. Flags are validated by the command directly (not the top-level parser).
| Flag | Short | Description |
|---|---|---|
--verify |
-v |
Verify lockfile against current config |
--diff |
-d |
Print diff |
--show-secrets |
— | Reveal secret values in diff output |
--include-snapshot |
— | Include runtime snapshot |
--quiet |
-q |
Reduce output |
--json |
— | JSON output |
--mode <m> |
— | development | build | ci | production |
mandu mcp
Run MCP tools from the terminal.
| Flag | Type | Description |
|---|---|---|
<tool> |
positional | Tool name; omit to list |
--list |
boolean | List tools |
--json |
boolean | JSON output |
Extra flags are forwarded as the tool's argument payload.
mandu desktop [subcommand]
Desktop targets. Default: scaffold.
| Subcommand | Purpose |
|---|---|
scaffold |
Create desktop scaffolding |
dev |
Desktop dev mode |
build |
Build desktop artifact |
Flags: --entry, --force. Env: MANDU_APP_TITLE.
mandu completion <shell>
Output a shell completion script. Required positional: bash, zsh, or
fish. Exits 1 if shell is missing or invalid.
Environment variables
| Variable | Consumed by | Purpose |
|---|---|---|
PORT |
dev, start, preview, openapi |
Server port |
CI |
check, guard |
Strict warnings; agent/JSON output hints |
NODE_ENV |
auth |
Cookie secure flag in production |
JWT_SECRET |
auth init |
Signing secret (dev fallback only) |
SESSION_SECRET |
scaffold templates |
Session secret (dev fallback only) |
DATABASE_URL |
db |
Migration target database |
MANDU_DB_RESET_CONFIRM |
db reset |
Destructive confirmation |
MANDU_PERF |
dev |
1 enables perf traces |
MANDU_HDR |
dev |
0 disables HMR dynamic reload payloads |
MANDU_APP_TITLE |
desktop |
Window title |
🤖 Agent Prompt
Apply the guidance from the Mandu docs page at https://mandujs.com/docs/reference/cli to my project.
Summary of the page:
Canonical list of all mandu CLI subcommands registered in @mandujs/cli. Use this to know which commands exist, which flags are accepted, and which exit codes to expect. Do not invent commands not listed here.
Required invariants — must hold after your changes:
- The runnable command set is whatever @mandujs/cli registers in commands/registry.ts — this list reflects v0.22/v0.23
- Unknown commands print an error and exit with code 1; unknown subcommands do the same
- CLI entrypoint is the bun shebang (#!/usr/bin/env bun) — do not invoke with node
- Short flags are fixed: -h=--help, -q=--quiet, -v=--verify, -d=--diff, -y=--yes
- Subcommands that only make sense with a target (add, middleware, session, auth, collection, scaffold) exit with code 1 when called without their required subcommand
Then:
1. Make the change in my codebase consistent with the page.
2. Run `bun run guard` and `bun run check` to verify nothing
in src/ or app/ breaks Mandu's invariants.
3. Show me the diff and any guard violations.
For Agents
Canonical list of all mandu CLI subcommands registered in @mandujs/cli. Use this to know which commands exist, which flags are accepted, and which exit codes to expect. Do not invent commands not listed here.
- The runnable command set is whatever @mandujs/cli registers in commands/registry.ts — this list reflects v0.22/v0.23
- Unknown commands print an error and exit with code 1; unknown subcommands do the same
- CLI entrypoint is the bun shebang (#!/usr/bin/env bun) — do not invoke with node
- Short flags are fixed: -h=--help, -q=--quiet, -v=--verify, -d=--diff, -y=--yes
- Subcommands that only make sense with a target (add, middleware, session, auth, collection, scaffold) exit with code 1 when called without their required subcommand