{"title":"amber watch","description":"Rebuild and restart an Amber V2 application during development","section":"cli","version":"v2","path":"cli/watch","canonical_url":"https://amberframework.org/docs/v2/cli/watch","markdown_url":"https://amberframework.org/docs/v2/cli/watch.md","inherited":false,"content_markdown":"# `amber watch`\n\n**Run from: the generated application root beside `shard.yml`.**\n\n```bash\namber watch\n```\n\nThe default V2 watch configuration rebuilds when Crystal source, environment\nYAML, ECR views, or authored assets change. It builds assets first, creates\n`bin/`, builds the app target, runs it, and restarts after matching files\nchange.\n\n```yaml\nwatch:\n  run:\n    build_commands:\n      - mkdir -p bin\n      - crystal build ./src/my_app.cr -o bin/my_app\n    run_commands:\n      - bin/my_app\n    include:\n      - ./config/**/*.cr\n      - ./config/environments/*.yml\n      - ./src/**/*.cr\n      - ./src/**/*.ecr\n      - ./app/assets/**/*\n```\n\nUse environment variables normally:\n\n```bash\nAMBER_SERVER_PORT=8080 amber watch\n```\n\nStop the watcher with `Ctrl-C`. If a rebuild fails, run the printed build\ncommand directly to get the complete compiler error.\n\n## Asset-aware watch cycle\n\nCLI `2.0.6` runs the same build-time compiler as `amber assets build` before\napplication compilation. A deleted asset, missing CSS image/font reference,\nmissing local JavaScript dependency, or invalid manifest entry therefore stops\nthe rebuild instead of becoming a browser 404."}