# CLAUDE.md

## Commands
- Build: `go build ./...` · Test: `go test ./... -race` · Lint: `golangci-lint run`
- Generate SQL code: `sqlc generate` (after editing `db/queries/*.sql`)

## Layout
- `cmd/server/main.go` wiring only · `internal/http` handlers · `internal/service` logic · `internal/db` sqlc output (do not edit)

## Style
- Idiomatic Go: small interfaces defined by the consumer, accept interfaces return structs.
- Use `net/http` with Go 1.22+ routing patterns (`mux.HandleFunc("GET /users/{id}", ...)`). No web framework unless asked.
- Pass `context.Context` as the first arg through every I/O call.
- Wrap errors: `fmt.Errorf("load user %d: %w", id, err)`. Never ignore an error; never `panic` in request paths.
- Use `log/slog` for structured logs.
- Tests are table-driven with `t.Run`; use `httptest` for handlers.

## Before finishing
- `gofmt` clean, `go vet` clean, tests pass with `-race`.
