Track lessons
CursorCode reviewContextBeginner5 min

Create a Code Review Rule in Cursor

Asking Cursor to "review this" gives generic advice that changes every time. A project rule stores your checklist and output format once, so every review checks the same risks and returns findings you can act on.

When to use

  • Self-review a branch before opening a Pull Request.
  • Review a teammate's PR diff with consistent severity levels.
  • Add stricter checks for one language or folder.

Example

A TypeScript API team adds a review rule that checks authorization, input validation and missing tests, then a narrow variant that flags `any` and unhandled promises only in .ts files.

TL;DR

Create a description-based rule; the Agent loads it whenever you ask for a review.

bash
mkdir -p .cursor/rules && touch .cursor/rules/code-review.mdc

Steps

  1. 1

    Write the general review rule

    Leave globs empty and alwaysApply false so the rule loads only when the request is about reviewing. The description is what the Agent uses to decide, so keep it explicit.

    .cursor/rules/code-review.mdc
    ---
    description: Strict code review of a diff or Pull Request. Use when asked to review changes.
    alwaysApply: false
    ---
    
    - Review only; do not edit files.
    - Read callers, tests and types touched by the diff.
    - Check: correctness, security, data changes, missing tests.
    - For each finding: severity (critical|major|minor), file:line, why, fix.
    - Skip formatting and naming nits.
  2. 2

    Add a TypeScript variant

    A glob-scoped rule adds language checks only when matching files are in context, keeping the general rule short.

    .cursor/rules/review-typescript.mdc
    ---
    description: Extra review checks for TypeScript
    globs: src/**/*.ts,src/**/*.tsx
    alwaysApply: false
    ---
    
    - Flag new `any`, non-null assertions (!) and unchecked casts.
    - Flag promises that are not awaited or caught.
    - Flag API input used without schema validation.
  3. 3

    Add a Python variant

    Same idea for Python services: focus on mistakes that tests and linters often miss.

    .cursor/rules/review-python.mdc
    ---
    description: Extra review checks for Python
    globs: **/*.py
    alwaysApply: false
    ---
    
    - Flag bare `except:` and swallowed exceptions.
    - Flag mutable default arguments.
    - Flag SQL built with f-strings or string concatenation.
  4. 4

    Run a review

    Ask for a review with an explicit diff so the Agent knows the scope; mention the rule with @ if you want to force it in.

    Cursor Agent
    @code-review Review git diff origin/main...HEAD.
    Report findings only. Do not edit files.

Gotchas

  • Rule files must end in .mdc; plain .md files in .cursor/rules are ignored.
  • Vague descriptions mean the rule is never picked; mention "review" explicitly.
  • These rules do not configure Bugbot; it reads .cursor/BUGBOT.md.
  • Commit .cursor/rules so the whole team reviews with the same checklist.

Cheat sheet

description + alwaysApply: falseLoaded when you ask for a review
globs: src/**/*.tsLanguage-specific extras
@code-reviewForce the rule into the chat
git diff origin/main...HEADScope of a pre-push review

Related

Sources

Reviewing agent output? CodeCrab reviews pull requests locally with your own AI tools.