scope
Move rules to where they belong. Frontend conventions apply to frontend files, SQL conventions apply to migrations, infra conventions apply to infra. The agent's attention budget is finite; spend it on what matters.
When to use it
- Multi-stack repo: frontend + backend, app + infra, multiple languages.
- Monorepo with packages of distinct character.
- Rules keep firing where they should not (frontend conventions on a Python script).
CLAUDE.mdis past 200 lines from trying to cover every area.
What it produces
- Cursor:
.cursor/rules/<area>.mdcwith aglobslist. - Copilot:
.github/instructions/<area>.instructions.mdwithapplyTo. - Claude Code / Codex: nested
CLAUDE.md/AGENTS.mdat directory boundaries.
The top-level file shrinks in the same pass. Rules duplicated into scoped files are removed.
How it works
- Map the repo. Globs top-level directories. Notes primary languages and conventions that look different across them.
- Ask which areas need rules. Multi-select with detected candidates:
src/components/,src/api/,db/migrations/,infra/, etc. Plus harnesses. - For each area, gather rules. Sample files, propose 3 to 5 conventions with Preferred / Avoid pairs, confirm.
- Write the scoped files. Same body, different wrappers per harness.
- Reconcile. Top-level file gets leaner. Rules now in scoped files are removed or pointered.
- Verify. Pick one file per scoped area and confirm the right rules apply.
Cursor trigger levels and word budgets
Pick the smallest level that works. Body size must match the trigger; the agent pays a token cost on every match.
| Trigger | Frontmatter | Body budget |
|---|---|---|
| Always Apply | alwaysApply: true, globs: [] | under 200 words |
| Auto-Attached | alwaysApply: false, globs: [...] | 200 to 500 |
| Agent-Requested | alwaysApply: false, description set | 500 to 800 |
| Manual | referenced via @rule-name | no strict cap |
If the body overflows, split into narrower-glob files or move long examples into docs/agents/<area>.md.