# KanzlAI Coding Conventions

## Go (backend/)

- Standard library style — prefer stdlib over third-party packages where reasonable
- `go vet` and `go test` must pass before committing
- Package layout: `cmd/` for entry points, `internal/` for private packages
- Error handling: return errors, don't panic. Wrap with context via `fmt.Errorf("operation: %w", err)`
- Naming: follow Go conventions (MixedCaps, not snake_case)
- No global mutable state

## TypeScript / Next.js (frontend/)

- TypeScript strict mode (enabled in tsconfig.json)
- App Router (src/app/) — no Pages Router
- Use server components by default, `"use client"` only when needed
- Tailwind CSS v4 for styling — no CSS modules or styled-components
- ESLint must pass before committing
- Import aliases: `@/` maps to `src/`
- Bun as package manager (not npm/yarn/pnpm)
- **API paths: NEVER include `/api/` prefix.** The `api` client in `lib/api.ts` already has `baseUrl="/api"`. Write `api.get("/cases")` NOT `api.get("/api/cases")`. The client auto-strips accidental `/api/` prefixes but don't rely on it.

## General

- No secrets in code — use environment variables
- Commit messages: `feat:`, `fix:`, `build:`, `refactor:`, `docs:`, `test:`, `chore:`
