# Conventions and Workflow

## Code style

- **TypeScript strict.** Import via the `@/` alias (`@/lib/...`, `@/components/...`).
- **Prettier:** 100-character lines, double quotes, semicolons, trailing commas, Tailwind class sorting. Run `npm run format`.
- **ESLint:** `eslint-config-next` core-web-vitals + TypeScript. Unused bindings prefixed with `_` are allowed.
- **Comments:** explain *why*, especially around integrations and static-export constraints. Match the density of the surrounding file.
- **Placeholders:** mark content awaiting the client with `[PLACEHOLDER: …]` so it can be found with grep.

## Architecture rules

- **Server components by default.** Add `"use client"` only for state, effects, or browser APIs.
- **Data in `src/lib`, presentation in `src/components`.** Page-specific prose can live in `page.tsx`.
- **Nothing that needs a server at runtime** except in `functions/`. No route handlers, server actions, `headers()`/`cookies()`, or ISR. They break `output: "export"`.
- **Never expose secrets through `NEXT_PUBLIC_*`.** Anything needing a secret goes in a Pages Function.
- **Keep third-party specifics isolated**: FareHarbor in `content.ts` and `FareharborWidget`; HighLevel in the Function, `LeadForm`, `EmailSignup`, `DonateWidget`, and `support-content.ts`.
- **Payments never touch the site.** Link to provider-hosted checkouts.
- **Validate at the edge of CMS data.** Loaders should tolerate missing optional fields and bad URLs (see `getTourBooking`).
- **Before using a Next.js API, check `node_modules/next/dist/docs/`** (per `AGENTS.md`). Next 16 has breaking changes.

## Workflow

1. `git pull` first. Decap commits to `main` frequently.
2. Work on a branch for anything non-trivial. Pushing it gives you a Cloudflare preview URL to share for review.
3. `npm run lint && npm run format:check && npm run build` before merging.
4. Merge to `main`, then verify on production.
5. If a change affects editors or admins (a new CMS field, changed behaviour), update this book (see *Maintaining This Book*).

Commit messages in this repo are short imperative summaries, for example "Link donations to HighLevel hosted checkout" or "Add annual corporate sponsors directory".