> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datafold.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Code Reviews

> Get automated, AI-powered code reviews on every pull request to catch SQL and data pipeline issues before they reach production.

AI Code Reviews add automated code review to your CI pipeline. Datafold checks the SQL in each pull request against a set of style and best-practice rules for your organization, and posts its findings as inline comments with suggested changes.

When combined with [Data Diffs](https://docs.datafold.com/classic/deployment-testing/how-it-works.md), AI Code Reviews give your team both **code-level** and **data-level** validation on every PR.

> [!NOTE]
>
> AI Code Reviews are an optional add-on to Datafold's CI integration. If you prefer to use only Data Diffs, no changes are needed — your existing CI setup continues to work as before.

## How It Works

**1. The first CI run finishes**

The review runs once per pull request, after the first Datafold CI run for that PR finishes. Later commits to the same PR are not re-reviewed.

**2. Changed code is checked against your rules**

Datafold analyzes the changed code against your organization's rule set and removes duplicate findings.

**3. Feedback is posted to the PR**

Findings are posted as inline review comments, with suggested changes, on the changed lines (up to 20 per pull request).

## What AI Code Reviews Check

AI Code Reviews check each pull request against SQL style and best-practice rules that Datafold configures for your organization. For example, a rule set can prefer CTEs over subqueries, or explicit `INNER JOIN` over comma joins. Contact [Datafold support](mailto:support@datafold.com) to define your rule set.

AI Code Reviews are supported for GitHub and GitLab repositories.

## AI Code Reviews + Data Diffs

AI Code Reviews and Data Diffs complement each other:

| | AI Code Reviews | Data Diffs |
| - | - | - |
| **What it checks** | The code itself, against your rule set | The actual data output (row and column-level differences) |
| **When it runs** | After the first CI run for the PR completes | After staging data is built |
| **What it catches** | Style and best-practice violations | Unintended data changes, row count shifts, value drift |

Used together, they provide code-level and data-level validation for each pull request.

## Enabling AI Code Reviews

AI Code Reviews require Datafold's CI integration to be set up with your Git provider and data warehouse. To enable the feature:

1. Ensure your [Git provider](https://docs.datafold.com/classic/integrations/code-repositories.md) and [data warehouse](https://docs.datafold.com/classic/integrations/databases.md) are connected in Datafold.
2. Verify your CI configuration is set up under **Settings > Integrations > CI**.
3. Contact [Datafold support](mailto:support@datafold.com) to enable AI Code Reviews and define your rule set.

Once enabled, AI Code Reviews run automatically after the first CI run for each new pull request — no additional CI pipeline changes are required.

## Using Data Diffs Only

If your team prefers to use only Data Diffs without AI Code Reviews, no action is needed. Your existing CI configuration will continue to run Data Diffs as before. AI Code Reviews are an opt-in feature and do not affect Data Diff behavior.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.