AI Rules Configuration
.cursorrules, CLAUDE.md, and Skills are three complementary, not interchangeable config formats. Sort out what each is good at — and what it isn't — before mixing them. Otherwise you end up writing the same rule three times and nobody on the team will keep them in sync.
If you've never written one, start with Cursor Rules Intro and Claude Code Skills. This page covers how to divide responsibility across the three formats and keep them aligned across a team.
What each format is actually for
| Format | Loading | Granularity | Best for |
|---|---|---|---|
.cursorrules | Loaded fully on Cursor startup | Single project file | Small projects (<500 lines of rules), Cursor-only teams |
.cursor/rules/*.mdc | Auto-injected by glob, or agent-triggered | Multiple files with frontmatter glob | Large projects, load different rules per file pattern |
CLAUDE.md | Loaded by Claude Code on startup, with nested loading from subdirs | Project + user + per-directory | Long-lived architectural rules, domain knowledge |
Skills (~/.claude/skills/) | Triggered on demand, not in default context | Named bundle, SKILL.md + assets | High-frequency but task-specific complex workflows (>200-line SOPs) |
The key difference:
.cursorrulesandCLAUDE.mdare always-on context — write too much and you blow your token budget every session- Skills are lazy-loaded — only read when the AI decides it needs them, so you can park lots of SOPs without polluting context
.cursor/rules/*.mdcsits in between, matching by glob
What goes where
The most common mistake is dumping everything into CLAUDE.md until it's 2,000 lines and burns 5K tokens per session. Better split:
| Rule type | Goes in | Example |
|---|---|---|
| Architectural laws (always enforced) | Top of CLAUDE.md | "no service file over 600 lines", "prefer ObjectId over slug" |
| Code style | .cursorrules or .cursor/rules/style.mdc | naming, import order, tab vs space |
| Domain knowledge | Middle of CLAUDE.md | "users have free/paid/enterprise tiers, perms via RBAC" |
| Complex workflow SOPs (>200 lines) | Skill | deployment flow, data migration, cert generation |
| Stack-specific | .cursor/rules/{stack}.mdc with glob | React rules that only apply to *.tsx |
| Personal preferences | ~/.claude/CLAUDE.md (user-level) | "use bun not npm", "commit messages in Chinese" |
Team sync strategy
Rules only matter if they're committed to git. Three layers, three approaches:
# 1) Project-level — all in
git add .cursorrules .cursor/rules/ CLAUDE.md
git commit -m "chore: update AI rules for new auth pattern"
# 2) Project Skills — committed under .claude/skills/
git add .claude/skills/deploy-prod/
git commit -m "skill: add prod deploy SOP"
# 3) User-level — never committed
# ~/.claude/CLAUDE.md and ~/.claude/skills/ are personal; don't commit
Typical .gitignore additions:
# AI cache + personal settings stay local
.claude/settings.local.json
.cursor/settings.local.json
# But project-level rules MUST be committed:
# !.cursorrules
# !.cursor/rules/
# !CLAUDE.md
# !.claude/skills/
Mandatory review: changes to CLAUDE.md or .cursorrules must go through PR — no direct pushes. These files affect every engineer's AI behavior, equivalent to changing lint config; the team needs to agree.
Real example: how JR Academy layers it
~/.claude/CLAUDE.md # Personal (~50 lines)
└─ "use bun not npm"
└─ "auto-push after commit"
└─ Projects registry
jr-academy-ai/CLAUDE.md # Project laws (~600 lines)
└─ ABSOLUTE RULES (rm policy, git safety)
└─ Service architecture (600-line cap, single responsibility)
└─ ID-First Principle (post-incident learnings)
└─ Anti-Template Content Rule
└─ MongoDB / Auth / Testing constraints
.cursor/rules/frontend.mdc # glob: *.tsx
└─ styled-components rules
└─ z-index conventions
.claude/skills/bootcamp-sync/ # Complex SOP (~400 lines)
└─ SKILL.md: sync curriculum/ → prod
└─ scripts/diff-check.ts
└─ templates/
.claude/skills/lesson-design/
└─ SKILL.md
Result: a typical session loads ~8K of context (the CLAUDE.md); when a deploy or sync is needed, the AI auto-triggers the matching skill and pulls in another 5-10K. About 60% cheaper than putting everything in CLAUDE.md.
Common traps
- Rules written too abstractly — "code should be clean and maintainable" is dead weight; AI can't act on it. Write "split any service file over 600 lines" instead.
- Conflicting rules —
.cursorrulessays "use tabs",CLAUDE.mdsays "4 spaces", AI behavior becomes unpredictable. Audit periodically. - Skill trigger conditions are vague — if
SKILL.mddescription says "helps with code review", the AI will never auto-trigger it. Write "auto-triggers on PR review, takes a PR diff, outputs a 5-category issue list." - Rules go stale — team locked in "use React 17" six months ago, you've since upgraded to React 19, AI still writes legacy patterns. Audit quarterly.
Next
- MCP Development Best Practices — extending AI capabilities into external systems
- AI Rules Continuous Improvement — versioning and iterating on rules
- Claude Code Context Management — controlling token cost of loaded rules
📚 Related resources
❓ Common questions
Open a question to review the practical answer.
Do rule files prevent unauthorized actions?
Rules are context, not enforced permissions. Use effective tool permissions, server-side authorization and observed behavior checks.
When should rules be split?
Keep durable constraints in project rules, current requirements in a task brief and task-specific procedures in a skill. Split by scope, not an arbitrary line count.
How can I validate a rule?
Retest normal, out-of-scope and conflicting scenarios and record actions and errors. Do not claim fixed savings without comparable measurements.