# CLI

Every command accepts `--json` and `--cwd <dir>`. With `--json` the output is one object:

```json
{ "ok": true, "command": "check", "exitCode": 0, "data": {}, "diagnostics": [] }
```

## Exit codes

| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Problems found: diagnostics, failing tests, generator conflicts |
| 2 | Invalid usage |
| 3 | Environment not ready: variables, database, missing tools |
| 70 | Internal error (a bug in Fellow) |

## Commands

| Command | Purpose |
|---|---|
| `fellow help [command]` | List commands, arguments and options (machine-readable with `--json`) |
| `fellow new <name> [--template web\|saas\|module] [--module]` | Create an application from a template (see [`fellow docs getting-started`](/docs/getting-started)) |
| `fellow dev` / `fellow build [--profile production\|compiled] [--target] [--preset bun\|static]` | Development server / build into `.output/`; `compiled` adds a single executable; `--preset static` exports public pages as HTML files (both regenerate `src/fellow.gen.ts`, see [`fellow docs deployment`](/docs/deployment)) |
| `fellow types` | Generate `src/fellow.gen.ts`: typed route table for the Vue client |
| `fellow check [--tests] [--strict]` | Architecture Validator, type checker and optionally tests |
| `fellow test [files] [--affected] [--failed] [--task <id>] [--module <id>]` | Run tests with a structured report (code, environment, infrastructure) |
| `fellow doctor` | Diagnose runtime, configuration, database, tenant isolation and migrations |
| `fellow migrate [--dry-run] [--allow-destructive]` | Apply migrations |
| `fellow migrate:status` | State of every migration |
| `fellow intel [--write]` | Project Intelligence map |
| `fellow openapi` | OpenAPI 3.1 document from the route contracts |
| `fellow knowledge [--source docs\|contracts]` | What the application says about itself (`docs/` and the contracts) as Markdown sections; see [`fellow docs knowledge`](/docs/knowledge) |
| `fellow context <terms> [--pack] [--budget n]` | Ranked context; `--pack` gives excerpts with origin within a token budget |
| `fellow docs:check [--framework]` | Detect outdated documentation |
| `fellow fix [--dry-run] [--id]` | Mechanical fixes for diagnostics |
| `fellow task:new` / `task:check` / `task:evidence` / `task:list` | Task Planner and Evidence Report (see [`fellow docs agents`](/docs/agents)) |
| `fellow approve <action> <target>` / `fellow approvals` | Human approvals (interactive only) |
| `fellow skills [name]` / `fellow skills:install` | Official agent skills |
| `fellow mcp` | MCP server (stdio) |
| `fellow docs [topic]` | Documentation and decisions (`adr/...`) of the installed version |
| `fellow module:validate <id>` / `fellow module:graph` | Validate one module / dependency graph |
| `fellow module:schema` | JSON Schema of the module manifest |
| `fellow module:list [--tenant]` | Lifecycle of every module (installed version, status, tenants) |
| `fellow module:upgrade <id> [--dry-run]` | Upgrade a module with `updatePolicy: 'manual'` |
| `fellow module:enable <id>` / `module:disable <id>` | Enable or disable a module for every tenant |
| `fellow module:activate <id> --tenant` / `module:deactivate <id> --tenant` | Per-tenant activation (no rebuild) |
| `fellow module:suspend <id> --tenant [--resume]` | Suspend a module for a tenant |
| `fellow module:uninstall <id>` | Mark uninstalled (needs `fellow approve module.uninstall <id>`) |
| `fellow entitlement:grant <key> --tenant [--expires] [--source]` / `entitlement:revoke` / `entitlement:list` | Entitlements |
| `fellow module:keygen` / `module:pack <id> [--sign] [--previous]` / `module:verify <tgz>` / `module:add <tgz> [--upgrade]` | Signed packages with integrity and contract versioning |
| `fellow token --tenant <uuid> --permission a.b.c` | Development access token (disabled in production) |
| `fellow tenant:create <slug> --name` / `tenant:list` / `tenant:suspend` / `tenant:activate` | Tenant registry (see [`fellow docs tenancy`](/docs/tenancy)) |
| `fellow tenant:limits <tenant> [--set q=n] [--unset q]` | Per-tenant quota limits |
| `fellow tenant:export <tenant> [--out]` | NDJSON export with manifest; needs `fellow approve tenant.cross <tenant-id>` |
| `fellow flag:set <flag> (--on\|--off\|--clear) [--tenant] [--rollout]` / `flag:list` | Feature flags |
| `fellow audit <tenant> [--action] [--actor] [--limit] [--verify]` | Audit log; `--verify` checks the hash chain |
| `fellow retention:run [--dry-run]` | Apply module retention policies per tenant, and prune finished jobs, workflows and events |
| `fellow work [--queue] [--concurrency] [--once] [--no-scheduler]` | Worker: jobs, durable event deliveries, workflows, cron schedules (see [`fellow docs operations`](/docs/operations)) |
| `fellow queue:status` / `queue:list [--status] [--name]` | Queue depth, live workers, jobs |
| `fellow queue:retry <id>` / `queue:retry --dead [--name]` / `queue:cancel <id>` | Retry dead jobs, cancel pending ones |
| `fellow workflow:list [--status] [--name] [--tenant]` / `workflow:show <id>` | Durable workflows and their step history |
| `fellow workflow:signal <id> <signal> [--data]` / `workflow:cancel <id>` | Signal or cancel (with compensation) a workflow |
| `fellow schedule:list` | Cron schedules and their next run |
| `fellow errors [--hours] [--limit]` | Unexpected errors grouped by fingerprint |
| `fellow diagnose <id>` | Explain a request id, error fingerprint, job or workflow: findings, code, causes, next steps |
| `fellow backup [--out] [--schema-only]` / `backup:verify <file>` | pg_dump backup with SHA-256 manifest / integrity check |
| `fellow restore <file>` | Restore a backup (needs `fellow approve backup.restore <file>`) |
| `fellow registry:init <dir> [--name]` / `registry:serve <dir> [--port] [--host]` | Create a static module registry / serve it read-only over HTTP (see [`fellow docs publishing`](/docs/publishing)) |
| `fellow registry:trust <fingerprint> [--registry]` | Trust a publisher key (interactive only) |
| `fellow module:publish <tgz> [--registry] [--key]` | Publish a signed package (needs `fellow approve module.publish <tgz>`) |
| `fellow module:install <id>[@range] [--registry] [--upgrade]` | Install from a registry: compatibility, dependencies, integrity, trusted signature, lockfile |
| `fellow module:yank <id>@<version> --reason` / `module:outdated` | Withdraw a published version / installed modules with newer or yanked versions |
| `fellow catalog [term] [--all] [--registry]` | Modules available in the configured registries |
| `fellow upgrade:check` / `upgrade [--dry-run]` | Compatibility with the installed Fellow version / apply the automatic changes (see [`fellow docs upgrading`](/docs/upgrading)) |

## Generators

Generators print a plan and write nothing with `--dry-run`. Re-running one is safe: identical files are
`unchanged`; files that differ are a `conflict` (exit 1) unless `--force` is given.

| Command | Creates |
|---|---|
| `fellow make:module <id> [--description]` | Manifest and `public.ts` |
| `fellow make:entity <module>.<entity> --fields ...` | Entity schema and tenant-isolated migration |
| `fellow make:resource <module>.<entity> --fields ...` | Entity, migration, service, create/list/get routes, permissions, tests |
| `fellow make:route <module>.<resource>.<action> [--method] [--path]` | Route, permission and test |
| `fellow make:event <module>.<entity>.<fact>` | Versioned event |
| `fellow make:page <module>/<Path>` | Page contract (path derived from the component), Vue component and test |
| `fellow make:policy <module>.<entity>` | Per-record policy and test |
| `fellow make:middleware <module>.<name>` | Typed middleware |
| `fellow make:notification <module>.<entity>.<event>` | Notification with mail and in-app channels |
| `fellow make:isolation <module> [--factory]` | Cross-tenant isolation test seeded by a factory of the module |
| `fellow make:service <module>.<name>` | Application service and test |
| `fellow make:test <module>.<name>` | Test wired to the test app |
| `fellow make:config <module>` | Validated module configuration |
| `fellow make:factory <module>.<entity>` | Deterministic test-data factory |
| `fellow make:auth` | `accounts` module: users, memberships, sign-in/out, login page, tests |
| `fellow make:job <module>.<name> [--queue]` | Background job |
| `fellow make:workflow <module>.<name>` | Durable workflow with a step, a compensation and a signal |
| `fellow make:schedule <module>.<name> --job <module>.<job> [--cron]` | Cron schedule that queues a job per tenant |
| `fellow make:channel <module>.<resource> [--permission]` | Real-time channel (Server-Sent Events) |

`make:resource` also creates a factory; with `--page` it adds a Vue index page (list, pagination, form).

Fields: `name:type`, comma-separated; append `?` for nullable. Types: `string`, `text`, `int`, `number`,
`bool`, `uuid`, `timestamp`. `id`, `tenant_id`, `created_at` and `updated_at` are added automatically.
