This guide walks you through building an AI-powered code review pipeline that runs on every PR. By the end you'll have a working .visor.yaml that reviews code for security, style, and bugs.
- Node.js 18+
- An AI provider API key (Google, Anthropic, or OpenAI)
npm i -D @probelabs/visor
npx visor initThis creates a .visor.yaml with inline documentation. You can start from scratch too — here's the minimal version:
version: "1.0"
ai_provider: google # or: anthropic, openai, bedrock
steps:
review:
type: ai
prompt: "Review the code changes for bugs and security issues."Run it: npx visor
Split your review into focused steps that run in parallel:
version: "1.0"
ai_provider: google
steps:
security:
type: ai
prompt: "Find security vulnerabilities in the changed code."
ai:
system_prompt: "You are a security expert. Focus on OWASP Top 10."
tags: [security, fast]
style:
type: ai
prompt: "Check code style and naming conventions."
tags: [style, fast]
architecture:
type: ai
prompt: "Review architectural decisions and suggest improvements."
tags: [architecture]Run only fast checks: npx visor --tags fast
Mix AI steps with real tooling:
lint:
type: command
exec: npx eslint --format json src/
tags: [fast, lint]
tests:
type: command
exec: npm test -- --coverage --json
tags: [fast, test]Command steps auto-parse JSON output — no parseJson flag needed.
summary:
type: ai
prompt: |
Summarize all review findings:
Security: {{ outputs["security"] | json }}
Style: {{ outputs["style"] | json }}
Lint: {{ outputs["lint"] | json }}
Tests: {{ outputs["tests"] | json }}
depends_on: [security, style, lint, tests]
tags: [summary]Steps without depends_on run in parallel. Steps with dependencies wait.
Create .github/workflows/visor.yml:
name: Visor Code Review
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
checks: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: probelabs/visor@v1
env:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}Visor will post review comments directly on the PR.
Fail the CI check if critical issues are found:
summary:
type: ai
# ...
fail_if: "output.issues && output.issues.some(i => i.severity === 'critical')"See examples/quick-start-tags.yaml for a working config, or examples/enhanced-config.yaml for advanced features.
| Mistake | Fix |
|---|---|
system_prompt at step level |
Put it inside ai: block, or use ai_system_prompt |
Top-level ai: block |
Use ai_provider and ai_model at top level |
parseJson: true on command steps |
Not needed — commands auto-parse JSON |
provider: at step level |
Use ai_provider or put it inside ai: block |
Run npx visor validate to catch these early.
- AI Configuration — providers, retry, fallback
- Failure Routing — auto-remediation on failures
- Testing — write tests for your pipeline
- Tag Filtering — organize steps with tags