agentleFS
golid-aigolid-ai/golid/.cursor/rules/write-rules.mdc

golid / rules

Cursor rule40 starsChanged 6 months agoMITView on GitHub

How to write, update, and maintain Cursor rules — use when creating a new rule or updating an existing one

The file

We split this write-rules.mdc into the rules it gives an agent

8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep examples minimal — one BAD, one GOOD, showing the exact mistake and fix.

    line 27
  2. Distinctive:

    When a code change invalidates or reveals a gap in an existing rule, update the rule in the same pass — not as a follow-up task.

    line 42
  3. Distinctive:

    Update triggers (only these — don't edit rules speculatively):

    line 46
  4. Distinctive:

    Keep rule edits minimal — update the specific line or section affected, don't rewrite the entire rule.

    line 58
  5. Distinctive:

    If any of the three is vague, keep the guidance in a reference doc or plan until the activation moment is clearer.

    line 71
  6. Distinctive:

    alwaysApply: only for universal guardrails — every line costs context on every interaction, so this is reserved for codebase-standards and …

    line 83
  7. Very specific:

    When adding a new workflow rule, add it to the Rule Index in codebase-standards.mdc.

    line 89
  8. Very specific:

    Run docs/rules-health.md quarterly, or whenever any rule crosses 150 lines.

    line 100

≈ “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
write-rules.mdc
---
description: "How to write, update, and maintain Cursor rules — use when creating a new rule or updating an existing one"
alwaysApply: false
---

# Writing Cursor Rules

> **Thesis:** Every rule opens with a thesis. The thesis is the contract —
> everything below it is the implementation.

## Structure

1. **Thesis (required)** — one sentence after the heading. States what the rule
   enforces and why. This is the most important line — a thesis enables the AI
   to generalize to novel situations; a pointer only enables pattern-matching.

2. **Refrain (optional)** — a short verb-driven phrase that captures the rule's
   rhythm. Only add one when the rule describes a natural action sequence.
   Good: `Validate → Authorize → Execute → Respond` (verbs with momentum).
   Bad: `Config → Env → Script → Constructor` (nouns — a process label, not
   a refrain).

3. **Reference files** — "Follow the established patterns in X" goes here,
   not in the thesis. The thesis says _what_; references say _where_.

4. **Sections** — BAD/GOOD examples for the highest-consequence patterns.
   Keep examples minimal — one BAD, one GOOD, showing the exact mistake and fix.

## When to Create a New Rule

- A pattern has been explained 3+ times across conversations
- A bug was caused by violating a convention that isn't written down
- A new file category has no glob coverage

## When to Extend an Existing Rule

- The new guidance applies to the same file glob
- It's a sub-pattern of an existing rule's thesis

## Updating Rules During Execution

When a code change invalidates or reveals a gap in an existing rule, update the
rule in the same pass — not as a follow-up task. Stale rules are worse than
missing rules because they actively mislead.

Update triggers (only these — don't edit rules speculatively):

- Bug fix exposed an unwritten convention → add to the relevant domain rule
- Refactor moved/renamed files referenced by a rule → update the references
- New pattern discovered (naming conflict, type safety convention) → add to
  the rule covering that file category
- Audit finding that should be enforced going forward → add to audit checklist
  AND the relevant domain rule
- A repeated implementation miss exposes a workflow gap → update the workflow
  rule that owns the missed step, not just the local domain rule. Example:
  missed OpenAPI/spec/frontend type sync belongs in `slice-and-ship` closeout.

Keep rule edits minimal — update the specific line or section affected, don't
rewrite the entire rule. The goal is accuracy, not polish.

For nontrivial workflow guidance, identify three things before adding or
expanding the rule:

- **Trigger** — the exact task, file glob, or failure signal that should activate
  the guidance.
- **Cost** — whether the guidance adds always-on context, auto-loaded glob
  context, or description-triggered reading.
- **Protected failure** — the real bug, audit finding, or repeated miss this
  guidance prevents.

If any of the three is vague, keep the guidance in a reference doc or plan until
the activation moment is clearer.

## Naming

`{domain}-{concern}.mdc` — e.g., `go-service`, `frontend-forms`, `write-tests`.
Workflow rules use verb phrases: `plan-feature`, `document-module`, `audit-bugs`.

## Activation

- **Glob-triggered** for domain rules (fires when editing matching files)
- **Description-triggered** for workflow rules (fires when the task matches)
- **alwaysApply** only for universal guardrails — every line costs context on
  every interaction, so this is reserved for codebase-standards and
  parallel-subagents

## Rule Index Maintenance

When adding a new workflow rule, add it to the Rule Index in
`codebase-standards.mdc`. When renaming or removing a rule, update the index.
Stale index entries mislead the AI about what rules exist.

## Size

Aim for 40-80 lines of content (excluding frontmatter). Over 120 lines suggests
the rule covers two concerns and should be split.

## Rule Health

Run `docs/rules-health.md` quarterly, or whenever any rule crosses 150 lines.
The audit is pruning-oriented: prefer deleting, moving, or narrowing guidance
before adding new rules.

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.