⌨️

Cursor Project Rules Generator

Writes a project rules file from your actual codebase conventions rather than generic best practices.

⌨️ Cursor Advanced Cursor Claude

The prompt

Write a Cursor project rules file for this codebase. Derive the rules from what the code actually does, not from general best practice — a rule that contradicts the surrounding code makes the assistant worse, not better.

**1. Observe first**
From the files I give you, state what you can actually determine:
- Language, framework and version
- Module system, import style and path aliases in use
- Naming conventions, separately for files, components, functions and constants
- Formatting: indent width, quote style, semicolons, trailing commas
- How errors are handled, how state is managed, how things are tested
- Where each kind of file lives

Mark anything you are inferring from one or two examples as uncertain.

**2. Write the rules**
Grouped and specific. Each rule should be checkable — a reviewer can say whether a diff follows it. Prefer "co-locate tests as name.test.ts beside the source" over "write good tests".

Include a **Do not** section, which is where most of the value is: patterns present in the ecosystem but deliberately absent here, dependencies not to reach for, directories not to touch, and anything generated that must not be hand-edited.

**3. Note the conflicts**
Where the codebase is internally inconsistent, say so and ask which convention to encode rather than silently picking the more common one.

Keep it under 100 lines. A rules file long enough to crowd the context window stops being read.

---
Representative files (a component, a test, a config, a module entry point):
[PASTE 3-5 FILES HERE]

Replace everything in [SQUARE BRACKETS] before you run it. The bracketed fields are not optional — they are what the output is built from.

Why this prompt is built this way

Where the system prompt above is a good generic ruleset you fill in, this one derives the rules from your actual code — and the opening line explains why that matters: a rule that contradicts the surrounding code makes the assistant worse, not better. An assistant told to use single quotes in a codebase that uses double quotes produces diffs that fight the formatter on every save.

Section 1 separating observation from rule-writing is what keeps it honest. Asking the model to first state what it can actually determine from the files you pasted, and to mark anything inferred from one or two examples as uncertain, prevents a single file's accident from being enshrined as a project-wide convention.

The Do not section is correctly identified as where most of the value sits. Positive conventions are partly discoverable from reading code; the absences are not. That the project deliberately avoids a popular library, that a directory is generated and must never be hand-edited, that a pattern common in the ecosystem was rejected here — none of that is visible in the source, and all of it is what an assistant gets wrong.

Section 3 asking about internal inconsistencies rather than silently picking the majority convention is the right behaviour: when a codebase does something two ways, that is a decision for you, and an assistant quietly standardising on the more common one may be standardising on the older one.

The 100-line limit is not cosmetic. Rules occupy the same context window as the code being edited.

What to use it for

  • Setting up Cursor on an existing project
  • Onboarding contributors
  • Encoding review feedback once
  • Monorepo per-package rules

Adapting it to your situation

  • Paste a test file and a config file, not only application code. Conventions are far more visible in those, and they are what people omit.
  • Include your ESLint or Prettier config directly, so formatting rules are read rather than inferred.
  • Answer the section 3 questions rather than ignoring them — that is the output asking you to make a decision it correctly refused to make.
  • Regenerate after a major migration. Rules derived from the old stack are worse than none.

Where this goes wrong

Five files is a sample, not a survey. Rules derived from them may not hold across a large codebase, which is exactly why the uncertainty markers exist — read them rather than deleting them for tidiness.

Resist letting the file grow. Every line added competes with your actual code for context, and a rules file long enough to crowd the window stops being applied properly.

Which model to run it on

Cursor can read the repository itself, which makes section 1 substantially more accurate than pasting files into a chat. Claude works well when you paste a representative selection manually.

Practical tips

Paste real files, including a test and a config — conventions show up in those more clearly than in application code. The length limit is not cosmetic: rules compete with your actual code for context, and a 300-line rules file means less room for the thing you are editing.