Cover for the post “The rules-file template”

Packs

The rules-file template

A CLAUDE.md / .cursor/rules structure that gets followed, the leave-out list, and two tests for whether yours is working. Free, no sign-up.

A rules file is a set of instructions, not documentation. Written as description — "we generally prefer named exports" — it reads as background. Written as instruction — "Use named exports." — it gets followed.

Same content, different mood, materially different output.

The template

# Project rules

## Architecture
- Framework: <name + version>
- Database: <name>, accessed via <client/ORM>
- Styling: <approach>
- Tests: <runner>, located in <where>

## Conventions
- Use <export style>.
- API responses return <shape>.
- Put <kind of file> in <path>.
- Use <library>. Never <the alternative you keep getting>.

## Patterns
- Auth: check with <function> from <path>. Never <the wrong way>.
- Database: import from <path>. Never instantiate a new client.
- Validation: use <library> at <boundary>.

## Departures from defaults
- <convention> — because <one line>. Applies to <scope>, not everywhere.

Every line is an imperative. If a line could be prefixed with "we tend to", rewrite it or delete it.

What earns its place

Include Test
The architecture, in four lines One line each, not a paragraph each
Conventions with a wrong answer Could a reasonable person do it differently and be wrong for your codebase? If both ways are fine, leave it out
Patterns you would re-explain every session You can feel the cost of their absence

What does not

  • History — how the project got here
  • Aspiration — what you intend to migrate to
  • Anything a human colleague needs but the model does not — team structure, who to ask, why the project exists
  • Politeness — "please", "we'd prefer", "where possible"

Rationale is the one exception, and only where a convention departs from the tool's default. One line of why, scoped — a rule with no reason tends to get applied too widely.

This is not a README. Treating it as one is why so many quietly stop working.

The two limits

About 200 lines for CLAUDE.md — Anthropic's own published number, and the stated reason is the one that matters: longer files consume more context and get followed less. 500 lines per rule is Cursor's equivalent.

Either way, you carry the whole file on every turn, whether or not it was relevant to the question. Every line is a line you pay for continuously.

Two tests for whether yours is working

The removal test. Delete a line and see whether anything changes. If nothing does, the line was decoration — it was either never being followed, or the model would have done it anyway.

The first-turn test. Open a fresh thread and ask for something small and conventional. If the output already matches your house style, the file is working. If you add "and use named exports", that line is not landing — and making it more polite will not help.

🔴 The failure mode nobody plans for

A stale rules file is worse than no rules file.

No file means the model guesses, and you can see it guessing. A stale file means it confidently instructs itself to be wrong before you have typed a word, with your authority behind it.

So: when you change a convention, change the file in the same commit. A rules file is part of the codebase, not a note about it.


Where to go next