CLAUDE.md Scope Rules: Stop Claude Code and Cursor Overreaching (Copy-Paste)
Published Oct 27, 2026 · 6 min read
Ask a coding agent for a one-line fix and you sometimes get back a 300-line diff: a new helper nobody asked for, a "tidied up" file next door and a cheerful "Done!" with no tests run. It's common enough that a GitHub repo with a single CLAUDE.md file, which its README says is derived from Andrej Karpathy's observations on LLM coding pitfalls, has passed 200,000 stars. The failure modes it targets are the ones you've probably hit: agents assume instead of asking, write far more code than needed, and change code they weren't asked to touch.
This guide turns those failure modes into five rules you can paste into CLAUDE.md, AGENTS.md or a Cursor project rule, plus the settings that back them up when a rule isn't enough.
Why scope rules work (and where they stop)
Claude Code reads CLAUDE.md at the start of every session, and Cursor adds project rules to the start of the model's context. That makes them the right place for behaviour you want on every task. But Claude Code's docs are clear that CLAUDE.md is context, not enforced configuration, and specific, concise instructions get followed most consistently. So each rule below is written to be checkable, and the last section moves the "never" rules into settings that are actually enforced.
1. Ask before assuming
The most expensive mistake is a confident build on a wrong guess. Don't tell the agent to "ask when unsure", because it's rarely unsure. Tell it when a question is required: when there's more than one reasonable reading, or when the choice changes behaviour, data or a public API. For small, reversible details, let it state its assumption and keep going, or you'll drown in questions.
2. State a plan before editing
A three-line plan costs seconds to read and catches most wrong turns before any code exists. Ask for the files it will change and how it will check the result. In Claude Code you can also press Shift+Tab until the status bar shows plan mode: Claude reads files and proposes a plan but makes no edits until you approve. Planning first also saves usage, because there's less to undo.
3. Ask for the smallest diff that works
Agents love to generalise: a config option for something with one value, an abstraction with one caller. A rule like "write the least code that solves the task" gives you something to point at in review. Pair it with "reuse existing helpers" so it doesn't reinvent the utility that already lives in src/lib/.
4. Don't touch unrelated files
Drive-by refactors are how a bug fix breaks something two folders away. Make the boundary explicit: only edit files the task needs, name any other file before changing it, and report unrelated bugs instead of fixing them. "Don't delete comments or code you don't fully understand" is worth its own line.
5. Verify before claiming done
"Done" should mean tests, lint and type check ran and passed, not that the code looks right. Ask for what it ran, what passed, and a list of every changed file. The file list makes rule 4 easy to check at a glance.
The copy-paste CLAUDE.md block
Paste this near the top of your CLAUDE.md, above your commands and project notes. Rules at the top of a short file are followed more reliably than rules buried in a long one:
## Scope rules (read first)
### Ask before assuming
- If the request has more than one reasonable reading, list them
and ask which one. Don't pick silently.
- If a choice changes behaviour, data or a public API, ask first.
For small, reversible details, state your assumption and go on.
### Plan before editing
- For anything bigger than a one-line fix, reply with a short plan
first: the files you'll change and how you'll check it works.
Wait for an OK before editing.
### Smallest diff that works
- Write the least code that solves the task. No extra features,
options or abstractions nobody asked for.
- Reuse existing helpers and patterns before adding new ones.
- Don't add dependencies without asking.
### Don't touch unrelated code
- Only edit files the task needs. If you need another file, say
which one and why before you change it.
- Don't reformat, rename or "tidy up" code you weren't asked to change.
- Don't delete comments or code you don't fully understand.
- Spotted an unrelated bug? Mention it at the end. Don't fix it.
### Verify before saying done
- Run the tests, linter and type check (see Commands below)
before you say a task is finished.
- Report what you ran and what passed. If you couldn't verify
something, say so plainly.
- Finish with a list of every file you changed.
Then add your real commands underneath, so "run the tests" means something specific:
## Commands
- Test: `pnpm test` · Lint: `pnpm lint` · Types: `pnpm typecheck`
New to CLAUDE.md? Start from our CLAUDE.md template and drop this block in at the top.
Using AGENTS.md instead
If your team uses more than one agent, put the same block in AGENTS.md. Cursor reads AGENTS.md from the project root and subfolders, and recent versions of Claude Code read it when there's no CLAUDE.md. If you have both files, start CLAUDE.md with an import so Claude reads the shared rules:
@AGENTS.md
## Claude Code only
- Use plan mode for changes under src/billing/.
Our AGENTS.md template shows a full shared file.
The Cursor .mdc version
Cursor project rules must be .mdc files in .cursor/rules/; a plain .md file there is ignored. Scope rules apply to every task, so use alwaysApply: true. Save this as .cursor/rules/scope.mdc:
---
description: Scope and verification rules for every task
alwaysApply: true
---
- If a request is ambiguous, list the options and ask. Don't guess.
- For anything bigger than a one-line fix, post a short plan
(files to change, how you'll verify) and wait for an OK.
- Write the smallest diff that solves the task. No extra features,
options or abstractions.
- Only edit files the task needs. Name any other file and why
before changing it.
- Don't reformat, rename or refactor unrelated code. Mention
unrelated bugs instead of fixing them.
- Run the tests, linter and type check before saying done. Report
what you ran and list every file you changed.
Keep framework rules in their own files scoped with globs, as in our Cursor rules examples, so this one stays short.
Back the rules with real guardrails
Rules shape behaviour; they don't block anything. For the things that must never happen, use the parts of Claude Code that enforce: a permissions.deny entry such as Edit(./migrations/**) in .claude/settings.json, or a PreToolUse hook that blocks the call. If the agent still seems to skip your rules, work through our fixes for Claude Code ignoring CLAUDE.md.
Skip the setup
The Claude Code Agent Starter Kit ($39) ships 5 rules-first CLAUDE.md templates, a planner and code-reviewer subagent, 3 safety hooks and 4 skills, all tested together. Using Cursor? The Cursor Rules Pack ($19) has 18 ready-made .mdc rules, including AI agent safety, plus an AGENTS.md template. Get the Starter Kit Get the Cursor Rules Pack
FAQ
How do I stop Claude Code changing code I didn't ask it to touch?
Add a scope rule to CLAUDE.md: only edit files the task needs, list any other file before touching it, and mention unrelated problems instead of fixing them. For folders that must never change, add an Edit deny rule in .claude/settings.json, which Claude Code enforces.
Does Claude Code read AGENTS.md?
Yes. Recent versions of Claude Code read AGENTS.md as project instructions when there is no CLAUDE.md in your working directory or above it. If you have both, put @AGENTS.md at the top of CLAUDE.md so Claude reads the shared rules too.
Should these rules go in an always-apply Cursor rule?
Yes. Scope and verification rules apply to every task, so use a .cursor/rules/*.mdc file with alwaysApply: true. Keep framework-specific rules in separate files scoped with globs.
Will a CLAUDE.md file make the agent ask too many questions?
It can if the rule is vague. Tell it to ask only when a choice would change the result, and to state its assumption and carry on for small, reversible details.