Review code with Otto

Labs
This feature is in Labs.

Otto reviews your Airflow code automatically when you open a pull request or merge request. The Otto review action runs Otto with a dedicated reviewer persona, posts inline review comments where the code has issues, and offers commit suggestions where a concrete fix is available.

The review runs Otto with --persona reviewer. The persona bundles the Astro and Airflow review prompt, a read-only tool allowlist, plan-mode permissions, and a structured verdict schema, so Otto returns review results tuned for Airflow projects rather than generic code review. See Personas.

The action supports both GitHub and GitLab:

  • GitHub: A composite GitHub Action that runs on pull_request and posts the review to the pull request.
  • GitLab: A CI/CD template and Docker image that run on merge request events and post the review to the merge request.

What Otto reviews

Otto reviews changes against three layers of knowledge, so it catches issues that generic code review misses:

  • Astronomer compatibility knowledge: Version-specific operator behavior, provider compatibility, deprecated patterns, and failure signatures drawn from the Astronomer compatibility knowledge base. This is the same knowledge base that powers Airflow upgrades with Otto.
  • Airflow community standards: Current Dag patterns, testing approaches, and structure recommendations from the Apache Airflow community.
  • Your team’s conventions: Standards, retry policies, approved operators, and patterns captured in Otto Memory. Otto surfaces deviations from your conventions before they reach a human reviewer.

How it works

On each run, the action:

  1. Checks out the changed code and gathers the pull request or merge request metadata, the diff, and the prior review conversation.
  2. Runs astro otto --mode json --persona reviewer against the gathered context.
  3. Posts the result back to the pull request or merge request.

The reviewer persona returns a structured verdict with these fields:

  • verdict: approve, comment, or request_changes.
  • summary: A one-sentence summary of the change.
  • reasoning: One to three sentences on the change as a whole.
  • comments: Line-anchored findings, each with a severity of high, medium, or low and an optional commit suggestion.

On re-runs, the action edits its existing comments in place rather than re-posting. It keeps one sticky summary comment, updates or leaves its prior inline comments instead of duplicating them, and only re-posts the merge-gating review when the verdict changes.

Prerequisites

  • An Astro Organization API token. The token only needs the Organization member permission.
  • A GitHub repository or GitLab project that contains an Airflow project.

Set up the review action

On GitHub, the review runs as the Otto Review action from the GitHub Marketplace. Add it to a workflow that runs on pull requests. To get the latest version, click Use latest version on the Marketplace listing.

1

Add the workflow

In your repository, create a workflow file at .github/workflows/otto-review.yml with the following content:

.github/workflows/otto-review.yml
1name: Astronomer CI - Review Code
2on:
3 pull_request:
4 branches:
5 - main
6
7permissions:
8 contents: read
9 pull-requests: write
10
11env:
12 ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
13 ASTRO_ORGANIZATION: ${{ secrets.ASTRO_ORGANIZATION }}
14
15jobs:
16 review:
17 runs-on: ubuntu-latest
18 steps:
19 - name: Otto Review
20 uses: astronomer/otto-review-action@v0.2.0
2

Add the required secrets

In your repository, go to Settings > Secrets and variables > Actions and add the following repository secrets:

  • ASTRO_API_TOKEN: Your Astro Organization API token.
  • ASTRO_ORGANIZATION: Your Astronomer Organization ID.
3

Open a pull request

Open a pull request against the main branch. The action runs Otto, posts a sticky summary comment, and adds inline comments where it finds issues.

Run a review on demand

Code review also works outside a CI/CD pipeline. Run the reviewer persona from your terminal to review changes before you push, or to audit existing pipelines that haven’t been through a structured review:

$astro otto --persona reviewer "review the Dags in this project"

See astro otto for the full persona reference.

Configure the review

Both platforms accept settings that change how the review runs. On GitHub, pass them as action inputs under with:. On GitLab, set them as CI/CD variables. The most common settings are:

GitHub inputGitLab variableDescription
modelOTTO_MODELOverride the model Otto uses. The default uses the model that the reviewer persona’s tier maps to.
allowed-toolsOTTO_ALLOWED_TOOLSOverride the reviewer persona’s read-only tool allowlist (read, grep, find, ls, bash).
max-diff-linesOTTO_MAX_DIFF_LINESTruncate diffs longer than this value. The default is 50000.
dry-runOTTO_DRY_RUNWhen true, post the summary and inline comments but no merge-gating review.

For the complete list of inputs, variables, and outputs, see the otto-review-action repository.