Skip to content

Start here

OverviewConnect your agentClient onboarding

Guides

WorkspacesScan manualGitHub PR reviewsFix ReviewScheduled scans

Reference

CLI guideService APIClient operations

For agents

docs/agents.mdllms.txt
Apex/Docs
⌘K
Connect your agent

Start here

OverviewConnect your agentClient onboarding

Guides

WorkspacesScan manualGitHub PR reviewsFix ReviewScheduled scans

Reference

CLI guideService APIClient operations

For agents

docs/agents.mdllms.txt
Docs/Running scans/GitHub PR reviews

Review GitHub pull requests

Have Apex review a pull request before it merges: comment on the PR, or start reviews from GitHub Actions.

10 min readUpdated Dec 3, 2026Repository owners

01Ways to review pull requests

Apex reviews a pull request with a PR scan: a focused security review of the changed code that follows nearby code only as needed to judge trust boundaries and exploitability. You do not need to run a full scan first.

PR commentA repository collaborator comments @cantina-apex review this PR. Apex shows progress in an Apex PR Scan check and posts the result as a PR comment.
GitHub ActionsA workflow starts a review when a pull request opens, waits for it, and links the result in the job summary. It authenticates with an Apex service key.
Apex app or CLIChoose PR Scan in the workspace Run scan dialog, or run apex scan --mode pr --pr <number>. Results appear in Apex.

Key idea

Comment on a pull request when a change needs a security review. Add the workflow when every pull request should get one. A PR scan covers the diff; run a full scan for whole-system coverage.

02Which guide covers what

Setup spans a few guides. Each one covers a different step.

Client onboardingInstall the GitHub App, approve repository access, and create a workspace.
Scan manualWhat a PR scan reviews, when to use one, and when to run a full scan instead.
GitHub PR reviews (this page)The PR comment command, results on the pull request, the GitHub Actions workflow, and troubleshooting.
CLI guideStart a PR scan from a terminal or coding agent with apex scan --mode pr.
Service APICreate the service key the workflow uses, poll scan status, and fetch findings.
Client operationsThe full input schema for workspace-scan, the operation the workflow calls.

03Before you start

  • The Apex GitHub App (cantina-apex) is installed on the repository and connected to your Apex organization.
  • An active Apex workspace includes the repository. For comment reviews it must be the only one; if there is none, the first comment creates one named after the repository.
  • Your organization has standard credits. Each PR review uses 25 standard credits.
  • For comment reviews, the person commenting is a collaborator on the repository.
  • For GitHub Actions, a company manager can create an Apex service key, and you can add repository secrets and variables on GitHub.

Set up the workspace first

PR reviews use the workspace's context, such as repository docs and notes, and a workspace created by a comment starts with none. Follow GitHub onboarding to connect GitHub and create the workspace before the first review.

Repositories split across workspaces

A comment cannot choose between several workspaces that include the same repository. Start those PR scans from the workspace in Apex, or from the workflow with an explicit workspace ID.

04Review from a PR comment

Open the pull request on GitHub and add a new comment whose first line is the command:

Pull request comment
@cantina-apex review this PR

When the risky part of the change is not obvious from the changed files, add a focus hint after the command or on the next lines:

Pull request comment
@cantina-apex review this PR
Focus on the signature checks in src/permit.ts and the new withdrawal limit.
  • @cantina-apex scan this PR and @cantina-apex run pr scan work the same way, and the command is not case-sensitive.
  • Only a new comment starts a review. Editing an earlier comment does not.
  • Only repository collaborators can start a review. Apex replies to anyone else without starting a scan.
  • Apex adds an Apex PR Scan check to the pull request as soon as it accepts the command.

05Read the result

  • The Apex PR Scan check shows the current stage and progress. Its Details link opens the scan in Apex.
  • When the review finishes, Apex posts a comment headed Apex PR Scan with the outcome, each validated finding with its severity, and links to the findings and the scan. Later reviews of the same pull request update that comment.
  • The check is advisory: it completes as neutral and never blocks a merge, even when Apex reports findings.
  • The scan and its findings also stay in the Apex workspace.

To review new commits, push them and comment again. If Apex already reviewed the pull request's current head commit, it reuses that result instead of starting a new scan, and a command sent while a review is running does not start a second one.

Large pull requests

PR scans work best on up to 150 changed files and 5,000 changed lines. Apex still reviews a larger pull request, but its comment recommends a full scan for broader coverage.

06Run reviews from GitHub Actions

Use this workflow when every pull request should get a review without anyone commenting. It starts a PR scan through the service API when a pull request opens or leaves draft, waits for the result, and links the scan in the job summary.

  1. 1
    Create a service key
    A company manager generates one in Apex company Settings under Service API keys, with only the scans:create and scans:read scopes and an expiration. The workflow never reads findings, so leave findings:read off. The key acts with its creator's Apex permissions.
  2. 2
    Find the workspace ID
    Run the lookup below with the new key and copy the workspaceId of the workspace that includes the repository.
  3. 3
    Find the GitHub App installation ID
    On GitHub, open github.com/organizations/<org>/settings/installations, or github.com/settings/installations for a personal account, and select Configure next to the Apex app. The number at the end of the page URL is the installation ID.
  4. 4
    Add the secret and variables
    In the repository, open Settings > Secrets and variables > Actions. Save the key as the APEX_SERVICE_KEY secret, and add the APEX_WORKSPACE_ID and APEX_GITHUB_INSTALLATION_ID variables.
  5. 5
    Add the workflow
    Commit the workflow below to the default branch as .github/workflows/apex-pr-review.yml.

Protect the service key

Service keys belong to the whole Apex organization, so this key can start scans in every workspace, not only this repository's. Anyone who can push a branch to the repository can change the workflow and read the secret. Use a dedicated key with only scans:create and scans:read and an expiration, and revoke it when you remove the workflow.

Workspace lookup

GET /api/apex/v1/workspaces
curl --fail-with-body --silent --show-error \
  --header "Authorization: Bearer $APEX_SERVICE_KEY" \
  'https://ai.cantina.xyz/api/apex/v1/workspaces?repository=acme%2Fpayments'

Workflow

.github/workflows/apex-pr-review.yml
name: Apex PR review

on:
  pull_request:
    # Add synchronize to review every push. Each review uses 25 standard credits.
    types: [opened, ready_for_review]

permissions:
  contents: read

jobs:
  apex-pr-review:
    # GitHub gives pull requests from forks and Dependabot no Actions secrets, so skip them, and drafts.
    if: >-
      ${{ !github.event.pull_request.draft &&
      github.event.pull_request.head.repo.full_name == github.repository &&
      github.actor != 'dependabot[bot]' }}
    runs-on: ubuntu-latest
    # The scan keeps running in Apex if the job times out.
    timeout-minutes: 120
    defaults:
      run:
        shell: bash
    env:
      APEX_API: https://ai.cantina.xyz/api/apex/v1
      APEX_SERVICE_KEY: ${{ secrets.APEX_SERVICE_KEY }}
    steps:
      - name: Start the Apex PR scan
        id: start
        env:
          WORKSPACE_ID: ${{ vars.APEX_WORKSPACE_ID }}
          INSTALLATION_ID: ${{ vars.APEX_GITHUB_INSTALLATION_ID }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
        run: |
          : "${APEX_SERVICE_KEY:?Add the APEX_SERVICE_KEY repository secret}"
          : "${WORKSPACE_ID:?Add the APEX_WORKSPACE_ID repository variable}"
          : "${INSTALLATION_ID:?Add the APEX_GITHUB_INSTALLATION_ID repository variable}"
          jq -n \
            --arg workspaceId "$WORKSPACE_ID" \
            --arg repoUrl "https://github.com/$GITHUB_REPOSITORY" \
            --argjson installationId "$INSTALLATION_ID" \
            --argjson pullRequestNumber "$PR_NUMBER" \
            '{workspaceId: $workspaceId, authorized: true, payload: {mode: "pr",
              repositories: [{provider: "github", repoUrl: $repoUrl,
                installationId: $installationId, sourceType: "pr",
                pullRequestNumber: $pullRequestNumber}]}}' > request.json
          # Starting a scan uses credits, so this request is never retried.
          if ! curl --silent --show-error --fail-with-body --output start.json \
            --header "Authorization: Bearer $APEX_SERVICE_KEY" \
            --header "Content-Type: application/json" \
            --data @request.json "$APEX_API/client/workspace-scan"; then
            echo "::error::Apex did not start the scan: $(cat start.json)"
            exit 1
          fi
          scan_id=$(jq -er .scanId start.json)
          echo "Started Apex scan $scan_id."
          echo "scan_id=$scan_id" >> "$GITHUB_OUTPUT"

      - name: Wait for the result
        env:
          SCAN_ID: ${{ steps.start.outputs.scan_id }}
        run: |
          # Keep polling through transient API errors: re-running the job would start a new scan.
          while :; do
            code=$(curl --silent --show-error --max-time 60 --output scan.json \
              --write-out '%{http_code}' \
              --header "Authorization: Bearer $APEX_SERVICE_KEY" \
              "$APEX_API/scans/$SCAN_ID") || code=000
            case "$code" in
              200) ;;
              401|403|404)
                echo "::error::Apex returned HTTP $code for scan $SCAN_ID: $(cat scan.json)"
                exit 1 ;;
              *)
                echo "::warning::Could not read the status of scan $SCAN_ID (HTTP $code). Retrying."
                sleep 60
                continue ;;
            esac
            status=$(jq -r .status scan.json)
            echo "Apex scan status: $status"
            case "$status" in
              completed) break ;;
              preparing|queued|running) sleep 60 ;;
              *) echo "::error::The Apex PR scan ended with status $status."; exit 1 ;;
            esac
          done
          # Findings stay in Apex; job summaries are public on public repositories.
          scan_url=$(jq -r '.scanUrl // "https://ai.cantina.xyz"' scan.json)
          {
            echo "### Apex PR scan"
            echo
            echo "Scan $SCAN_ID finished. [Open the findings in Apex]($scan_url)."
          } >> "$GITHUB_STEP_SUMMARY"
  • Each run starts a new PR scan and uses 25 standard credits, including a re-run of the job. If a run fails while waiting, follow the scan in Apex instead of re-running it.
  • Add synchronize to the trigger types to review every push.
  • The job waits on the runner while Apex reviews the change, then links the scan in the job summary. Delete the Wait for the result step to only start reviews.
  • Draft pull requests wait until they are marked ready. Pull requests from forks and runs that Dependabot triggers are skipped because GitHub does not give them Actions secrets.
  • A scan started from the workflow does not post the Apex PR Scan check or comment. Its findings stay in Apex.

Keep findings out of public logs

Job summaries, logs and artifacts are public on public repositories, so the workflow posts only a link to the scan. The findings export includes unpublished drafts. If you fetch it in CI, keep the output private.

Other CI systems

Any pipeline can start the same review with this request. Apex returns the scanId; poll GET /api/apex/v1/scans/{scanId} until it is terminal, then fetch /findings as the service API guide describes.

POST /api/apex/v1/client/workspace-scan
curl --fail-with-body --silent --show-error \
  --request POST https://ai.cantina.xyz/api/apex/v1/client/workspace-scan \
  --header "Authorization: Bearer $APEX_SERVICE_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "workspaceId": "<workspace-id>",
    "authorized": true,
    "payload": {
      "mode": "pr",
      "repositories": [{
        "provider": "github",
        "repoUrl": "https://github.com/acme/payments",
        "installationId": 12345678,
        "sourceType": "pr",
        "pullRequestNumber": 42
      }]
    }
  }'

Replace the workspace ID, repository URL, installation ID, and pull request number with your own. authorized: true confirms the credit use; Apex rejects paid requests without it. Do not retry this request automatically, because each accepted request starts a scan. A pull request over the preferred size also returns fullScanRecommendation. The client operations reference has the full input schema.

07Troubleshooting

Apex replies on the pull request when it cannot start a review. Find its message below.

No check and no reply after a commentWrite the command on the first line of a new comment, and confirm the Apex GitHub App is installed on the repository.
Apex PR scans can only be started by repository collaboratorsAsk someone with access to the repository to comment, or add the person as a collaborator.
Apex could not find this repository in your Apex accountConnect GitHub to your Apex organization, then comment again.
Apex found more than one matching setup for this repositoryMore than one active workspace includes the repository. Archive the extra workspaces or remove the repository from them, then comment again.
Apex does not have enough standard credits for this PR ReviewAdd standard credits in Apex, then comment again. The reply links to your billing page.
Apex PR scan comment commands are disabled for this workspaceStart the PR scan from the workspace in Apex instead.
This GitHub App connection belongs to a different Apex accountReconnect GitHub from the Apex organization that owns the workspace, then comment again.
Apex scanning is disabled for this repositoryScanning is turned off for your Apex organization. Contact Cantina to turn it back on.
Workflow fails with HTTP 401 or 403Check that APEX_SERVICE_KEY holds a current key with the scans:create and scans:read scopes, created by someone who can still start scans in the workspace.
Workflow fails with HTTP 400 or 404Check the APEX_WORKSPACE_ID and APEX_GITHUB_INSTALLATION_ID variables. The response says what Apex rejected.
Workflow fails with HTTP 402Your organization is out of standard credits. Add credits in Apex, then re-run the job.
Was this useful?
Last updated Dec 3, 2026 · v2026.12
← PreviousApex scan manualNext →Fix Review workflow

On this page

  1. Ways to review pull requests
  2. Which guide covers what
  3. Before you start
  4. Review from a PR comment
  5. Read the result
  6. Run reviews from GitHub Actions
  7. Troubleshooting

Related

Apex scan manualClient onboardingApex service APIApex CLI guide