Skip to main content
KITS

Launch sale: 70% off every kit until 31 December. See the deals

Field notes / Nov 23, 2026 · 6 min

Rules Files for Cursor and Claude Code That Work

The KITS team


A good rules file for Cursor or Claude Code is short, specific and written as commands the agent can check: the stack and versions, the commands to build and test, the smallest-change rule, and what it must never touch. Keep it under about 200 lines, and move anything that applies to only part of the code into scoped rules. A starter you can paste is below.

What is a rules file?

An AI coding agent starts each session knowing nothing about your project. A rules file is plain text it loads at the start so it follows your conventions without being told every time.

For Claude Code, that file is CLAUDE.md. Per Anthropic's Claude Code memory page, as of December 2026, a project file can live at ./CLAUDE.md or ./.claude/CLAUDE.md, and the /init command generates a starting file from your codebase. The page also says Claude Code can read an AGENTS.md file in place of a CLAUDE.md, and that CLAUDE.md files can import other files with @path/to/import.

For Cursor, rules are files in your project that Cursor loads into the agent's context. We could not verify Cursor's current documentation for this post, so check Cursor's own docs for the current folder, file format and rule types before relying on any layout described by us.

How long should a rules file be?

Short. The Claude Code page says, as of December 2026, to target under 200 lines per CLAUDE.md file, because longer files consume more context and reduce adherence. It also says that if two instructions contradict each other, Claude may pick one arbitrarily.

Two practical consequences:

  • Ten clear rules get followed better than forty.
  • Review the file now and then and delete rules that are outdated or conflict.

The same logic applies in any tool. A long, vague file is read less carefully than a short, sharp one.

What belongs in the file?

Things the agent cannot work out from the code, and things it gets wrong if left alone.

  • Stack and versions. "Next.js App Router, React 19, TypeScript strict." Models default to older patterns.
  • Commands. How to build, test, lint and type-check, written out exactly.
  • Conventions. File naming, where things live, which library to use for what.
  • Boundaries. Files and folders it must not touch, such as generated code or migrations.
  • Behaviour. Smallest change that works, no unrequested refactors, no invented APIs.

What to leave out: advice like "write clean code", which gives nothing to check, and long explanations of things the code already shows.

What is a copy-paste starter?

Replace the brackets, and delete lines that do not apply.

# Project rules

Stack: [framework and version], [language], [package manager]. Use only libraries already in package.json unless I approve a new one.

Commands:
- Install: [command]
- Test: [command]
- Lint: [command]
- Type-check: [command]
Run the tests and the type-check before saying a task is done.

Make the smallest change that solves the problem I described, and stay inside it. Don't refactor, rename, reformat or reorder code I didn't ask you to touch. If you notice a bug elsewhere, add one line at the end starting "Also noticed:" instead of changing it.

Give complete code for whatever you change. No placeholders such as "rest of the code here".

Don't invent functions, libraries, flags or settings. If you are not sure something exists in the version we use, say so and tell me how to check, such as the docs page or a command to run.

Don't say code works unless you ran it. If you can't run it, say your answer is untested, and give me one way to check it.

Never touch: [generated files], [migrations folder], [env files]. Never print or commit secrets.

If a request would do something hard to undo (deleting data, rewriting history, changing production), say so first and wait for my confirmation.

These lines are adapted from the coder profile in our free and paid instruction kits, and they target the failures people complain about most: unrequested rewrites, invented APIs and false claims of success.

How do I stop the agent breaking things I did not ask about?

The "smallest change" rule does most of the work. It works because it gives a reason and an alternative: put other observations in one "Also noticed" line instead of acting. You review the diff, and unrequested edits are the hardest ones to spot.

Pair it with these habits:

  • Ask for a plan first on anything touching more than a few files.
  • Commit before a big agent task so you can roll back.
  • Ask for a short note listing the files changed and why.

Should I scope rules to parts of the codebase?

Yes, once the file grows. Rules about React components do not need to load while the agent edits a database script. The Claude Code page describes path-scoped rules under .claude/rules/ that load only when matching files are involved, and recommends moving part-of-the-codebase instructions there. Cursor has its own way of attaching rules to file patterns; read its docs for the current format.

How do I test the rules?

Give the agent a small, safe task and read the diff. Did it stay inside the request? Did it run the tests? Did it claim success without running anything? If a rule is ignored, make it shorter and more specific, move it to the top, and remove any rule that contradicts it.

Is there a ready-made version?

Cursor Rules for Production Stacks ships rule files for a Next.js App Router stack, a TypeScript API and a React with Tailwind UI layer, plus a skill for adapting them to your repo. Claude Code Skills Pack adds reusable skills for review, audits and refactor planning. Check each kit page for what is available now. The behaviour rules above come in the Fix your AI collection, and the builder kits are in the Build with AI collection.

Frequently asked questions

Do I need both CLAUDE.md and Cursor rules?

Only if you use both tools. Keep the shared content in one place if you can. Claude Code can import other files, so one source file can serve more than one tool.

What is AGENTS.md?

A plain file of instructions for coding agents. Per Anthropic's page, Claude Code can read it as project instructions. Other tools may read it too; check each tool's docs.

Why does the agent ignore my rules?

Usually the file is too long, two rules conflict, or the rule is vague. Shorten, make rules checkable, and remove contradictions.

Should the rules say "be a senior engineer"?

It adds little. Concrete rules about commands, boundaries and behaviour change what the agent does.

This note points at