agentleFS
madebyarismadebyaris/cursor-composer-rules/.cursor/rules/composer-coding-excellence.mdc

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

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
  1. Distinctive:

    Use whenever you are writing or modifying source, tests, types, or build files.

    line 8
  2. Very specific:

    If the file uses camelCase, don't introduce snake_case.

    line 24
  3. Distinctive:

    If errors are returned as values, don't throw exceptions.

    line 25
  4. Distinctive:

    If imports are grouped, group yours.

    line 26
  5. Distinctive:

    If functions are pure, keep yours pure.

    line 27
  6. Distinctive:

    If the project tests with framework X, don't introduce framework Y.

    line 28
  7. Very specific:

    If the project has a logger, use it — don't console.log.

    line 29
  8. Distinctive:

    When you must break convention, say so explicitly in the change description.

    line 31
  9. Distinctive:

    If the idiom is not in the repo, one primary lookup via composer-senior-practices, then write it.

    line 40
  10. Distinctive:

    Default to matching the file you are editing.

    line 44
  11. Distinctive:

    No silent reformat of untouched files.

    line 58
  12. Distinctive:

    No dependency or framework swaps for style alone.

    line 59
  13. Distinctive:

    When considering whether project style should improve, load composer-senior-practices / the senior-practices skill — do not invent …

    line 62
  14. Distinctive:

    Don't reformat untouched code.

    line 67
  15. Distinctive:

    Don't rename things that weren't part of the request.

    line 68
  16. Distinctive:

    Don't refactor adjacent functions "while you're there."

    line 69
  17. Distinctive:

    Don't reorder imports unless that's the change.

    line 70
  18. Distinctive:

    Don't bump dependencies unless required.

    line 71
  19. Distinctive:

    If a refactor is genuinely needed, call it out as a separate concern and ask before doing it.

    line 73
  20. Distinctive:

    Write comments that explain why or what is non-obvious, not what the code already says.

    line 77
  21. Very specific:

    Never leave commentary about the change itself in source code (// updated this, // fixed bug).

    line 94
  22. Distinctive:

    Don't invent function names, type names, library APIs, or config options.

    line 98
  23. Distinctive:

    Don't reference files, modules, or functions that don't exist.

    line 99
  24. Distinctive:

    Don't make up command output, test results, or error messages.

    line 100
  25. Distinctive:

    Don't paste hashes, IDs, or "example" values that look real but are invented.

    line 101
  26. Distinctive:

    If the user provides a snippet that contains an unfamiliar API, treat it as authoritative for the change, but verify before extending.

    line 103
  27. Very specific:

    Don't suppress type errors with casts or // @ts-ignore to make a build green.

    line 108
  28. Very specific:

    Don't silently swallow errors with empty catch blocks.

    line 110
  29. Distinctive:

    If the change is bug-fix-shaped, write a failing test first when feasible.

    line 114
  30. Distinctive:

    Test the behavior, not the implementation.

    line 116
  31. Very specific:

    Don't write tests that pass trivially (expect(true).toBe(true)) just to raise coverage.

    line 117
  32. Distinctive:

    Don't delete or weaken a failing test to make CI green.

    line 118
  33. Distinctive:

    Only refactor when the task requires it or when the user asks for it.

    line 124
  34. Distinctive:

    Before a non-trivial refactor: confirm tests cover the affected behavior.

    line 125
  35. Distinctive:

    Keep refactor commits separate from behavior-change commits.

    line 126
  36. Distinctive:

    Stop the refactor immediately if you discover the scope is larger than you thought.

    line 127
  37. Distinctive:

    Don't optimize without measuring.

    line 131
  38. Distinctive:

    Don't introduce secrets, tokens, or credentials in source.

    line 132
  39. Distinctive:

    Don't write SQL by string concatenation.

    line 133
  40. Distinctive:

    Don't disable security middleware "for testing" without a clear path back.

    line 134
  41. Distinctive:

    Don't add a dependency to solve a 10-line problem.

    line 138
  42. Distinctive:

    Use the latest stable version unless the project pins to something older for a reason — check first.

    line 139
  43. Distinctive:

    Don't bump versions across major boundaries casually.

    line 140
  44. Distinctive:

    Run the lockfile update through the project's package manager, not by hand.

    line 141

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
composer-coding-excellence.mdc
---
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**.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.