{"title":"amber generate","description":"Supported and preview generators in the Amber V2 beta","section":"cli","version":"v2","path":"cli/generate","canonical_url":"https://amberframework.org/docs/v2/cli/generate","markdown_url":"https://amberframework.org/docs/v2/cli/generate.md","inherited":false,"content_markdown":"# `amber generate`\n\n**Run from: the generated application root beside `shard.yml`.**\n\n```bash\namber generate TYPE NAME [fields or actions]\n```\n\n| Type | Status | Output |\n|---|---|---|\n| `controller` | Supported | Controller, ECR views, pending route specs |\n| `schema` | Supported | Built-in Schema API definition |\n| `job` | Supported | Built-in job class |\n| `mailer` | Supported | Built-in mailer class |\n| `channel` | Supported | WebSocket channel |\n| `migration` | Supported | Reversible Micrate SQL migration |\n| `model` | Supported | Grant-backed model, spec, and migration |\n| `scaffold` | Supported | Grant model, schema, HTML CRUD, ECR views, specs, route, and migration |\n| `api` | Preview | Persistence-backed model and controller |\n| `auth` | Preview | Requires a compatible persistence/auth stack |\n\n**Run from: the same application root — examples for the core web app.**\n\n```bash\namber generate controller Posts index show\namber generate schema Post title:string:required body:text\namber generate job PublishPost --queue=default --max-retries=3\namber generate mailer Digest --actions=weekly\namber generate channel Updates --topics=posts\namber generate migration CreatePosts\n```\n\nController routes are intentionally not guessed. Add them to `config/routes.cr`,\nthen enable the generated pending request specs. Amber V2 generator output is\nalways ECR, even if a migrated `.amber.yml` still contains a legacy Slang value.\n\nGenerated API resources and authentication remain preview and may require\nadditional application integration. Model, scaffold, and migration generators\nuse the Grant, selected database driver, and Micrate tooling included in the\nsupported database-backed web template.\n\nAmber CLI `2.0.6` binds scaffold and API schemas\ndirectly to `create` and `update`, then reads request-local typed values with\n`validated_as`. HTML scaffolds re-render their ECR forms on validation failure;\nAPI resources use the framework's structured JSON failure. This is the\nreleased generator path for Amber `2.0.0-beta.5`."}