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.md is past 200 lines from trying to cover every area.

What it produces

  • Cursor: .cursor/rules/<area>.mdc with a globs list.
  • Copilot: .github/instructions/<area>.instructions.md with applyTo.
  • Claude Code / Codex: nested CLAUDE.md / AGENTS.md at directory boundaries.

The top-level file shrinks in the same pass. Rules duplicated into scoped files are removed.

How it works

  1. Map the repo. Globs top-level directories. Notes primary languages and conventions that look different across them.
  2. Ask which areas need rules. Multi-select with detected candidates: src/components/, src/api/, db/migrations/, infra/, etc. Plus harnesses.
  3. For each area, gather rules. Sample files, propose 3 to 5 conventions with Preferred / Avoid pairs, confirm.
  4. Write the scoped files. Same body, different wrappers per harness.
  5. Reconcile. Top-level file gets leaner. Rules now in scoped files are removed or pointered.
  6. 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.

TriggerFrontmatterBody budget
Always ApplyalwaysApply: true, globs: []under 200 words
Auto-AttachedalwaysApply: false, globs: [...]200 to 500
Agent-RequestedalwaysApply: false, description set500 to 800
Manualreferenced via @rule-nameno strict cap

If the body overflows, split into narrower-glob files or move long examples into docs/agents/<area>.md.