golid / rules
Cursor rule40 starsChanged 6 months agoMITView on GitHub
Bug audit checklist — use when asked to review code for bugs, security issues, or quality problems
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,531 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-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-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 audit-bugs.mdc into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Use workflow-routing first when the user asks for review/audit depth or when the diff crosses T2/T3 triggers.
≈ “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: Bug audit checklist — use when asked to review code for bugs, security issues, or quality problems
alwaysApply: false
---
# Bug Audit Checklist
> **Thesis:** Run this checklist against any file or module being reviewed.
> Each item references a real bug found in this codebase.
## When to Run
Use `workflow-routing` first when the user asks for review/audit depth or when
the diff crosses T2/T3 triggers; this checklist is scoped by that tier.
Two trigger points, not just one:
1. **Pre-merge gate** — before declaring a card/feature "done", run the relevant section of this checklist against every file you touched. ~20% of recent commits are post-hoc audit cleanup; running this proactively converts those into the original commit. This is the highest-ROI use.
2. **On demand** — when explicitly asked to audit, review for bugs, or grade code quality.
The checklist below is the same for both; only the trigger differs.
## Evidence Requirements
A finding isn't "audited" until you've produced one of:
- **File path + function name + line range** for the offending pattern (e.g., `service/feature/feature.go::Create lines 45-52`).
- **`rg` command + match count** for codebase-wide patterns (e.g., `rg "_ = pool\.Exec" -g '*.go' | wc -l → 3 hits`).
- **"Verified clean"** with the search you ran, when no instances exist (e.g., `rg "createResource" frontend/ → 0 hits`).
"Looks fine" is not an audit result. If you can't cite the search, you didn't run it.
Core patterns (`apperror`, parameterized SQL, `batch()`, Switch/Match, `createResource`, alive guard) — see `codebase-standards`. Frontend fetch — `solidjs-data-fetching`. Route UI — `solidjs-pages`.
## Audit Strategy
A single audit pass catches ~60-70% of real issues. Each pass has blind spots due to which files get read first, which patterns the search focuses on, and attention saturation on large codebases. To maximize coverage:
1. **Run multiple independent passes with different focus areas** — e.g., one pass for reactive patterns, one for auth/security, one for config consistency, one for the fork/rename story. Narrow scope finds more than broad sweeps.
2. **Vary the search strategy** — don't just follow this checklist. Grep for known anti-patterns (`return () =>` in `.tsx`, `_ =` in `.go`, `any` in component props). Read files the checklist doesn't mention (entry-server.tsx, rename tool, CI config, env files).
3. **Check reference implementations are textbook-perfect** — `app.tsx`, `login/index.tsx`, `dashboard/index.tsx`, and `settings/index.tsx` are copied by the scaffold tool and by AI assistants. A bug in these propagates everywhere.
4. **Verify the tool chain, not just the code** — rename tool, scaffold templates, deploy scripts, and CI config can have bugs that downstream users inherit silently.
5. **After fixing issues, re-read the fixed files** — fixes can introduce new problems (e.g., a rename tool step that corrupts URLs by naively replacing project names inside domain strings).
## Backend Service Files
- [ ] **SQL injection** — `fmt.Sprintf` with values or identifiers in SQL? Use `$N` placeholders (see `codebase-standards`).
- [ ] **Missing transactions** — any method with 2+ writes that isn't wrapped in `Begin/Commit`?
- [ ] **Silent error discards** — `_ = fn(...)` or `_ = pool.Exec(...)`? Log errors (see `codebase-standards`).
- [ ] **ErrNoRows masking** — any `_ = pool.QueryRow(...)` that ignores real DB errors? Must check `err != nil && err != pgx.ErrNoRows`.
- [ ] **Role-only auth** — any method that checks `userType` but not specific resource membership? Must use `verifyXAccess`.
- [ ] **Missing status guards** — can the method be called on inactive/completed/cancelled parent entities? Add guards.
- [ ] **echo.NewHTTPError usage** — use `apperror.X()` instead (see `codebase-standards`).
- [ ] **TIMESTAMPTZ scan into *string** — nullable `TIMESTAMPTZ` columns CANNOT scan into `*string`. Must scan into `*time.Time` then format: `if t != nil { s := t.Format(time.RFC3339); field = &s }`.
- [ ] **ON CONFLICT without UNIQUE constraint** — any `ON CONFLICT (col1, col2)` requires a matching `UNIQUE` index on those columns. Without it, PostgreSQL returns a runtime error.
- [ ] **Hardcoded values in service constructors** — names, emails, URLs should come from config/env, not hardcoded strings.
- [ ] **Missing `rows.Err()` after `rows.Next()` loops** — partial iteration errors are silent without this check. Every `for rows.Next()` must be followed by `if err := rows.Err()`.
- [ ] **`apperror.NotFound("X not found")` double-suffix** — `apperror.NotFound(resource string)` formats its argument as `"%s not found"`, so `apperror.NotFound("User not found")` emits the user-facing string `"User not found not found"`. Pass the bare resource noun (e.g. `apperror.NotFound("User")`, `apperror.NotFound("Invoice")`). The May 26 audit found this pattern in 7 production sites — the formatter contract is non-obvious and the double-suffix surfaces in real API responses.
- [ ] **Bare `err == pgx.ErrNoRows` instead of `errors.Is(err, pgx.ErrNoRows)`** — direct equality breaks the moment any caller wraps the error with `fmt.Errorf("...: %w", err)`. The codebase has 110+ bare-equality sites (May 26 audit); they work today only because nothing wraps before the comparison. Use `errors.Is` defensively — same one-line fix, future-proof against wrapping.
## Backend Handler Files
- [ ] **Missing requireUserID/requireUserType** — every protected handler must extract auth.
- [ ] **Business logic in handler** — DB queries or complex logic should be in the service layer.
- [ ] **Missing request validation** — required fields should be checked before calling service.
## Frontend Route Files
- [ ] **Nested `<Show>` for content states** — use flat `Switch/Match` (see `solidjs-pages`).
- [ ] **Missing `batch()` on async signal updates** — wrap post-`await` signal updates in `batch()` (see `solidjs-data-fetching`).
- [ ] **Missing `defer: true` on `createEffect(on(...))`** — refetch effects need `{ defer: true }` + separate `onMount` (see `solidjs-data-fetching`).
- [ ] **Reactive expression inside `<Title>`** — pre-compute with `createMemo`, pass resolved string (see `solidjs-pages`).
- [ ] **`createResource` usage anywhere** — use `onMount` + signals + alive guard (see `codebase-standards`, `solidjs-data-fetching`).
- [ ] **Return from `onMount` or `createEffect`** — use `onCleanup` inside the body, not a return value (see `solidjs-data-fetching`).
- [ ] **Missing alive guard** — `let alive = true; onCleanup(...); if (alive)` before setting signals (see `solidjs-data-fetching`).
- [ ] **Missing PRIVATE_ROUTES entry** — route listed in `frontend/src/lib/constants.ts`.
- [ ] **window.confirm usage** — use `DestructiveModal` (see `solidjs-pages`).
- [ ] **Route-based detail view** — prefer signal-driven modal (see `solidjs-pages`).
## Migration Files
- [ ] **Missing down migration** — does the `.down.sql` exist and reverse everything?
- [ ] **Missing indexes** — are FK columns and filter columns indexed?
- [ ] **Missing updated_at trigger** — does the table have `updated_at` and the trigger?
## External API Integration
- [ ] **API field names mismatch** — verify JSON struct tags match the external API's exact field names. Check the API docs, not assumptions.
- [ ] **Query param vs body** — some APIs expect fields as query parameters, not in the request body. Verify endpoint documentation.
- [ ] **Email deliverability** — external services may reject emails on bounce suppression lists. Verify `IsConfigured()` returns true before relying on email delivery. Use `service.Retry()` for resilience.
- [ ] **Webhook signature verification** — every webhook endpoint must verify the request signature (e.g., HMAC-SHA256 with timing-safe comparison).
## Cross-Cutting
- [ ] **Secrets in code** — any hardcoded API keys, passwords, or tokens?
- [ ] **Secrets in shell scripts** — any `export VAR=secret`? Secrets should be loaded from env files, never hardcoded.
- [ ] **N+1 queries** — any loop that makes a DB query per iteration? Should be a JOIN or batch query.
- [ ] **Missing error handling in goroutines** — any `go fn()` without error logging?
- [ ] **SSE endpoints excluded from middleware** — SSE (long-lived) endpoints must skip gzip compression (causes flush panic on close) and request timeout middleware. Check `middleware/stack.go` skipper functions.
- [ ] **Modal overflow** — any modal content taller than the viewport? The global Modal has `max-h-[90vh] overflow-y-auto` but verify iframe/large content modals use appropriate height constraints.
## Anti-Rationalization
| Excuse | Counter |
|---|---|
| "It's a small change, audit isn't needed" | The repeated 23505 translation gap was 3 lines each time. Run the relevant section. |
| "Tests pass, ship it" | Audit checks whether the *new* branch is tested at all, not whether existing tests still pass. |
| "I'll audit in a follow-up PR" | Follow-up audit PRs often average 30 file changes. Audit now or pay 10× later. |
| "The audit takes longer than the change" | Time the audit. If it's >5 minutes for a single-file change, you're doing it wrong — pick the relevant section, skip the others. |
| "I read the code, looks fine" | "Looks fine" produces no evidence. Run the `rg` search and cite the result. See Evidence Requirements above. |
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.

