Git Guardian Angel (GGA) is an intelligent code review system that works seamlessly with Code Review Guardian to provide automated code reviews across different Git providers.
Git Guardian Angel is a provider-agnostic system that:
- ✅ Works with GitHub, GitLab, Bitbucket, and any Git provider
- ✅ Automatically reviews code in pull requests and merge requests
- ✅ Provides actionable feedback and suggestions
- ✅ Integrates with your existing CI/CD pipeline
- ✅ Supports multiple AI agents for code review
composer require --dev nowo-tech/code-review-guardianAdd your Git provider token to .env:
# Required: Git Provider API Token
GIT_TOKEN=your_token_hereSee TOKEN_SETUP.md for detailed step-by-step instructions on creating accounts and obtaining tokens for each provider.
The configuration file code-review-guardian.yaml is automatically installed. Update it to enable Git Guardian Angel:
# code-review-guardian.yaml
git:
provider: auto # auto-detects GitHub, GitLab, or Bitbucket
api_token_env: GIT_TOKEN # Reads from .env file
repository_url: auto # auto-detected from git remote
# Enable Git Guardian Angel
gga:
enabled: true
auto_review: true # Automatically review new PRs/MRs
post_comments: true # Post review comments
agents:
enabled: true
provider: openai # or anthropic, github_copilotAdd to your CI/CD pipeline (GitHub Actions example):
# .github/workflows/code-review.yml
name: Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Install dependencies
run: composer install
- name: Run Code Review Guardian
env:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
./code-review-guardian.sh --post-commentgit:
# Provider: auto, github, gitlab, bitbucket
provider: auto
# Environment variable name that contains the API token
api_token_env: GIT_TOKEN
# Repository URL (auto-detected if set to 'auto')
repository_url: autogga:
# Enable/disable Git Guardian Angel
enabled: true
# Automatically review new PRs/MRs
auto_review: true
# Post review comments to PRs/MRs
post_comments: true
# Review only changed files
review_changed_files_only: true
# Maximum number of comments per review
max_comments: 50
# AI Provider for GGA (codex, claude, gemini, ollama)
provider: codex
# File patterns to review
file_patterns:
- "*.php"
- "*.twig" # Symfony uses Twig, Laravel uses *.blade.php
# Patterns to exclude from review
exclude_patterns:
- "vendor/*"
- "var/*" # Symfony: var/, Laravel: storage/
- "public/build/*"
- "node_modules/*"
- "*.min.js"
- "*.map"
# Rules file (relative to project root)
rules_file: "docs/AGENTS.md"
# Strict mode: fail if response is ambiguous
strict_mode: trueSee AGENTS_CONFIG.md for detailed agent configuration.
-
Create Personal Access Token:
- Go to Settings → Developer settings → Personal access tokens → Tokens (classic)
- Generate token with
repoandpull_requestsscopes
-
Add to GitHub Secrets (for CI/CD):
- Go to repository Settings → Secrets and variables → Actions
- Add secret
GIT_TOKENwith your token
-
Local
.envfile (recommended for local development):GIT_TOKEN=ghp_your_token_here
Note: The script supports
.envand.env.localfiles..env.localtakes priority over.env. If the.envfile doesn't exist, it will be created automatically with a template.
-
Create Access Token:
- Go to Settings → Access Tokens
- Create token with
apiandwrite_repositoryscopes
-
Add to GitLab CI/CD Variables:
- Go to Settings → CI/CD → Variables
- Add variable
GIT_TOKENwith your token (masked)
-
Local
.envfile:GIT_TOKEN=glpat-your_token_here
-
Create App Password:
- Go to Personal settings → App passwords
- Create password with
Repositories: WriteandPull requests: Writepermissions
-
Add to Bitbucket Pipelines Variables:
- Go to Repository settings → Pipelines → Repository variables
- Add variable
GIT_TOKENwith your app password
-
Local
.envfile:GIT_TOKEN=your_app_password_here
The GGA configuration adapts automatically based on your framework. Here are the default patterns for each framework:
gga:
provider: codex
file_patterns:
- "*.php"
- "*.twig"
exclude_patterns:
- "vendor/*"
- "var/*"
- "public/build/*"
- "node_modules/*"
- "*.min.js"
- "*.map"
rules_file: "docs/AGENTS.md"
strict_mode: truegga:
provider: codex
file_patterns:
- "*.php"
- "*.blade.php"
exclude_patterns:
- "vendor/*"
- "storage/*"
- "public/build/*"
- "node_modules/*"
- "*.min.js"
- "*.map"
rules_file: "docs/AGENTS.md"
strict_mode: truegga:
provider: codex
file_patterns:
- "*.php"
exclude_patterns:
- "vendor/*"
- "node_modules/*"
- "*.min.js"
- "*.map"
rules_file: "docs/AGENTS.md"
strict_mode: trueYou can configure different AI providers for GGA:
- codex: Default provider (recommended)
- claude: Anthropic Claude
- gemini: Google Gemini
- ollama: Local Ollama instance
gga:
provider: claude # Change to your preferred providername: Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Install dependencies
run: composer install
- name: Run Code Review Guardian
env:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
./code-review-guardian.sh --post-comment# .gitlab-ci.yml
code_review:
only:
- merge_requests
script:
- composer install
- ./code-review-guardian.sh --post-comment
variables:
GIT_TOKEN: $GIT_TOKEN# bitbucket-pipelines.yml
pipelines:
pull-requests:
'**':
- step:
name: Code Review
script:
- composer install
- ./code-review-guardian.sh --post-comment- Verify
.envor.env.localfile exists and containsGIT_TOKEN - Check token is set correctly (no extra spaces)
- Remember:
.env.localtakes priority over.env - For CI/CD, verify token is in secrets/variables
- If
.envdoesn't exist, the script will create it automatically
- Verify token has correct permissions
- Check Git provider API rate limits
- Review logs for API error messages
- Set
providerexplicitly in configuration instead ofauto - Verify git remote URL is correct
- Never commit tokens: Use
.envfile (gitignored) or CI/CD secrets - Use least privilege: Only grant minimum required permissions
- Rotate tokens regularly: Update tokens periodically
- Monitor usage: Review API usage to detect anomalies
- AGENTS_CONFIG.md - AI Agent Configuration
- CONFIGURATION.md - Full Configuration Guide (in Code Review Guardian package)
- Code Review Guardian README - Main Documentation