This Codebase Is Yours: Ownership Rules for Coding Agents
Rules-file lines that tell Claude Code, Codex, or Cursor it owns the code, so it edits and removes code instead of bolting on duplicate functions and wrappers.
Added · Updated
Add this section near the top of AGENTS.md (or CLAUDE.md / .cursor/rules). Edit the bracketed parts. ## You own this codebase This is your codebase as much as mine. Work on it the way a senior engineer who will maintain it for years would. - Before writing a new function, component, or helper, search the repo for one that already does the job. Reuse or extend it. Say which file you checked. - Change existing code in place. Do not add a wrapper, a "v2" copy, or a parallel code path to avoid touching the original. - When your change makes code unused, delete it in the same change: old functions, dead imports, stale flags, commented-out blocks. - Keep one way of doing each thing. If you find two, tell me and propose which one to keep. - Fix the cause, not the symptom. No try/except or `?.` added only to make an error disappear. - If a fix needs a larger refactor than the task, stop and describe it in 3-5 lines instead of half-doing it. ## Limits on ownership Ownership does not mean permission for everything: - Never touch: [secrets/.env files, migrations already run in production, deploy config, billing code]. - Ask before: adding a dependency, changing a public API, deleting a file over [200] lines, or renaming anything used outside this repo. - Stay inside the task. Note unrelated problems in a "Noticed" list at the end; don't fix them unasked. ## End of every task Report: files changed, code deleted (with line counts), anything you found duplicated, and the command you ran to verify it works.
How to use it
- Click Copy template.
- Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
- Replace the [BRACKETED] parts with your details.
Pairs well with: AI Agent Guardrails Checklist: Prompt Rules vs. Tool Permissions
FAQ
Why tell an AI coding agent the codebase is its own?
Without ownership framing, agents tend to play it safe: they add new functions next to old ones, wrap code instead of changing it, and leave dead code behind. Telling the agent it owns and maintains the code, and spelling out what that means, gets it to reuse, edit in place, and clean up.
Won't this make the agent change too much?
It can, which is why the template pairs ownership with hard limits: a never-touch list, an ask-before list, and a rule to stay inside the task and only note unrelated problems. Real limits on dangerous actions still belong in tool permissions, not just the rules file.
Where do I put these rules?
In the root AGENTS.md if you use several agents, with CLAUDE.md importing it via @AGENTS.md. For Cursor, put it in a .cursor/rules/*.mdc file with alwaysApply: true.
How do I stop the agent creating duplicate functions?
Make searching first a written rule, ask it to name the file it checked, and ask for a list of duplicates found at the end of each task. That turns a vague hope into a step you can see in its report.
Does owning the code mean the agent can clean up anything it sees?
No. It cleans up what its own change touched or made unused, and lists everything else for a separate task. Pair these rules with minimal diff rules to keep each change small, and with check-current-docs rules so new code matches the library versions you actually have installed.
Get 3 new templates every week
Free. Unsubscribe anytime.Related templates
AGENTS.md Starter Template for Claude Code, Codex & Cursor
Lean CLAUDE.md: Trim a Bloated Rules File to 40 Lines
Safe Refactor Prompt
Minimal Diff Rules: Stop AI Agents Rewriting Unrelated Code
Check Current Docs First: Stop Agents Using Outdated APIs
Browse all Coding & Cursor Rules templates