write-rules

Rules for writing Cursor rules, which are reusable instructions that guide an AI coding assistant's behavior in a project.

In plain words
What is it for?
Use them when creating or updating a rule, deciding whether a pattern deserves one, or documenting mistakes and preferred fixes.
Why use it?
They make rules clearer and more reusable by requiring a stated purpose, useful references, and focused examples.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/golid-ai/golid/write-rules
Clone the repo
git clone --depth 1 https://github.com/golid-ai/golid

Made for: Cursor.

Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 939 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00022 $0.00939
Opus 5 $0.00011 $0.00469
Sonnet 5 $0.00004 $0.00188
Haiku 4.5 $0.00002 $0.00094

Measured 3d ago against content hash ec52d48d1866, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

write-rules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/write-rules.mdc · 103 lines

How it starts

The opening of the file, as written. The whole thing — 103 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.

Read the full file on GitHub · 103 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 103 lines · 22 tokens per session scan A ec52d48d1866

Subscribe to this mod's changes

write-rules is a cursor rule published in the GitHub repository golid-ai/golid (40 stars, last pushed 2mo ago), licensed MIT. It adds 22 tokens to every session and 939 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.