2.6 KiB
2.6 KiB
Repository Guidelines
Project Structure & Module Organization
app/defines Next.js routes and Server Actions; folder names mirror URLs and exposepage.tsxorroute.tsentrypoints.- Shared UI lives in
components/, domain hooks inhooks/, reusable utilities inlib/, and Tailwind tokens plus global CSS understyles/. - Static assets sit in
public/; data fixtures and CMS JSON indata/; D1 schema and migrations insql/; automation scripts inscripts/. - Tests mirror this layout inside
__tests__/so suites stay close to the features they exercise.
Build, Test, and Development Commands
npm run devstarts the local server;npm run buildandnpm run startproduce and serve the production bundle.- Quality gates:
npm run lint,npm run format:check, andnpm run ci:typecheckkeep linting, formatting, and typing aligned. - Testing relies on Vitest:
npm run testfor watch mode,npm run test:runfor CI-stable runs, andnpm run test:coveragefor reports. - OpenNext & data ops:
npm run pages:buildprepares the worker bundle,npm run deploy:preview/npm run deploy:productionpush through Wrangler, andnpm run db:migrate[:local]ornpm run db:backupmanage D1 state. - Agent support tools live under
npm run bmad:*(refresh, list, validate) and should follow any manifest updates inbmad/.
Coding Style & Naming Conventions
- Ship TypeScript with strict typing; prefer explicit module exports over defaults for clean tree-shaking.
- Prettier and ESLint enforce 2-space indents, double quotes, and trailing commas; run
npm run formatbefore reviews. - Files follow PascalCase for components, camelCase for hooks/utilities, and kebab-case for route folders to produce friendly URLs.
Testing Guidelines
- Place specs under the matching
__tests__/subtree and name them*.test.ts[x]. - Combine Vitest with Testing Library for component interactions and use
vitest.setup.tsfor shared providers. - Add regression coverage for each bug fix and ensure watch mode passes before pushing.
- Gate merges with
npm run test:coverage; flag low coverage in the PR description.
Commit & Pull Request Guidelines
- Follow the Conventional Commit format in history (
feat(scope): summary,fix(area): detail) using present-tense voice. - Bundle schema or fixture changes with their related code and note breaking behavior explicitly.
- Before opening a PR, run lint, typecheck, coverage, and
npm run pages:build; attach output if CI is down. - PRs should explain motivation, link issues or tickets, and include UI screenshots or recordings when visuals change.