Most weak CLAUDE.md or .cursorrules files fail for the same reason: they say vague things like "write clean code" instead of specifying exact commands, directory boundaries, and forbidden anti-patterns.
Generate & Download Custom Rules Files
Export CLAUDE.md, .cursorrules, .cursor/rules/project.mdc, or AGENTS.md for your stack
4 Sections Every Project Rules File Needs
- Exact Verify Commands: Tell the agent how to check types, lint, and tests (e.g.,
npm run typecheck && npm test). - Framework Boundaries: E.g. "Use Next.js App Router Server Components by default; never import secrets in client modules."
- Forbidden Shortcuts: Reject silent empty catches, raw SQL string concatenation, and unverified test claims.
- Brief Length (< 80 lines): Put deep task-specific playbooks inside downloadable
SKILL.mdpacks instead.
Starter Next.js + TypeScript CLAUDE.md Template
# Project Rules
## Verify Commands
- Run before finishing: `pnpm typecheck && pnpm lint && pnpm test`
## Architecture & Security
- Default to React Server Components; add `'use client'` only on leaf widgets.
- Validate all API inputs with Zod before database writes.
- Keep diffs scoped to the requested task and preserve unrelated comments.
Frequently Asked Questions
How long should CLAUDE.md or .cursorrules be?
Keep always-loaded files under 80 lines (~500–900 tokens). Check size quickly with the LLM Token Counter.
Should I use .cursorrules or .cursor/rules/*.mdc?
Use .cursor/rules/*.mdc when scoping rules by file extension (such as **/*.tsx vs **/*.sql); keep a concise root AGENTS.md or CLAUDE.md for cross-agent basics.