Cursor rule
.cursor/rules/audit-code.mdcSelf-review checklist for the coding agent to run before dispatching a reviewer. Checks CONVENTIONS.md compliance, Boy Scout Rule, test coverage, types, and SOLID. Produces a pass/fail checklist. Use before request-review, before committing, or when user asks for a code quality check.
Cursor rules
Quality
66/100
Scores the file, not the repository.Length
1,441 words
26 headings · 2 code blocksRepository
119
— · pushed 1 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Audit Code7> **HARD GATE** — **HARD GATE** — Audit must check for: bugs (correctness), security, performance, and clarity. Do NOT skip security review if the code touches user data, auth, or external APIs.8910Run this self-review before asking anyone else to look at the code. The goal is to catch everything that is clearly wrong or missing — so the reviewer can focus on design and architecture, not hygiene.1112**Distinct from `request-review`:** This is the coding agent checking its own work. No second agent is involved. Run this first; run `request-review` after this passes.1314## Look-here-first (churn heuristic)1516Before the checklist, rank changed files by git churn and review **high-churn hotspots first** — they carry the most latent risk regardless of diff size.1718```bash19bash scripts/bp-churn-rank.sh --since 90.days --limit 1520```2122Apply the full checklist to churn-ranked files in descending order. Files with zero recent commits but large diffs still get reviewed; churn only sets priority, not scope.2324## Modes2526- Default: full checklist27- --quick: Run only Supply Chain and Test Coverage. Use for changes under 50 LOC.28- --gate: Non-interactive mode for automated CI gating (used by build-epic step 6). Exit with non-zero status code (`exit 1`) on ANY checklist failure; `exit 0` only if ALL items pass. Produces a compact pass/fail summary to stderr. On failure, list every ✗ item with reason.29- --parallel: Run checklist sections in **isolated git worktrees** (e45s18) so concurrent checks cannot corrupt each other's working tree:3031```bash32bash scripts/lib/parallel-review-worktrees.sh audit-code33```343536## Checklist3738### Supply Chain & Security3940- [ ] slopcheck run for new dependencies; packages tagged in plan-work: `[OK]`, `[SUS]`, or `[SLOP]`41- [ ] No `[SLOP]` packages without documented human approval42- [ ] No secrets in diff (`sk-`, `ghp_`, `AKIA`, `.env` values) — see `guard-git` patterns43- [ ] OWASP Top 10 spot-check: injection, broken auth, sensitive data exposure, misconfiguration (see `docs/references/security-threats.md`)44- [ ] Security: diff scanned — no unaddressed HIGH findings (or deviations documented in `specs/security/EXCEPTIONS.md`)4546### Provenance & Metadata4748- [ ] New plan artefacts include `type:` and `context:` metadata49- [ ] Implementation steps reference ADR or commit SHA where decisions were made5051### Law of Demeter5253- [ ] No method chains through unrelated objects (e.g. `a.getB().getC().doX()`)54- [ ] Collaborators talk to immediate neighbors only; law violations need explicit justification5556### CONVENTIONS.md Compliance5758- [ ] All output files are in `specs/` (no docs written to project root)59- [ ] No `gh issue create` calls anywhere in new/modified skills or scripts60- [ ] `gh` used only for PRs and repo clone operations61- [ ] No GitHub REST API called directly (no curl/fetch to api.github.com)6263### Scope6465- [ ] Changes are limited to what was asked — nothing extra refactored or reorganized66- [ ] No speculative features added67- [ ] No files touched outside the stated scope68- [ ] **Discovered defects:** Reproducible gate failures (Preflight, CI, golden suite) require fix-or-log — `quick-fix` or `fix-bug` — even when "outside" the story scope. Scope-minimization does not waive Always Green.69- [ ] Boy Scout Rule applies to files opened to fix a gate failure; it does not excuse skipping red Preflight7071### Boy Scout Rule7273- [ ] Every file I touched is cleaner than when I found it74- [ ] No dead code left behind75- [ ] No commented-out code blocks7677### Types and Safety7879- [ ] No `any` types introduced (TypeScript) or untyped public functions (Python/Go/etc.)80- [ ] No `@ts-ignore` or `// eslint-disable` added81- [ ] No `as unknown as X` casts that bypass type safety8283### Test Coverage8485- [ ] Every new function has at least one test86- [ ] Every bug fix has a regression test87- [ ] Tests verify behavior through public interfaces (not implementation details)88- [ ] Tests are F.I.R.S.T compliant (per CONVENTIONS.md §Tests; use `enforce-first` if unsure)8990### SOLID and Heuristics9192- [ ] Single Responsibility: no function or module doing two unrelated things93- [ ] Open/Closed: extended through interfaces, not by modifying stable code94- [ ] Dependency Inversion: dependencies injected, not imported globally where avoidable95- [ ] **Chapter 17 Heuristics**: Code is free of smells documented in `audit-code/HEURISTICS.md` (G, N, C, T)9697### Refactoring Smells (Fowler)9899Explicitly name any detected smells: Mysterious Name, Duplicated Code, Feature Envy, Data Clumps, Primitive Obsession, Message Chains, Middle Man.100101### Code Style (CONVENTIONS.md)102103- [ ] Functions: 4–20 lines; split if longer104- [ ] Functions: descend exactly one level of abstraction (The Stepdown Rule / G34)105- [ ] Files: under 300 lines (ideally 200–300)106- [ ] Names: specific and unique (grep returns < 5 hits for each name)107- [ ] No duplication — shared logic extracted (DRY / G5)108- [ ] Early returns over nested ifs; max 2 levels of indentation109- [ ] Conditionals: expressed as positives (G29)110- [ ] Comments explain WHY, not WHAT111112### Red Flags113114Before reporting, name any rationalization you caught yourself making for skipping a checklist item. Silence is not acceptable — if you skipped an item, state the reason explicitly.115116## Output117118Report the checklist with ✓ / ✗ per item. For each ✗, describe what needs to be fixed.119120If all items pass: suggest running `request-review` for an independent second opinion.121If any items fail: fix them before proceeding.122123In `--gate` mode, print one summary line per checklist section (`PASS Supply Chain` / `FAIL Provenance (2 items)`). Exit `0` only if all PASS. Write full report to `specs/verifications/AUDIT-<epic>-<story>.md`.124125## Verify126127→ verify: `test -f CONVENTIONS.md && test -d skills/enforce-first && test -d skills/request-review`128129## Handoff130131Gate: READY -> next: commit-message132Writes: state.yaml handoff.next_skill = commit-message133134135<!-- story: e01s02 -->136<!-- story: e06s03 -->137<!-- story: e07s01 -->138139---140141# Clean Code Heuristics (Chapter 17)142143A summary of Robert C. Martin's catalogue of code smells and heuristics, used as the technical benchmark for `audit-code`.144145## Comments (C)146- **C1: Inappropriate Information**: Comments should only hold technical notes. Metadata (author, change history) belongs in Git.147- **C2: Obsolete Comment**: Update or delete comments that are no longer accurate.148- **C3: Redundant Comment**: Don't describe code that adequately describes itself (e.g., `i++; // increment i`).149- **C4: Poorly Written Comment**: If you write a comment, spend time making it the best it can be.150- **C5: Commented-Out Code**: Delete it. Git remembers it.151152## Environment (E)153- **E1: Build Requires More Than One Step**: Building should be a single trivial operation (e.g., `bash install.sh`).154- **E2: Tests Require More Than One Step**: Running all tests should be one simple command (e.g., `npm test`).155156## Functions (F)157- **F1: Too Many Arguments**: 0 is ideal, 1-2 is fine, 3 requires special justification. Never > 3.158- **F2: Output Arguments**: Avoid them. If a function changes state, it should change the state of its owning object.159- **F3: Flag Arguments**: Boolean arguments are a smell that the function does > 1 thing.160- **F4: Dead Function**: Discard methods that are never called.161162## General (G)163- **G1: Multiple Languages in One Source File**: Try to minimize the mixing of languages (e.g., HTML inside Java).164- **G5: Duplication (DRY)**: **The root of all evil.** Every time you see duplication, it's a missed opportunity for abstraction.165- **G6: Code at Wrong Level of Abstraction**: High-level concepts in base classes; low-level details in derivatives.166- **G25: Replace Magic Numbers with Named Constants**: No "naked" numbers or strings.167- **G28: Encapsulate Conditionals**: Prefer `if (shouldBePublished())` over complex boolean logic.168- **G29: Avoid Negative Conditionals**: Prefer `if (buffer.shouldCompact())` over `if (!buffer.shouldNotCompact())`.169- **G30: Functions Should Do One Thing**: If a function can be split into sections, it's doing too much.170- **G31: Hidden Temporal Couplings**: If execution order matters, make the dependency explicit via arguments.171- **G34: Functions Should Descend Only One Level of Abstraction**: The Stepdown Rule.172173## Naming (N)174- **N1: Choose Descriptive Names**: Names should reveal intent and be updated as code evolves.175- **N4: Unambiguous Names**: Names should make the working of a function/variable clear.176- **N7: Names Should Describe Side-Effects**: Describe everything the function is or does.177178## Tests (T)179- **T1: Insufficient Tests**: A test suite should test everything that could possibly break.180- **T4: An Ignored Test Is a Question about an Ambiguity**: Document the reason for `@Ignore`.181- **T5: Test Boundary Conditions**: Most bugs happen at the boundaries; test them exhaustively.182- **T8: Test Coverage Patterns Can Be Revealing**: Analyze what code is *not* executed to find gaps.183- **T9: Tests Should Be Fast**: Slow tests don't get run.184
Also in danielvm-git/bigpowers
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| danielvm-git/bigpowers.cursor/rules/align-grid.mdc · 119 | Cursor rules | lint-formatdo-notagent-behaviour | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/assess-impact.mdc · 119 | Cursor rules | testtesting-strategydeployment | 66/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/audit-plan.mdc · 119 | Cursor rules | buildteststylegit | 74/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/build-epic.mdc · 119 | Cursor rules | buildgit | 58/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/change-request.mdc · 119 | Cursor rules | no sections | 48/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/commit-message.mdc · 119 | Cursor rules | lint-formatstyletypesgit+3 | 82/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/compose-workflow.mdc · 119 | Cursor rules | styledo-notagent-behaviour | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/context7-mcp.mdc · 119 | Cursor rules | style | 54/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/deepen-architecture.mdc · 119 | Cursor rules | testtesting-strategydo-not | 57/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/define-language.mdc · 119 | Cursor rules | lint-formatdo-not | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/delegate-task.mdc · 119 | Cursor rules | git | 62/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/deploy.mdc · 119 | Cursor rules | setupbuildtestdeployment | 77/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/develop-tdd.mdc · 119 | Cursor rules | teststylearchtesting-strategy+5 | 85/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/diagnose-root.mdc · 119 | Cursor rules | no sections | 39/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/dispatch-agents.mdc · 119 | Cursor rules | git | 54/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/edit-document.mdc · 119 | Cursor rules | no sections | 39/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/elaborate-spec.mdc · 119 | Cursor rules | test | 58/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/enforce-first.mdc · 119 | Cursor rules | no sections | 50/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/evolve-skill.mdc · 119 | Cursor rules | no sections | 50/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/execute-plan.mdc · 119 | Cursor rules | do-not | 51/100 | 3 days ago |
Diff against .cursor/rules/align-grid.mdc Diff against .cursor/rules/assess-impact.mdc Diff against .cursor/rules/audit-plan.mdc Diff against .cursor/rules/build-epic.mdc Diff against .cursor/rules/change-request.mdc Diff against .cursor/rules/commit-message.mdc Diff against .cursor/rules/compose-workflow.mdc Diff against .cursor/rules/context7-mcp.mdc Diff against .cursor/rules/deepen-architecture.mdc Diff against .cursor/rules/define-language.mdc Diff against .cursor/rules/delegate-task.mdc Diff against .cursor/rules/deploy.mdc Diff against .cursor/rules/develop-tdd.mdc Diff against .cursor/rules/diagnose-root.mdc Diff against .cursor/rules/dispatch-agents.mdc Diff against .cursor/rules/edit-document.mdc Diff against .cursor/rules/elaborate-spec.mdc Diff against .cursor/rules/enforce-first.mdc Diff against .cursor/rules/evolve-skill.mdc Diff against .cursor/rules/execute-plan.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
