This tutorial shows you how to set up code review using Cursor CLI in GitHub Actions. The workflow will analyze pull requests, identify issues, and post feedback as comments.
For most users, we recommend using Bugbot instead. Bugbot provides managed automated code review with no setup required. This CLI approach is useful to explore capabilities and for advanced customization.
Automated code review in action showing inline comments on a pull request

Configure authentication

Set up your API key and repository secrets to authenticate Cursor CLI in GitHub Actions.

Set up agent permissions

Create a configuration file to control what actions the agent can perform. This prevents unintended operations like pushing code or creating pull requests. Create .cursor/cli.json in your repository root:
{
  "permissions": {
    "deny": [
      "Shell(git push)",
      "Shell(gh pr create)",
      "Write(**)"
    ]
  }
}
This configuration allows the agent to read files and use the GitHub CLI for comments, but prevents it from making changes to your repository. See the permissions reference for more configuration options.

Build the GitHub Actions workflow

Now let’s build the workflow step by step.

Set up the workflow trigger

Create .github/workflows/cursor-code-review.yml and configure it to run on pull requests:
name: Cursor Code Review

on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]

jobs:
  code-review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    
    steps:

Checkout the repository

Add the checkout step to access the pull request code:
- name: Checkout repository
  uses: actions/checkout@v4
  with:
    fetch-depth: 0
    ref: ${{ github.event.pull_request.head.sha }}

Install Cursor CLI

Add the CLI installation step:
- name: Install Cursor CLI
  run: |
    curl https://cursor.com/install -fsS | bash
    echo "$HOME/.cursor/bin" >> $GITHUB_PATH

Configure the review agent

Before implementing the full review step, let’s understand the anatomy of our review prompt. This section outlines how we want the agent to behave: Objective: We want the agent to review the current PR diff and flag only clear, high-severity issues, then leave very short inline comments (1-2 sentences) on changed lines only with a brief summary at the end. This keeps the signal-to-noise ratio balanced. Format: We want comments that are short and to the point. We use emojis to make scanning comments easier, and we want a high-level summary of the full review at the end. Submission: When the review is done, we want the agent to include a short comment based on what was found during the review. The agent should submit one review containing inline comments plus a concise summary. Edge cases: We need to handle:
  • Existing comments being resolved: The agent should mark them as done when addressed
  • Avoid duplicates: The agent should skip commenting if similar feedback already exists on or near the same lines
Final prompt: The complete prompt combines all these behavioral requirements to create focused, actionable feedback Now let’s implement the review agent step:
- name: Perform code review
  env:
    CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
    GH_TOKEN: ${{ github.token }}
  run: |
    cursor-agent --force --model "$MODEL" --output-format=text --print "You are operating in a GitHub Actions runner performing automated code review. The gh CLI is available and authenticated via GH_TOKEN. You may comment on pull requests.
    
    Context:
    - Repo: ${{ github.repository }}
    - PR Number: ${{ github.event.pull_request.number }}
    - PR Head SHA: ${{ github.event.pull_request.head.sha }}
    - PR Base SHA: ${{ github.event.pull_request.base.sha }}
    
    Objectives:
    1) Re-check existing review comments and reply resolved when addressed
    2) Review the current PR diff and flag only clear, high-severity issues
    3) Leave very short inline comments (1-2 sentences) on changed lines only and a brief summary at the end
    
    Procedure:
    - Get existing comments: gh pr view --json comments
    - Get diff: gh pr diff
    - If a previously reported issue appears fixed by nearby changes, reply: ✅ This issue appears to be resolved by the recent changes
    - Avoid duplicates: skip if similar feedback already exists on or near the same lines
    
    Commenting rules:
    - Max 10 inline comments total; prioritize the most critical issues
    - One issue per comment; place on the exact changed line
    - Natural tone, specific and actionable; do not mention automated or high-confidence
    - Use emojis: 🚨 Critical 🔒 Security ⚡ Performance ⚠️ Logic ✅ Resolved ✨ Improvement
    
    Submission:
    - Submit one review containing inline comments plus a concise summary
    - Use only: gh pr review --comment
    - Do not use: gh pr review --approve or --request-changes"
.
├── .cursor/
│   └── cli.json
├── .github/
│   └── workflows/
│       └── cursor-code-review.yml

Test your reviewer

Create a test pull request to verify the workflow works and the agent posts review comments with emoji feedback.
Pull request showing automated review comments with emojis and inline feedback on specific lines

Next steps

You now have a working automated code review system. Consider these enhancements:
  • Set up additional workflows for fixing CI failures
  • Configure different review levels for different branches
  • Integrate with your team’s existing code review process
  • Customize the agent’s behavior for different file types or directories