PR-Agent: Open-Source AI Code Review Tool
PR-Agent is an open-source AI code reviewer that runs as a GitHub Action or CLI, supporting GitHub, GitLab, Bitbucket, and Azure DevOps. It generates PR descriptions, reviews code, suggests improvements, and answers questions using GPT, Claude, Gemini, or DeepSeek — you pay only for API calls. Worth using if you need self-hosted, customizable PR automation; skip it if you want a plug-and-play hosted solution.
What is PR-Agent?
PR-Agent is an open-source AI PR reviewer that attaches to your GitHub, GitLab, Bitbucket, Azure DevOps, or Gitea repository and automatically reviews pull requests. It responds to slash commands like /describe, /review, /improve, and /ask, generating PR descriptions, security and quality feedback, code improvement suggestions, and free-text Q&A about the diff. The tool runs a single LLM call per operation (~30 seconds) and feeds your project's AGENTS.md conventions to the model by default since v0.39.0, so it picks up team style without extra configuration.
Core tools and capabilities
- ✓Four slash-command tools: /describe (PR title, summary, walkthrough, labels), /review (findings, security, effort estimate), /improve (code suggestions), and /ask (free-text Q&A on the diff)
- ✓Multi-platform support: GitHub, GitLab, Bitbucket, Azure DevOps, and Gitea
- ✓Multi-AI provider support: OpenAI GPT, Anthropic Claude, Google Gemini, DeepSeek, Mistral, and any model reachable via LiteLLM (Azure OpenAI, AWS Bedrock, Vertex AI, Ollama, OpenRouter)
- ✓PR compression strategy that handles large diffs by intelligently trimming context to fit token limits
- ✓Project conventions via AGENTS.md, SKILL.md, and organization-level configuration — automatically fed to the model since v0.39.0
- ✓JSON-based prompting and TOML configuration for full customization of review categories, output formats, and enabled tools
- ✓Deployment flexibility: GitHub Actions, CLI, Docker, GitHub App/webhook, or self-hosted webhook
- ✓Self-reflection mechanism to reduce hallucination and improve review consistency
When to run PR-Agent on your pull requests
- •Automated first-pass code review on every pull request to catch bugs, security issues, and code quality problems before human review
- •Generating consistent PR descriptions and changelog entries without manual writing
- •Asking questions about a large diff — e.g., 'what does this PR change architecturally?' — without reading the whole codebase
- •Enforcing team conventions via custom AGENTS.md files that the model reads automatically on every review
- •Multi-platform teams that use different git providers across projects but want a single review tool
- •Cost-sensitive teams that want AI-assisted review without per-seat SaaS pricing
Installing PR-Agent as a GitHub Action
For GitHub Actions, add a workflow file at `.github/workflows/pr-agent.yml` that triggers on `pull_request` events (opened and synchronize types). Set `OPENAI_KEY` and `GITHUB_TOKEN` as environment variables — the token is auto-injected by GitHub. Reference the action as `uses: the-pr-agent/pr-agent@main`. For local CLI use, install via `pip install "pr-agent @ git+https://github.com/The-PR-Agent/[email protected]"` (the PyPI version is temporarily behind). Docker and webhook setups are documented for GitLab, Bitbucket, and Azure DevOps.
Running PR-Agent from the CLI
On GitHub, comment `/describe`, `/review`, `/improve`, or `/ask "your question"` directly on a PR. From the CLI: `pr-agent --pr_url https://github.com/owner/repo/pull/123 review` (or replace `review` with `describe`, `improve`, `ask`). Environment variables `OPENAI_KEY` and `GITHUB_TOKEN` must be set for CLI use. Configuration lives in `pr_agent/settings/configuration.toml` for custom prompts, categories, and tool toggles.
What PR-Agent does well
- ✓Full data control — you provide the AI API key and review data never leaves your infrastructure
- ✓Multi-platform out of the box: GitHub, GitLab, Bitbucket, Azure DevOps, and Gitea with consistent tooling
- ✓Single-LLM-call operations keep costs low: ~30 seconds and one API request per tool invocation
- ✓AGENTS.md conventions are automatically included in prompts since v0.39.0, requiring no extra configuration
- ✓Highly customizable via TOML configuration and JSON-based prompting — change categories, add custom checks, or retarget the model
- ✓Plain-diff provider available for diffs that don't fit standard token limits, with CI artifact context injection
Known limitations and considerations
- △Self-hosted means you manage API credentials, costs, and uptime — no managed tier with SLA
- △/help_docs is disabled beginning with v0.36.1 due to a pending fix for the credential-exposure issue (issue #2445)
- △Full customization requires editing TOML configs and understanding the prompting model — not truly zero-config
- △Docker Hub namespace migration in v0.34.2 requires updating pinned image references from `codiumai/pr-agent` to `pragent/pr-agent` when upgrading
- △PyPI publishing is temporarily behind — `pip install pr-agent` installs 0.39.0 instead of the current v0.42.0, so direct GitHub install is required for the latest version
Alternatives to PR-Agent
Who should use PR-Agent
PR-Agent fits teams that need AI-assisted code review with full data control and no per-seat pricing. It's well-suited for open-source maintainers, privacy-conscious enterprises, and teams running across multiple git providers. Organizations with well-defined coding conventions benefit most from the AGENTS.md auto-loading feature. Teams wanting a five-minute setup with no configuration should look at hosted alternatives instead.
Frequently asked questions
PR-Agent itself is MIT-licensed and free. You need to provide your own AI API key — OpenAI, Anthropic, or any LiteLLM-compatible provider — and pay their per-token rates. Self-hosting means you control costs entirely.
Anthropic Claude (including Opus 5 and Sonnet 5), Google Gemini (3.6), DeepSeek, and Mistral are explicitly supported. Any model reachable through LiteLLM works too — Azure OpenAI, AWS Bedrock, Vertex AI, Ollama, and OpenRouter are listed examples.
Add your API key as a repository or organization secret (e.g., OPENAI_KEY), reference it in the GitHub Actions env block, and set GITHUB_TOKEN to Secrets.GITHUB_TOKEN. Restricted mode in configuration.toml reduces required GitHub permissions for tighter security.
Yes. GitLab webhook setup and Bitbucket app installation are documented at docs.pr-agent.ai. Both support the /describe, /review, /improve, and /ask tools. Line-specific /ask is GitHub and GitLab only.
Its PR compression strategy adaptively trims diff context to fit token limits, handling both small and large PRs in a single LLM call. A plain-diff provider is also available for diffs that don't fit standard contexts, with CI artifact injection for additional context.
Yes. JSON-based prompting and TOML configuration at pr_agent/settings/configuration.toml control which categories are checked, how feedback is structured, and which tools are enabled. Organization-level settings and AGENTS.md files let you encode team conventions per repo.
Related repositories
Want a second opinion on pr-agent?
Ask an AI that can read this page — one click and you get its take on pr-agent.
