Skip to content

code_rules

code_rules returns a concise, actionable set of rules for the current project, scoped to the area you are working in. It is derived from the detected patterns and any rules defined in CLAUDE.md or equivalent config files.

Running code_rules at the start of a task prevents AI agents from falling back to generic patterns that do not match the project.

code_rules(scope="frontend")
code_rules(scope="backend")
code_rules(scope="testing")
code_rules(scope="all")
ParameterTypeDefaultDescription
scope"frontend" | "backend" | "testing" | "all""all"Which rules to return
Frontend rules (12):
- Use Tailwind classes only; no inline styles
- State: Zustand for client state, React Query for server state
- Components go in src/components/, pages in src/app/
- All strings via useTranslations() — no hardcoded copy
- Minimum 44px touch targets on all buttons
Backend rules (8):
- All endpoints must validate input with Zod
- Rate limit with express-rate-limit on all public routes
- Never return raw DB errors to the client
- Use snake_case for DB column names
ApproachTokens
Read CLAUDE.md — full file~8,000
code_rules(scope="frontend")~400

80–90% fewer tokens than loading the full config file.

  • At the start of any frontend, backend, or testing task
  • When you are unsure whether a pattern is idiomatic for the project
  • Before generating new boilerplate code