# AI Code Review

AI Code Review helps you reviews your code changes, predicting errors and offering suggestions for improvement before merging pull requests.

AI Code Review is currently in **beta**. Beta features are still a work in progress and may have bugs. Please join the [Discord conversation](https://discord.com/channels/621778831602221064/1415468783648247870) to share your feedback.

## [Getting Started](https://docs.sentry.io/product/ai-in-sentry/ai-code-review.md#getting-started)

To enable AI Code Review in your GitHub organization or on specific repositories:

1. Have the [Sentry GitHub integration](https://docs.sentry.io/organization/integrations/source-code-mgmt/github.md) enabled.

2. Enable these required settings in your Sentry [organization settings](https://sentry.io/orgredirect/settings/:orgslug/):

   * `Show Generative AI Features`
   * `Enable AI Code Review`

## [AI Code Review Commands](https://docs.sentry.io/product/ai-in-sentry/ai-code-review.md#ai-code-review-commands)

Ways AI Code Review can help you:

1. **Error Prediction** - When you create a pull request and set it to `Ready for Review`, AI Code Review will check for errors in your code. If no error is found, you will see a 🎉 emoji as a reaction to your PR description. Otherwise, AI Code Review will add comments to your PR. **Note:** We skip review if you set your PR to `draft` on creation.

2. **`@sentry review`** - Use this command in a PR comment, and the assistant will review the PR and predict errors, as well as make suggestions.

Once you have added a comment, the assistant will reply, acknowledging the request. For code reviews, you will then see comments added to your PR.

## [Frequently Asked Questions](https://docs.sentry.io/product/ai-in-sentry/ai-code-review.md#frequently-asked-questions)

* **What data does AI Code Review need access to for the AI system to function, and what information is sent to third-party AI providers?**

  AI Code Review requires access to your pull requests, including PR metadata, repository information, file names, directory structures, and code diffs. Only file names, code diffs, and PR descriptions are sent to the AI provider for analysis.

* **Does AI Code run anywhere outside of GitHub, and does it run in the background?**

  AI Code Review only runs on GitHub. It will run once when a PR is marked `ready for review` (either when creating the PR, or after taking it out of draft), and otherwise only runs when triggered by a comment.

  You can learn more about AI privacy and security [here](https://docs.sentry.io/product/ai-in-sentry/ai-privacy-and-security.md).

* **Why aren't `@sentry` commands working?**

  AI Code Review will respond with a message to enable the `Show Generative AI Features` and `Enable AI Code Review` settings in your [organization settings](https://sentry.io/orgredirect/settings/:orgslug/), if you have not already enabled them. Once enabled, try `@sentry review` again to run AI Code Review.

* **When does Error Prediction run?**

Error Prediction is automatically triggered by the following GitHub pull\_request webhook events:

* `opened`: when you open a new pull request (we skip those opened in `draft` state)
* `ready_for_review`: when a draft pull request is marked as “Ready for review”

To manually run error prediction and get a general review, comment `@sentry review` in the PR.
