Ir para o conteúdo

Lição 21 · Reviewing and Testing AI Code

Agent Review and Bugbot

Add AI review with Cursor Agent Review for local changes and Bugbot for pull requests, configure them, triage findings and keep a human approval step.

AI can also help with review itself. The product has two related features: Agent Review for changes on your computer and Bugbot for pull requests. They may find problems you would miss. They can also miss problems and report things that are not problems.

Names and trigger words may change during the rename to Grok Build. For example, the announcement says that from December 7, 2026, teams should tag @Build instead of @Cursor in connected apps. Check the current documentation for review commands.

Agent Review

Agent Review runs a dedicated code review on your local changes. As documented in December 2026, you can:

  • Type /agent-review in the agent input.
  • Run it from the Source Control tab, which compares your local changes with your main branch.
  • Set it to run automatically, for example after commits, in the source control settings.

It offers two depths:

Depth Suited to
Quick Small diffs and sanity checks; faster and cheaper
Deep Complex logic, security-sensitive code, large refactors; slower and costlier

It also reads repository guidance from BUGBOT.md files.

Bugbot

Bugbot reviews pull requests and comments with explanations and suggested fixes. It can run on each pull request update or when you ask. Documented comment triggers include cursor review and bugbot run. You can also start a review from the agent before pushing, with /review-bugbot. The pricing documentation says the Free and Plus plans do not include Bugbot.

Behaviors worth knowing:

  • By default, reviews are incremental: they look at changes since its previous review.
  • It skips pull requests above its size limit and asks you to split them.
  • It publishes a status check. By default, findings give a neutral result, so requiring the check alone does not block merging.
  • An optional Autofix can propose fixes. Review them like any other AI change.

Configuration

A repository file, .cursor/config/bugbot.yaml, can set its behavior. It is read from the pull request's base branch, so it must be committed and pushed there. This example uses documented field names:

YAML
triggers:
  drafts: false
  frequency: oncePerPr
review:
  effort: default
  incremental: true
prSummary:
  mode: comment
autofix:
  mode: disabled

According to the documentation, the pull request author's personal overrides come first, then this file, then team and organization settings. Choosing effort levels is available only with usage-based billing.

Write review guidance

In BUGBOT.md, describe what matters in your code, not general advice:

TEXT
## Review priorities
- Money is integer cents. Flag any float used for money.
- Every database query filters by tenant_id.
- New endpoints need an authorization check and a test for it.

## Ignore
- Formatting. The linter handles it.

Good guidance is specific enough that a reviewer can say yes or no. The same text helps human reviewers.

Triage findings

Do not apply every suggestion blindly. For each finding, decide:

  1. Is it real? Reproduce it or write a failing test.
  2. How serious is it? Consider impact and likelihood.
  3. What is the right fix? The suggested one may be wrong or too narrow.
  4. Should it become a test or rule, so the problem does not return?

This stand-in sorts example findings. The findings are invented and are not Bugbot output.

Python Stand-in: triage review findings

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that a serious finding is not dismissed just because it is not yet proven.

Turn a finding into a test

Suppose a review says "documents of other tenants can be read". A test settles the question and stays as protection:

Python Confirm a tenant leak with a test

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The test checks both directions: the wrong access is refused, and the correct access still works.

Is it useful?

After a few weeks, count how many findings were real and worth acting on. If there are too many false alarms, people stop reading. Improve the guidance file when you see repeated noise. Keep an eye on usage costs too.

AI review is not approval

Layers of defense

Tests and CI
AI review Extra eyes
Human review Accountable
Branch rules
1 / 2

An AI reviewer and an AI author may share blind spots. Keep a human owner for every merge, especially for security, money and personal data. Review tools send code to a hosted service, so make sure your organization allows it.

Where it fits in your day

A simple routine is: finish a task, read your own diff, run the tests, then ask for an AI review before you open the pull request. Reading first matters. If the AI review comes first, it is tempting to look only where it points.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Which Agent Review depth suits security-sensitive code?

    Deep is documented for complex and security-sensitive changes.
  2. 2. Does requiring Bugbot's status check alone block merges that have findings?

    Check the current documentation and your branch rules if you want blocking behavior.
  3. 3. What is a sensible first step for a review finding?

    Findings can be wrong, and so can suggested fixes.

Summary

  • Agent Review checks local changes; Bugbot reviews pull requests.
  • Guidance files should name your project's real risks.
  • Triage findings, test them and measure how useful they are.
  • A human remains responsible for merging.

Next: Privacy Mode and Protecting Data

Seu progresso fica salvo neste navegador. Não precisa de conta.