golid / rules
Cursor rule40 starsChanged 6 months agoMITView on GitHub
Core codebase standards — applies to every conversation.
- Reads credentials
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/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-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
Show its rules and text
We split this codebase-standards.mdc into the rules it gives an agent
15 rules. About 0 are common, 7 are distinctive, and 8 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.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 57
When a code change invalidates or reveals a gap in a rule or doc, update it in the same pass.
- Very specific: line 59
Changed a convention or pattern?: Update the relevant .cursor/rules/ file.
- Very specific: line 60
Changed a module's behavior?: Update docs/modules/{module}/spec.md.
- Very specific: line 61
Added/removed a component?: Update frontend/src/components/index.ts.
- Very specific: line 62
Changed deploy scripts or env vars?: Update docs/ and config/.env.example.
- Very specific: line 63
Added a new route?: Add to PRIVATE_ROUTES in frontend/src/lib/constants.ts.
- Very specific: line 64
Found a bug pattern worth codifying?: Add to audit-bugs.mdc and the relevant domain rule.
- Very specific: line 65
Added or changed an API endpoint?: Update backend/openapi.yaml.
- Very specific: line 67
If unsure whether a rule is affected, grep .cursor/rules/ for the pattern you changed.
- Distinctive: line 71
When making code changes, update or add tests in the same pass.
- Distinctive: line 73
Added a new API route?: Add handler tests: success, not-found, validation error, unauthorized.
- Distinctive: line 74
Changed a service function?: Update tests to cover new/changed branches.
- Distinctive: line 75
Added a new page/route?: Add a render test (loading state, loaded state with mocked API).
- Distinctive: line 76
Changed a function signature?: Update all test call sites.
- Distinctive: line 77
Removed code?: Remove or update tests for the removed behavior.
≈ “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: Core codebase standards — applies to every conversation.
alwaysApply: true
---
# Codebase Standards
> **Thesis:** Universal guardrails that apply regardless of which file you're
> editing — the principles that every other rule assumes you follow.
## Core Guardrails
One-line reminders of the highest-consequence rules. Domain-specific rules
(go-service, solidjs-pages, etc.) have full explanations and examples.
- **Module spec mapping** — before modifying a module, read its spec at `docs/modules/{module}/spec.md`. Folders: `auth`, `users`, `feature`. Multi-file auth: `auth_password`, `auth_verify` → `auth` spec.
- **Parameterized queries only** — never `fmt.Sprintf` with values into SQL. Use `$N` placeholders for values; write literal SQL per call site for identifiers.
- **`apperror` for all errors** — never `echo.NewHTTPError`. Use `apperror.BadRequest`, `.Forbidden`, `.NotFound`, `.Validation`, `.Internal`.
- **`batch()` signal updates after every `await`** — put user-visible state like `setLoading(false)` inside both `try` and `catch`, wrapped in `batch()`. `finally` is only okay for independent re-entry locks that do not need to batch with success/error UI.
- **`Switch/Match` for content states** — never nested `<Show>` for loading/error/empty/data states.
- **`onMount` + signals for data fetching** — never `createResource`. Use `alive` guard and `loadRequestID` for param refetches. See `solidjs-data-fetching`.
- **Never early-return route components before reactive setup** — move auth/access guards into JSX with `<Show when={...} fallback={...}>`.
- **Never discard errors** — no `_ = fn()`. Log with `logger.Error` at minimum.
- **Resource membership, not just role** — verify the specific user belongs to the specific resource, not just `userType`.
- **Config over hardcoded values** — if you'd change it per environment, it belongs in `Config` or named constants.
- **Request body size limit** — `middleware.BodyLimit("1M")` is configured in `stack.go`.
- **SSE uses one-time ticket auth (not JWT in URL)** — see `handler/sse.go` and `service/sse/sse.go`.
- **Command lookup before shell work** — before running nontrivial local, test, deploy, GCP, Git, or contract-validation commands, read `common-commands` / `docs/cli-reference.md`, use known-good repo commands, and diagnose the first concrete failure instead of probing equivalent tools.
## Security
- Two-layer auth: handler calls `requireUserID` (authn), service calls `verifyResourceAccess` or equivalent (authz).
- **Selector/verifier pattern** for security tokens — never store tokens as plaintext. See `service/auth/auth_password.go` and `service/auth/auth_verify.go`.
- Webhook endpoints verify signatures (HMAC-SHA256). Never trust unverified webhooks.
## Opt-In Modules
- **`IsConfigured()` for opt-in modules** — queue, rate limiting, email, and tracing use `IsConfigured()` gates (`REDIS_URL`, `MAILGUN_API_KEY`, `OTEL_ENDPOINT`). When not configured, fall back gracefully. Both paths must be tested.
- **Never check `service != nil`** — use `service.IsConfigured()`. Opt-in services are always instantiated (never nil).
- **Dual-path pattern for queue** — `if h.queue.IsConfigured() { enqueue } else { go func() { Retry(...) }() }`.
- **Redis fail-open** — rate limiting and queue degrade when Redis is unreachable. Log the degradation.
## Operations
- **Shutdown order** — `e.Shutdown()` first (drain HTTP), then `sseHub.Shutdown()` (close SSE), then `defer db.Close()` (pool cleanup last via defer LIFO).
## Git Discipline
See `git-commits` rule for full conventions. Key points:
- **One logical change per commit** — don't bundle unrelated changes.
- **Spec drift before commit** — run `scripts/check_spec_drift.sh <base-ref>` before committing module-owned code changes; fix drift or include the required skip marker.
- **Branch naming** — `type/short-description` (e.g., `feat/notes-crud`, `fix/token-expiry`).
## Keep Rules and Docs In Sync
When a code change invalidates or reveals a gap in a rule or doc, update it in the same pass. Stale rules actively mislead.
- **Changed a convention or pattern?** Update the relevant `.cursor/rules/` file.
- **Changed a module's behavior?** Update `docs/modules/{module}/spec.md`.
- **Added/removed a component?** Update `frontend/src/components/index.ts`.
- **Changed deploy scripts or env vars?** Update `docs/` and `config/.env.example`.
- **Added a new route?** Add to `PRIVATE_ROUTES` in `frontend/src/lib/constants.ts`.
- **Found a bug pattern worth codifying?** Add to `audit-bugs.mdc` and the relevant domain rule.
- **Added or changed an API endpoint?** Update `backend/openapi.yaml`.
If unsure whether a rule is affected, grep `.cursor/rules/` for the pattern you changed.
## Keep Tests In Sync
When making code changes, update or add tests in the same pass. Don't ship code without corresponding tests.
- **Added a new API route?** Add handler tests: success, not-found, validation error, unauthorized.
- **Changed a service function?** Update tests to cover new/changed branches.
- **Added a new page/route?** Add a render test (loading state, loaded state with mocked API).
- **Changed a function signature?** Update all test call sites.
- **Removed code?** Remove or update tests for the removed behavior.
## Working Principles
- **Minimal impact** — changes should only touch what's necessary.
- **Stop and re-plan when stuck** — if a fix takes more than 2 attempts, stop and re-plan.
- **Verify before marking done** — run tests, typecheck, and build after every change.
- **Never run `-tags=integration` against the dev DB** — verify `TEST_DATABASE_URL` first. Full warning lives in `write-tests-planning`.
- **Change sizing** — keep each commit to one logical change, ideally under ~100 lines of diff. See `git-commits`.
- **Pre-merge audit gate** — before declaring a feature/card "done", run `audit-bugs` (module-scoped) or `audit-codebase` (cross-cutting).
## Anti-Rationalization
Workflow rules own their specific "don't skip the step" counters. When a task
touches tests, commits, audits, or spec sync, read the nearest active rule's
Anti-Rationalization section instead of relying on a generic reminder here.
## Rule Index
Non-globbed files (`cmd/server/main.go`, `internal/wire/*.go`, `internal/db/*.go`, `frontend/src/app.tsx`) use Core Guardrails as primary guidance — intentional, not a gap.
Domain rules fire automatically via file globs. For workflow tasks, invoke by name:
- **Workflow routing:** `workflow-routing` (classify T0–T3 before choosing plan, slice, audit, or review depth)
- **Common commands:** `common-commands` (known-good local/dev/test/deploy commands)
- **Git conventions:** `git-commits` (commit messages, branch naming, change sizing)
- **Any repo plan:** `planning-standards` (quality bar for `docs/plans/**/*.md`)
- **Plan a new feature:** `plan-feature` → `plan-feature-execution` → `slice-and-ship` / `plan-execution-loop` → domain rules → `write-tests` / `write-tests-planning` → `audit-bugs`
- **Plan infra/deploy/env work:** `plan-infra` → `deploy-infra` → `ci-workflow` as needed
- **Implement a planned feature:** `slice-and-ship` (implement → test → sync → audit → commit, one criterion at a time)
- **Document a module:** `document-module` → `audit-codebase` (verify)
- **Audit for bugs:** `audit-bugs` (single module) or `audit-codebase` (full system)
- **Spec drift check:** `scripts/check_spec_drift.sh` + `check_citation_freshness.sh` + `check_rule_health.sh` (see `ci-workflow`)
- **Refactor a large file:** `refactor-large-files`
- **Form/error patterns:** `frontend-forms`
- **Create or maintain a rule:** `write-rules`
- **Dynamic image endpoints:** `dynamic-image-endpoints` (renderer + ETag) → `dynamic-image-http` (cache posture, render budget, max bytes)
- **Frontend tests:** `write-tests-frontend` → `write-tests-frontend-workflow`; **E2E:** `write-tests-e2e`; **backend tests:** `write-tests` → `write-tests-planning`
- **Module specs:** `docs/modules/{module}/spec.md` — auth, users, feature
- **Frontend routing:** `solidstart-routing` — `(private)` / `(public)` groups and `PRIVATE_ROUTES`
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.

