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
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 repository44 other files it gives its agents.
- .cursor/rules/audit-bugs.mdcCursor rule
- .cursor/rules/audit-codebase.mdcCursor rule
- .cursor/rules/ci-workflow.mdcCursor rule
- .cursor/rules/codebase-standards.mdcCursor rule
- .cursor/rules/common-commands.mdcCursor rule
- .cursor/rules/deploy-infra.mdcCursor rule
- .cursor/rules/document-module.mdcCursor rule
- .cursor/rules/dynamic-image-endpoints.mdcCursor rule
- .cursor/rules/dynamic-image-http.mdcCursor rule
- .cursor/rules/external-api.mdcCursor rule
- .cursor/rules/feature-flags.mdcCursor rule
- .cursor/rules/frontend-components-advanced.mdcCursor rule
- .cursor/rules/frontend-components.mdcCursor rule
- .cursor/rules/frontend-forms.mdcCursor rule
- .cursor/rules/frontend-lib.mdcCursor rule
- .cursor/rules/git-commits.mdcCursor rule
- .cursor/rules/go-handler.mdcCursor rule
- .cursor/rules/go-service-errors.mdcCursor rule
- .cursor/rules/go-service.mdcCursor rule
- .cursor/rules/iteration-surface.mdcCursor rule
- .cursor/rules/job-queue.mdcCursor rule
- .cursor/rules/observability.mdcCursor rule
- .cursor/rules/openapi.mdcCursor rule
- .cursor/rules/parallel-subagents.mdcCursor rule
- .cursor/rules/plan-execution-loop.mdcCursor rule
- .cursor/rules/plan-feature-execution.mdcCursor rule
- .cursor/rules/plan-feature.mdcCursor rule
- .cursor/rules/plan-infra.mdcCursor rule
- .cursor/rules/planning-standards.mdcCursor rule
- .cursor/rules/refactor-large-files.mdcCursor rule
- .cursor/rules/rename-tool.mdcCursor rule
- .cursor/rules/seed-data.mdcCursor rule
- .cursor/rules/slice-and-ship.mdcCursor rule
- .cursor/rules/solidjs-data-fetching.mdcCursor rule
- .cursor/rules/solidjs-pages.mdcCursor rule
- .cursor/rules/solidstart-routing.mdcCursor rule
- .cursor/rules/sql-migrations.mdcCursor rule
- .cursor/rules/sse-realtime.mdcCursor rule
- .cursor/rules/workflow-routing.mdcCursor rule
- .cursor/rules/write-tests-e2e.mdcCursor rule
- .cursor/rules/write-tests-frontend.mdcCursor rule
- .cursor/rules/write-tests-frontend-workflow.mdcCursor rule
- .cursor/rules/write-tests.mdcCursor rule
- .cursor/rules/write-tests-planning.mdcCursor rule
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
- Distinctive: line 27
Keep examples minimal — one BAD, one GOOD, showing the exact mistake and fix.
- Distinctive: line 42
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.
- Distinctive: line 46
Update triggers (only these — don't edit rules speculatively):
- Distinctive: line 58
Keep rule edits minimal — update the specific line or section affected, don't rewrite the entire rule.
- Distinctive: line 71
If any of the three is vague, keep the guidance in a reference doc or plan until the activation moment is clearer.
- Distinctive: line 83
alwaysApply: only for universal guardrails — every line costs context on every interaction, so this is reserved for codebase-standards and …
- Very specific: line 89
When adding a new workflow rule, add it to the Rule Index in codebase-standards.mdc.
- Very specific: line 100
Run docs/rules-health.md quarterly, or whenever any rule crosses 150 lines.
≈ “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: "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.
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.

