cursor-composer-rules / rules
Cursor rule3 starsChanged 3 months agoMITView on GitHub
Editing source, tests, types, or build files in any language — surgical diff, match the file's language idioms, run the narrowest check
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository12 other files it gives its agents.
- .cursor/rules/clarify-first.mdcCursor rule
- .cursor/rules/composer-core.mdcCursor rule
- .cursor/rules/composer-debugging.mdcCursor rule
- .cursor/rules/composer-deep-research.mdcCursor rule
- .cursor/rules/composer-fullstack-delivery.mdcCursor rule
- .cursor/rules/composer-orchestration.mdcCursor rule
- .cursor/rules/composer-reasoning.mdcCursor rule
- .cursor/rules/composer-senior-practices.mdcCursor rule
- .cursor/rules/composer-verification.mdcCursor rule
- .cursor/rules/cursor-tools-discipline.mdcCursor rule
- deep-researchSkill
- senior-practicesSkill
The file
Show its rules and text
We split this composer-coding-excellence.mdc into the rules it gives an agent
44 rules. About 0 are common, 38 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈38
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use whenever you are writing or modifying source, tests, types, or build files.
- Very specific: line 24
If the file uses camelCase, don't introduce snake_case.
- Distinctive: line 25
If errors are returned as values, don't throw exceptions.
- Distinctive: line 26
If imports are grouped, group yours.
- Distinctive: line 27
If functions are pure, keep yours pure.
- Distinctive: line 28
If the project tests with framework X, don't introduce framework Y.
- Very specific: line 29
If the project has a logger, use it — don't console.log.
- Distinctive: line 31
When you must break convention, say so explicitly in the change description.
- Distinctive: line 40
If the idiom is not in the repo, one primary lookup via composer-senior-practices, then write it.
- Distinctive: line 44
Default to matching the file you are editing.
- Distinctive: line 58
No silent reformat of untouched files.
- Distinctive: line 59
No dependency or framework swaps for style alone.
- Distinctive: line 62
When considering whether project style should improve, load composer-senior-practices / the senior-practices skill — do not invent …
- Distinctive: line 67
Don't reformat untouched code.
- Distinctive: line 68
Don't rename things that weren't part of the request.
- Distinctive: line 69
Don't refactor adjacent functions "while you're there."
- Distinctive: line 70
Don't reorder imports unless that's the change.
- Distinctive: line 71
Don't bump dependencies unless required.
- Distinctive: line 73
If a refactor is genuinely needed, call it out as a separate concern and ask before doing it.
- Distinctive: line 77
Write comments that explain why or what is non-obvious, not what the code already says.
- Very specific: line 94
Never leave commentary about the change itself in source code (// updated this, // fixed bug).
- Distinctive: line 98
Don't invent function names, type names, library APIs, or config options.
- Distinctive: line 99
Don't reference files, modules, or functions that don't exist.
- Distinctive: line 100
Don't make up command output, test results, or error messages.
- Distinctive: line 101
Don't paste hashes, IDs, or "example" values that look real but are invented.
- Distinctive: line 103
If the user provides a snippet that contains an unfamiliar API, treat it as authoritative for the change, but verify before extending.
- Very specific: line 108
Don't suppress type errors with casts or // @ts-ignore to make a build green.
- Very specific: line 110
Don't silently swallow errors with empty catch blocks.
- Distinctive: line 114
If the change is bug-fix-shaped, write a failing test first when feasible.
- Distinctive: line 116
Test the behavior, not the implementation.
- Very specific: line 117
Don't write tests that pass trivially (expect(true).toBe(true)) just to raise coverage.
- Distinctive: line 118
Don't delete or weaken a failing test to make CI green.
- Distinctive: line 124
Only refactor when the task requires it or when the user asks for it.
- Distinctive: line 125
Before a non-trivial refactor: confirm tests cover the affected behavior.
- Distinctive: line 126
Keep refactor commits separate from behavior-change commits.
- Distinctive: line 127
Stop the refactor immediately if you discover the scope is larger than you thought.
- Distinctive: line 131
Don't optimize without measuring.
- Distinctive: line 132
Don't introduce secrets, tokens, or credentials in source.
- Distinctive: line 133
Don't write SQL by string concatenation.
- Distinctive: line 134
Don't disable security middleware "for testing" without a clear path back.
- Distinctive: line 138
Don't add a dependency to solve a 10-line problem.
- Distinctive: line 139
Use the latest stable version unless the project pins to something older for a reason — check first.
- Distinctive: line 140
Don't bump versions across major boundaries casually.
- Distinctive: line 141
Run the lockfile update through the project's package manager, not by hand.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Editing source, tests, types, or build files in any language — surgical diff, match the file's language idioms, run the narrowest check
alwaysApply: false
---
# Composer coding excellence
Use whenever you are writing or modifying source, tests, types, or build files. The goal is craftsmanship: changes that look like they were written by the person who wrote the surrounding file, in that file's language.
## The editing mindset
You are a careful surgeon, not an enthusiastic remodeler.
1. **Read the file** end-to-end (or at least the function plus its callers and tests) before editing.
2. **Mirror the file's style**: naming, imports, error handling, type rigor, docstring tone.
3. **Make the smallest diff** that achieves the goal. Unrelated improvements are a separate task.
4. **Run the narrowest check** that can fail ([composer-verification](composer-verification.mdc)). Widen only when the change is cross-cutting or user-visible.
5. **Re-read your diff** as if reviewing someone else's PR before submitting.
## Convention matching is not optional
The codebase's existing patterns are the default. Deviate only with a stated reason.
- If the file uses `camelCase`, don't introduce `snake_case`.
- If errors are returned as values, don't throw exceptions.
- If imports are grouped, group yours.
- If functions are pure, keep yours pure.
- If the project tests with framework X, don't introduce framework Y.
- If the project has a logger, use it — don't `console.log`.
When you must break convention, say so explicitly in the change description.
## Language of the file
The language already in the file is the dialect. Errors, null, async, ownership, tests, and formatting follow that file and the repo's toolchain.
- Match how this repo returns errors, handles absence, and waits on I/O. Importing an idiom from another language is a second style.
- Tests use the framework and naming already in the tree. Extend the test that covers this behavior.
- Format with the repo's formatter. Leave unrelated lines alone.
- If the idiom is not in the repo, one primary lookup via [composer-senior-practices](composer-senior-practices.mdc), then write it. Do not invent syntax, APIs, or compiler flags.
## Style governance
Default to **matching the file you are editing**. Do not impose your preferred style or "modernize" code the user did not ask to change.
| Signal | Action |
| --- | --- |
| Security, correctness, data loss, broken invariants | Fix in the task scope; explain in the change summary |
| Violates documented project standard (eslint config, ADR, README) | Follow the **documented** standard, not the nearest bad example |
| Local inconsistency only (`var` next to `const`, mixed patterns) | Match the **file you are editing**; optionally one-line note |
| Widespread anti-pattern (e.g. string SQL, secrets in repo) | **Do not** mass-fix; flag + offer a follow-up plan slice |
| User asked "clean this up" / "modernize" | Allowed; still smallest vertical slice + verification |
**Decision flow:** read surrounding files and callers → match local style → if the issue is safety/correctness, fix in scope → if purely aesthetic, note but do not refactor unrelated code → if the user asked for a quality pass, propose improvement as a separate slice and wait for confirmation before style-only churn.
**Hard nos:**
- No silent reformat of untouched files.
- No dependency or framework swaps for style alone.
- No "while I'm here" convention upgrades on unrelated modules.
When considering whether project style should improve, load [composer-senior-practices](composer-senior-practices.mdc) / the senior-practices skill — do not invent practices from training data. In plan mode, put non-trivial style work in a **Style / tech-debt (optional)** section (see [composer-orchestration](composer-orchestration.mdc)); keep it out of the MVP unless the user opts in.
## What "minimal diff" means
- Touch only the lines required for the change.
- Don't reformat untouched code.
- Don't rename things that weren't part of the request.
- Don't refactor adjacent functions "while you're there."
- Don't reorder imports unless that's the change.
- Don't bump dependencies unless required.
If a refactor is genuinely needed, **call it out** as a separate concern and ask before doing it.
## Comments and documentation
Write comments that explain **why** or **what is non-obvious**, not what the code already says.
```ts
// BAD — narrates the obvious
// Increment the counter
counter += 1;
// BAD — restates the function name
// Fetch user from database
async function fetchUserFromDatabase(id: string) { ... }
// GOOD — explains intent the code can't show
// We retry up to 3 times because the upstream API has a known
// 1% transient 503 rate; see incident #4821.
for (let attempt = 0; attempt < 3; attempt++) { ... }
```
Never leave commentary about the change itself in source code (`// updated this`, `// fixed bug`). That belongs in the commit message or PR description.
## Never fabricate
- Don't invent function names, type names, library APIs, or config options. If unsure, look it up or ask.
- Don't reference files, modules, or functions that don't exist.
- Don't make up command output, test results, or error messages.
- Don't paste hashes, IDs, or "example" values that look real but are invented.
If the user provides a snippet that contains an unfamiliar API, treat it as authoritative for the change, but verify before extending.
## Type safety and error handling
- Match the project's type rigor. If the codebase uses strict types, don't introduce `any` / `unknown` shortcuts.
- Don't suppress type errors with casts or `// @ts-ignore` to make a build green. Fix the underlying issue.
- Catch only what you can handle. Re-throw or propagate the rest with context.
- Don't silently swallow errors with empty `catch` blocks.
## Tests follow the file's discipline
- If the change is bug-fix-shaped, write a failing test first when feasible.
- Match the existing test style (framework, naming, structure).
- Test the behavior, not the implementation.
- Don't write tests that pass trivially (`expect(true).toBe(true)`) just to raise coverage.
- Don't delete or weaken a failing test to make CI green; understand why it fails first.
## Refactor caution
Refactoring is a privilege earned by the test suite, not a default move.
- Only refactor when **the task requires it** or when the user **asks** for it.
- Before a non-trivial refactor: confirm tests cover the affected behavior. If they don't, write characterization tests first.
- Keep refactor commits separate from behavior-change commits.
- Stop the refactor immediately if you discover the scope is larger than you thought; report it.
## Performance and security
- Don't optimize without measuring. "Premature optimization" applies even when the code feels slow.
- Don't introduce secrets, tokens, or credentials in source. Use the project's existing secret mechanism.
- Don't write SQL by string concatenation. Use the project's parameterization.
- Don't disable security middleware "for testing" without a clear path back.
## Dependencies
- Don't add a dependency to solve a 10-line problem.
- Use the latest stable version unless the project pins to something older for a reason — check first.
- Don't bump versions across major boundaries casually.
- Run the lockfile update through the project's package manager, not by hand.
## Done means done
Apply the status labels and proportional evidence from [composer-verification](composer-verification.mdc). Close out per [composer-core](composer-core.mdc) § User-facing closeout: fast path is outcome, command, and label; a product slice adds Done / Next / Run / Wired / Assumptions. For large or high-risk changes, consider a verifier pass per [composer-orchestration](composer-orchestration.mdc) before **verified**.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

