- Always read
README.md. - Check
docs/for up-to-date project documentation. - Check data schema definitions in
docs/or TypeScript types. - Understand Next.js routing (
/pages,app/) and React component structure.
- Store all documentation in the
docs/folder, as Markdown (.md). - Update documentation for each significant change.
- Document every new feature near its implementation (README,
/docs/, code comments). - API documentation must be clear for non-code readers (Swagger/OpenAPI, TSDoc).
- Do not update
README.mdfor minor fixes. - When moving
.mdfiles, update all internal and external links. - Avoid duplicate information. Prefer a single source of truth.
- Use TypeScript types for prop and context documentation.
- Use TypeScript everywhere.
- Add TSDoc/JSDoc comments for all public functions, hooks, and components.
- Apply atomic design or feature-based structure for React components.
- Prefer
async/awaitfor async operations. - Use React hooks (
useEffect,useMemo,useCallback, custom hooks) for logic reuse. - Write tests for all critical components and API routes.
- Use Jest and React Testing Library.
- Add logs before and after major operations.
- Use meaningful error messages (never just "500 Internal Server Error").
- Handle missing data with explicit UI (
<EmptyState />, messages). - Do not swallow exceptions; always log and handle properly.
- Refactor files >500 lines into smaller modules.
- Use GitHub Actions for CI.
- Keep CI configuration up-to-date.
- Run
make precommitbefore every commit. - Check and improve test coverage (Codecov or equivalent).
- Add tests for every bug fix.
- Integration tests for key Next.js API routes and pages.
- Respect Next.js folder structure:
/pages,/app,/components,/lib,/hooks,/api. - Use Prettier for formatting and ESLint for linting.
- Do not mix tabs and spaces.
- Add empty lines between logical code blocks.
- Use clear and consistent naming (
useFetchUsernotuseFU). - Add TSDoc/JSDoc for components and functions.
- Do not break code indentation.
- Refactor large files.
- Use Context API, Redux, Zustand, or Recoil for state.
- Document and type all Next.js API endpoints.
- Use Prisma or Drizzle for database migrations (if applicable).
- Use validators (zod, yup) for data validation.
- Use Conventional Commits (
feat(agent): add x,fix(agent): bugfix). - Branch names follow ticket or convention.
- PR descriptions must include context, ticket refs, screenshots.
- Always update and check documentation in PR.
- All tests and CI must pass before merge.
| Aspect | Next.js/React |
|---|---|
| Doc props/hooks | TSDoc/JSDoc |
| Routing | /pages, app/ |
| Testing | Jest, RTL |
| Logging | Browser, custom logs |
| Typing | TypeScript |
| DB migrations | Prisma, Drizzle |
| UI state | Context, Redux, ... |
| Error handling | ErrorBoundary, Sentry |
- https://nextjs.org/docs
- https://react.dev
- https://www.typescriptlang.org/docs/handbook/intro.html
- https://testing-library.com/docs/react-testing-library/intro/
- Track issues, ideas, and improvements in
docs/todo.md. - Each significant change must be documented and tested.
- Always prioritize developer and user experience.