golid / rules
Cursor rule40 starsChanged 6 months agoMITView on GitHub
Document an existing module — use when asked to spec, document, or map a module that's already built
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/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-rules.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 document-module.mdc into the rules it gives an agent
10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Every business rule must be marked:
- Distinctive: line 26
Do NOT invent business rules.
- Very specific: line 27
Use function names in [Verified:] annotations, not line numbers.
- Distinctive: line 37
Never put exact line numbers in Known Issues: Use function names or describe the pattern.
- Very specific: line 41
Use docs/modules/_templates/spec.md.
- Very specific: line 65
Run @audit-codebase against the spec to verify:
- Distinctive: line 66
Every FK dependency has a Depends On entry
- Distinctive: line 67
Every Scope Includes item has matching content
- Distinctive: line 73
When code changes a documented contract (state machine transition, enum value, business rule, side effect, API shape), update the spec in …
- Distinctive: line 84
If the spec doesn't mention the thing you changed, no sync needed.
≈ “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: Document an existing module — use when asked to spec, document, or map a module that's already built
alwaysApply: false
---
# Document a Module
> **Thesis:** Use this when documenting an existing module. `plan-feature.mdc`
> plans forward. This documents backward — capturing what was built, why, and
> how it behaves.
## Order of Operations
1. **Schema first** — read the migrations in `backend/migrations/` to understand tables, enums, relationships, indexes
2. **Service logic** — each service module lives in its own subpackage at `backend/internal/service/<module>/`. Read `<module>.go` (plus split files like `auth_password.go`, `auth_verify.go`) for business rules, auth checks, transactions, status transitions
3. **Handler surface** — read `backend/internal/handler/*.go` for request validation and response shapes; route registration lives in `backend/internal/wire/routes.go`
4. **Frontend routes** — read `frontend/src/routes/(private)/*.tsx` for pages, modals, state management
5. **Write the spec** — fill `docs/modules/_templates/spec.md` and save it to
`docs/modules/{module}/spec.md`
## Evidence Standards
- Every business rule must be marked:
- `[Verified: service/auth/auth.go, Refresh()]` — confirmed by reading the code
- `[NEEDS VERIFICATION]` — inferred from naming or partial evidence
- Do NOT invent business rules. If you can't confirm it, mark it unverified.
- Use **function names** in `[Verified:]` annotations, not line numbers. Line numbers drift with every PR; function names are stable.
- File paths are good — they can be verified with `ls` or `glob`. Include them freely.
## Anti-Rot Rules
These are the #1 source of documentation staleness. Follow strictly:
- **Never put exact line counts** in docs. Use complexity tiers (Low/Medium/High/Critical) or approximate scale (`~3k lines`). Exact counts are wrong after the next PR.
- **Never list code quality issues** (missing error handling, unused imports, dead code) in docs. Those are linter/grep concerns, not documentation. They go stale the moment someone cleans up code.
- **Do list architectural concerns** (file too large for splitting, duplicated utility, drift risk between frontend/backend). These change rarely and help future developers.
- **Never put exact line numbers in Known Issues**. Use function names or describe the pattern.
## Template Reference
Use `docs/modules/_templates/spec.md`. Do not recreate the template by memory;
copy it first, then fill it with verified evidence.
## Complexity Ratings
| Rating | Criteria |
|--------|----------|
| Low | < 500 lines, simple CRUD, no state machine, 0-1 integrations |
| Medium | 500-1,500 lines, has state machine or moderate rules, 1-2 integrations |
| High | 1,500-3,000 lines, complex state machines, financial calcs, 2+ integrations |
| Critical | 3,000+ lines, polymorphic entities, cross-system deps, data migration risks |
## Output
Save to `docs/modules/{module}/spec.md`. Create the directory if it doesn't exist.
**After updating a spec,** regenerate the reverse dependency map
(`docs/dependency-graph.md`) if Depends On entries changed. Check
`docs/flows.md` for flows involving this module and update if transaction
boundaries or failure modes changed. If endpoint auth logic changed,
update `docs/permissions.md`.
## After Writing
Run `@audit-codebase` against the spec to verify:
1. Every FK dependency has a Depends On entry
2. Every Scope Includes item has matching content
3. Business rules cite actual file paths
4. No `[NEEDS VERIFICATION]` items that can be resolved from code
## Same-Commit Spec Sync
When code changes a documented contract (state machine transition, enum value, business rule, side effect, API shape), update the spec **in the same commit**. Spec drift is the single largest source of doc rot in this repo.
What counts as "documented contract":
- A row in the State Machine table.
- An enum literal listed under Entities.
- A bullet under Business Rules with `[Verified: ...]`.
- A `created_via` / `source` / `status` enum value.
- A side effect listed under Side Effects (email, webhook, SSE event).
- A row in the API Surface table.
If the spec doesn't mention the thing you changed, no sync needed. If it does, the spec change goes in the same commit as the code change.
To verify before opening a PR: `scripts/check_spec_drift.sh`. The script flags handler/service files changed without a matching spec change. If the drift is intentional (refactor, rename, no behavior change), include `[skip-spec(<module>): <one-line reason>]` in any commit message in the range, or `[skip-spec: <reason>]` to skip all modules. See `ci-workflow` "Spec-Drift Gate" for the full mapping and CI wiring.
## Anti-Rationalization
| Excuse | Counter |
|---|---|
| "I'll update the spec in a follow-up doc commit" | Spec-drift follow-ups produced `2b6568e`, `9294451`, `c9ba50d`, `a4e9405` — four separate commits that should have been zero. Sync in the same commit costs 30 seconds. |
| "The spec is auto-generated from code" | It isn't. Specs in this repo are hand-written narrative + `[Verified:]` annotations. They don't auto-update. |
| "The change is too small to matter to the spec" | If it's small enough that the spec doesn't need updating, the spec already covers it. If the spec is silent on the thing you changed, the spec is now wrong. |
| "Someone will catch it in audit" | They will. That's the cleanup commit you're trying to avoid. |
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.

