15 community-ranked rules
Use TypeScript strict mode with `strict: true` in `tsconfig.json` — enables `strictNullChecks`, `noImplicitAny`, and other safety checks.
This belongs in tsconfig.json (`strict: true`), not in agent instructions.
Write rules for yourself that prevent the same mistake
This belongs in automated testing or linting pipelines, not in agent instructions.
For TypeScript: Only write Vitest tests when resolving a specific user issue or upon explicit request.
Use Google-style JSDoc docstrings for every public module, class, function, and method.
Documentation formatting should be enforced by static analysis tools like eslint-plugin-jsdoc rather than relying on AI instructions.
Use discriminated unions for state management over boolean flags.
Saving the agent time by explicitly enforcing a TypeScript best practice for state management that requires code pattern recognition across files.
Use plan mode for verification steps, not just building
Adds minimal value over the 0922494eee667d5d rule as it restates plan mode use without distinct actionable guidance.
Validate all external inputs at system boundaries. Trust nothing from users, APIs, or files.
Saves time by specifying all three untrusted input sources (users, APIs, files) as requiring validation at system boundaries.
Avoid `any` — use `unknown` with type guards when the type is truly unknown.
Avoiding `any` belongs in an ESLint (@typescript-eslint/no-explicit-any) or Biome (typescript/noExplicitAny) rule instead.
Design a minimal, intuitive public API. Every exported symbol is a commitment — keep the surface area small.
Avoid N+1 query patterns — use batch loading, JOINs, or DataLoader patterns.
Prefer small, focused functions under 30 lines. Extract helpers when logic grows.
Saving the agent time by explicitly stating a specific function length preference (under 30 lines) that requires inferring from code patterns otherwise.
Use `readonly` for arrays and properties that should not be mutated.
Saving the agent time on consistently applying TypeScript immutability best practices without needing to infer from scattered code examples.
Use `React.FC` sparingly — prefer explicit return types: `function Card({ title }: Props): React.ReactElement`. Use generic components: `function List<T>({ items, renderItem }: ListProps<T>)`.
If a function can fail, return a discriminated union (`{ ok: true; data: T } | { ok: false; error: E }`) instead of throwing — callers are forced to handle both cases.
Write E2E tests for critical user journeys: signup, login, checkout, core workflows.
Have a rule that helps your AI coding agent? Share it with the community.
Suggest a Rule