GGA can run in any CI/CD pipeline to review code changes on pull requests and merge requests. Two flags control how GGA identifies which files to review in a pipeline context.
Choosing the right flag
| Flag | What it reviews | When to use |
|---|
--ci | Files changed in the last commit (HEAD~1..HEAD) | Reviewing the most recent push in any pipeline |
--pr-mode | All files changed across the full PR/MR diff | Reviewing everything in a pull or merge request |
Both flags disable caching automatically, since each CI run starts from a clean state.
For pull request workflows, --pr-mode gives a complete picture of the change. For push-triggered pipelines that run on every commit, --ci is faster and cheaper.
Provider configuration in CI
Set your provider and API key via environment variables or CI secrets so they are not stored in source control:
# Override provider at runtime
GGA_PROVIDER=claude gga run --pr-mode
# Override timeout
GGA_TIMEOUT=600 gga run --ci
Store API keys (such as ANTHROPIC_API_KEY, GEMINI_API_KEY) as encrypted secrets in your CI platform and pass them to the job environment.
GitHub Actions
Create the workflow file
Create .github/workflows/ai-review.yml in your repository.
Add the workflow configuration
.github/workflows/ai-review.yml
name: Gentleman Guardian Angel
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Gentleman Guardian Angel
run: |
git clone https://github.com/Gentleman-Programming/gentleman-guardian-angel.git /tmp/gga
chmod +x /tmp/gga/bin/gga
echo "/tmp/gga/bin" >> $GITHUB_PATH
- name: Install Claude CLI
run: |
# Install your preferred provider CLI
npm install -g @anthropic-ai/claude-code
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Run AI Review
run: |
# Review all files changed in the PR
gga run --pr-mode
# Or with diffs only (faster, cheaper)
# gga run --pr-mode --diff-only
fetch-depth: 0 is required for --pr-mode. Without it, the shallow clone will not contain the base branch history needed to compute the PR diff.
GitLab CI
Add the CI job to your pipeline
Add the following job to your .gitlab-ci.yml:
Configure the job
gga:
stage: test
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y git curl
- git clone https://github.com/Gentleman-Programming/gentleman-guardian-angel.git /opt/gga
- export PATH="/opt/gga/bin:$PATH"
# Install your provider CLI here
script:
- git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA | xargs git add
- gga run
only:
- merge_requests
The GitLab example stages the changed files manually using CI_MERGE_REQUEST_DIFF_BASE_SHA before calling gga run. This is necessary because there is no interactive staging area in CI — the xargs git add step replicates what a developer would stage locally.
General guidance
- Any pipeline, last commit: use
gga run --ci
- Pull/merge request review: use
gga run --pr-mode
- Reduce cost on large PRs: add
--diff-only to --pr-mode to send only unified diffs instead of full file contents
- Override provider: set the
GGA_PROVIDER environment variable in your job
- API keys: add provider API keys (e.g.
ANTHROPIC_API_KEY) as encrypted CI secrets and expose them in the job environment