Loading...
Loading...
Hot-reload Go apps with cosmtrek/air during development. Use when setting up dev workflows for Go HTTP servers, configuring .air.toml, or debugging hot-reload issues with SQLite, port binding, or file watchers.
npx skill4agent add brojonat/llmsrules air-gogo install github.com/air-verse/air@latestair.go.air.tomlroot = "."
tmp_dir = "tmp"
[build]
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 500
exclude_dir = ["tmp", "k8s", "cmd", "node_modules", "vendor"]
exclude_regex = ["_test\\.go$"]
include_ext = ["go", "html", "css", "js", "yml", "yaml", "toml"]
kill_delay = "1s"
send_interrupt = true
stop_on_error = true
[misc]
clean_on_exit = true| Setting | What it does | Why it matters |
|---|---|---|
| Milliseconds to wait after a file change before rebuilding | Prevents rapid-fire rebuilds when saving multiple files |
| Time to wait after killing the old process before starting the new one | Critical for SQLite/file locks — the old process needs time to release resources |
| Send SIGINT before SIGKILL | Allows graceful shutdown (flush writes, close DB connections) |
| Don't restart on build errors | Prevents crash loops when you have a syntax error |
| File extensions to watch | Add |
| Directories to ignore | Exclude test fixtures, k8s manifests, vendored deps |
| File patterns to ignore | Skip test files to avoid rebuilding when only tests change |
| Remove tmp dir on exit | Prevents stale binaries from confusing the next run |
.PHONY: dev dev-email dev-clean
# Dev: console output, fresh state
dev: dev-clean
air
# Dev: real emails, LAN-accessible for mobile testing
dev-email: dev-clean
$(call setup_env, .env.prod)
SMTP_HOST=smtp.example.com \
BASE_URL=http://$(LAN_IP):8080 \
air
dev-clean:
@rm -f app.db app.db-shm app.db-wal tmp/main
@-lsof -ti :8080 | xargs kill -9 2>/dev/null || truedev-cleanair# Inline
PORT=3000 DEBUG=true air
# From .env file in Makefile
$(call setup_env, .env.dev)
air.air.tomllsof -ti :8080 | xargs kill -9dev-clean.air.toml[build]
kill_delay = "1s" # Give old process time to release the lock
send_interrupt = true # Graceful shutdown via SIGINT
pre_cmd = ["rm -f app.db-shm app.db-wal"] # Clean stale lock files[build]
pre_cmd = ["rm -f app.db app.db-shm app.db-wal"][build]
exclude_dir = ["tmp", "vendor", "node_modules", ".git", "k8s", "docs"]Ctrl+Cgo run .include_extexclude_dir[build]
include_ext = ["go", "html", "css", "js"]cmd/servercmd/workercmd[build]
cmd = "go build -o ./tmp/server ./cmd/server"
bin = "./tmp/server"air -c .air.worker.toml