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

# Add an AI security code review to every pull request

> Get a security review on each GitHub pull request: turn on Autopilot security review for a repository, then read the findings it posts by severity, with evidence and a fix.

By the end of this guide, the pull requests in a repository you pick each get one security review from an AI reviewer. It threat-models the diff and posts its findings grouped by severity. Each finding names a `path:line`, says whether it is confirmed or suspected, and carries evidence, an exploit sketch and a fix.

This is `autopilot-security-review`, one of the [Autopilot](https://docs.reliantlabs.io/guides/autopilot.md) built-ins. You turn it on rather than write it. Unlike [PR review](https://docs.reliantlabs.io/guides/workflows/review-pull-requests-with-ai.md), it needs a machine with a clone of the repository: the reviewer reads the code around the diff in that checkout, read-only.

## Before you begin

* The `reliant` CLI, v1.21 or later, signed in ([Sign in and tokens](https://docs.reliantlabs.io/cli/sign-in.md)), and `gh` for the GitHub side.
* The Reliant GitHub App installed on the repository ([GitHub integration](https://docs.reliantlabs.io/integrations/github.md#access)).
* A [machine](https://docs.reliantlabs.io/guides/machines/connect-computer-as-machine.md) that is online and holds a clone of the repository.
* In an organization: an organization AI account that can run the `powerful` model tag. See [What this does not do](#what-this-does-not-do).

**1. See what it will do before you turn it on**

The workflow's scenarios run its control flow with the model and GitHub mocked, at no cost. Each shows one path: a draft is skipped, a head commit is reviewed once.

```bash terminal theme={null}
reliant workflow scenario run --include-builtins | grep autopilot-security-review
```

```text theme={null}
  ✓ autopilot-security-review/closed_pr_skipped (7ms)
  ✓ autopilot-security-review/comment_re_reviews_an_already_reviewed_head (12ms)
  ✓ autopilot-security-review/draft_pr_skipped_on_an_event (7ms)
  ✓ autopilot-security-review/findings_post_one_comment_grouped_by_severity (17ms)
  ✓ autopilot-security-review/head_already_reviewed_is_skipped (7ms)
  ...
```

19 scenarios pass. [Test workflows with scenarios](https://docs.reliantlabs.io/guides/workflows/test-workflows-with-scenarios.md) explains the format.

**2. Create a project on the machine's clone**

Run this in the clone, on the machine the reviews will run on. The workflow looks for a checkout whose `origin` remote is the pull request's repository, either at the project root or in a subfolder named after the repository.

```bash terminal theme={null}
cd ~/src/acme-api
git remote get-url origin        # must be github.com/acme/api
reliant project create --name acme-api
```

`project create` prints the project ID. The pull request's own files are read from GitHub at its head commit; this checkout is never changed.

**3. Turn on security review**

`--machine` takes a daemon ID or hostname from `reliant machine list`. `require_labels` makes it opt-in: only pull requests carrying `security-review` are reviewed. Leave it out to review every non-draft pull request on every push.

```bash terminal theme={null}
reliant trigger activate --workflow builtin://autopilot-security-review \
  --machine build-box --project-id <project-id> \
  --param 'repos=["acme/api"]' \
  --param 'require_labels=["security-review"]' \
  --param 'review_guidance=The public API is internet-facing. Every query must be scoped by org_id.' \
  --name-prefix "acme-api · security-review"
```

It prints one row per declared trigger: `pr-updated`, `label-added` and `review-comment`. They turn on together, or none do. `review_guidance` is your threat model. Every setting is in [Autopilot settings](https://docs.reliantlabs.io/guides/autopilot.md#security-review). In the app, this is **Workflows → Library → Autopilot · security review → Set up**.

**4. Ask for a review**

Open a pull request and add the label, or comment `/autopilot security-review` on any open pull request, a draft included. Only you and the accounts in `trusted_ids` can ask by comment.

```bash terminal theme={null}
gh pr create --title "Add task search" --body "Search tasks by title." --label security-review
reliant trigger list                       # find the label-added activation's ID
reliant trigger events <activation-id>
```

A `launched` row means the review started. Follow it with `reliant workflow follow <chat>` or under **Workflows → Runs**.

**5. Read the findings**

```bash terminal theme={null}
gh pr view --comments
```

Look for one review comment, headed **🛡️ Security review**, at the pull request's head commit. It opens with a count, such as "2 finding(s): 1 critical, 0 high, 1 medium, 0 low (1 confirmed)", and the reviewer's summary. Then come the findings, grouped Critical, High, Medium and Low. Each finding shows:

* **Confirmed** (the path from attacker input to the vulnerable code was traced) or **Suspected** (the reviewer could not trace one link in that path, and says which), the title, `path:line` and category
* **Evidence**, an **Exploit sketch** and a **Fix**

A collapsed **What was checked** section lists each area it covered and the dependency advisory lookups. A scope note closes the review: the review read code only, nothing was run against live systems, and it is not a penetration test. A clean pull request gets "No security findings in the changed code."

**6. Turn it off**

Pass `--project-id`. Without it, `deactivate` pauses this workflow in every project you own.

```bash terminal theme={null}
reliant trigger deactivate --workflow builtin://autopilot-security-review --project-id <project-id>
```

## What this does not do

* **It is not a guarantee.** The findings are advisory: a model reading code can miss a vulnerability or flag one that is not exploitable, which is why each finding says confirmed or suspected. Keep your own scanners, dependency checks and human review for security-sensitive changes.
* **It never approves, requests changes or merges.** The workflow posts the review with the literal event `COMMENT`, and the reviewer has no GitHub write tools. Autopilot never merges; a person does.
* **It does not run your code or touch live systems.** The reviewer is told never to build, test, install or execute the repository, and never to scan or probe a host. Its shell runs with no credentials. Its only network calls are advisory lookups for changed dependencies. [Agents in production](https://docs.reliantlabs.io/deep-dives/agents-in-production.md) explains these limits.
* **It has no budget of its own.** Each review can take up to 50 turns (`max_turns`) on the `powerful` tag. Without `require_labels`, every push to every non-draft pull request is reviewed. See [What it costs](https://docs.reliantlabs.io/guides/autopilot.md#what-it-costs).
* **In an organization, runs spend only the organization's AI accounts** by default. A person can allow their own accounts on the automation in the app, or an admin can add an organization account.

## Troubleshooting

> [accordion] No checkout of acme/api was found under …
>
> The run found no clone whose `origin` is the repository at the project root or in a subfolder named after it. It fails, and posts a note on the pull request once per head commit. Clone the repository into the project, or activate on the project and machine that hold it.

> [accordion] Not reviewing acme/api#12: its head commit … already has a security review
>
> Each head commit is reviewed once. Push a commit, or comment `/autopilot security-review` to review the same commit again.

> [accordion] Not reviewing acme/api#12: it carries none of the labels security-review
>
> `require_labels` is set and the pull request has no matching label. Add the label, which also starts a review.

## Next steps

> [card] [Review every pull request with an AI agent](https://docs.reliantlabs.io/guides/workflows/review-pull-requests-with-ai.md)
>
> The general code reviewer, which needs no machine.

> [card] [Run a scheduled vulnerability scan](https://docs.reliantlabs.io/guides/workflows/nightly-dependency-security-sweep.md)
>
> Scan the whole repository on a schedule and file GitHub issues.

> [card] [Autopilot reference](https://docs.reliantlabs.io/guides/autopilot.md)
>
> Every setting, label and cost of the Autopilot workflows.

> [card] [Agents in production](https://docs.reliantlabs.io/deep-dives/agents-in-production.md)
>
> What unattended agents can and cannot reach.


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