AI-powered, GitHub-native pull request review automation.
Review your PRs automatically. Get actionable feedback directly where the code changed.
PR โ Diff โ AI Review โ Findings โ GitHub Comments
PR Review Agent is an automated AI code-review system that runs inside GitHub Actions whenever a pull request is opened or updated.
Instead of manually inspecting every changed file first, the agent handles the repetitive review workflow:
Important: The current M1โM5 implementation is a reviewer, not an autonomous code editor. It identifies problems and comments on them; the developer remains responsible for changing the code.
From the root of your GitHub repository:
npx @debangsu__/create-pr-review-agentYou don't need to manually clone the reviewer implementation first; the package can be fetched by npx.
The installer asks which model provider should perform reviews:
== AI PR Review Agent - installer ==
Installed:
.github/workflows/pr-review.yml
scripts/*.js
Which LLM will the agent use to review PRs?
1) Anthropic (Claude)
2) OpenAI (GPT)
Choose 1 or 2:
Choose the provider for which you have an API key.
The API key should be stored as a GitHub Actions repository secret.
Go to:
GitHub Repository
โ
Settings
โ
Secrets and variables
โ
Actions
โ
New repository secret
For Anthropic:
ANTHROPIC_API_KEY
For OpenAI:
OPENAI_API_KEY
๐ Never commit an API key into source code,
.envfiles, workflow YAML, README files, or PR comments.
The intended secret flow is:
๐ GitHub Secret
โ
โผ
โ๏ธ GitHub Actions
โ
โผ
๐งฉ Provider Adapter
โ
โผ
๐ง Claude / GPT
git add .
git commit -m "Add AI PR review agent"
git pushCreate a normal PR on GitHub.
That's it.
The workflow takes over automatically.
Here is the complete runtime workflow:
flowchart TD
A["๐จโ๐ป Developer opens / updates PR"] --> B["๐ GitHub PR event"]
B --> C["โ๏ธ GitHub Actions"]
C --> D["๐ฅ Fetch PR diff"]
D --> E["โ๏ธ Chunk diff by file"]
E --> F["๐งฉ Build review context"]
F --> G["๐ง Claude / GPT"]
G --> H["๐ฆ Structured findings"]
H --> I["๐๏ธ Apply severity threshold"]
I --> J{"๐ Exact line available?"}
J -->|Yes| K["๐ฌ Inline PR comment"]
J -->|No| L["๐ Summary / fallback comment"]
K --> M["๐จโ๐ป Human validates finding"]
L --> M
M --> N["โ๏ธ Human fixes code"]
N --> O["๐ค Push new commit"]
O --> B
The reviewer does more than blindly send the entire pull request to an LLM.
The agent retrieves the pull-request change set through GitHub's API.
PR
โโโ changed file A
โโโ changed file B
โโโ changed file C
โโโ ...
Large PRs are split into focused review units.
โโโ File A review
โ
PR diff โโโโโโโโโโผโโ File B review
โ
โโโ File C review
โ
โโโ File N review
This keeps individual review prompts more manageable and focused.
For the current file, the agent builds a focused review context.
Conceptually:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Current file diff โ
โ โ
โ + changed code โ
โ - removed code โ
โ โ
โ Other changed symbols โ
โ โข functionA() โ
โ โข validateToken() โ
โ โข UserRepository.findById() โ
โ โ
โ Review instructions โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Suppose:
auth.js
โโโ rename validateToken() โ verifyToken()
server.js
โโโ still calls validateToken()
A purely isolated file review can miss that relationship.
The agent instead supplies a compact list of symbols touched elsewhere in the same PR, allowing the model to reason about relevant cross-file relationships without blindly sending every other diff in full.
flowchart LR
A["๐ GitHub PR"] --> B["โ๏ธ GitHub Actions"]
B --> C["๐ฅ fetch-diff.js"]
C --> D["โ๏ธ chunk-diff.js"]
D --> E["๐ง review-chunk.js"]
E --> F{"LLM Provider"}
F --> G["Anthropic / Claude"]
F --> H["OpenAI / GPT"]
G --> I["๐ฆ Structured results"]
H --> I
I --> J["๐งฎ aggregate.js"]
J --> K["๐๏ธ Severity filter"]
K --> L["๐ฌ post-comment.js"]
L --> M["๐ GitHub PR feedback"]
PR-Review-Agent/
โ
โโโ .github/
โ โโโ workflows/
โ โโโ pr-review.yml โ๏ธ GitHub Actions entry point
โ
โโโ scripts/
โ โโโ fetch-diff.js ๐ฅ PR diff acquisition
โ โโโ chunk-diff.js โ๏ธ Diff decomposition
โ โโโ review-chunk.js ๐ง Review execution
โ โโโ aggregate.js ๐งฎ Result aggregation
โ โโโ aggregate-lib.js ๐งฉ Aggregation utilities
โ โโโ post-comment.js ๐ฌ GitHub feedback publishing
โ โโโ run-review.js ๐๏ธ Pipeline orchestration
โ โ
โ โโโ providers/
โ โโโ anthropic.js ๐ง Anthropic adapter
โ โโโ openai.js ๐ง OpenAI adapter
โ โโโ prompt.js ๐ Prompt construction
โ
โโโ test/
โ โโโ fixtures/
โ โโโ sample.diff ๐งช Diff fixture
โ โโโ chunk-results/
โ โโโ index.json ๐งช Result fixture
โ โโโ validate.json ๐งช Validation fixture
โ
โโโ .genesis/ ๐ Project process / development docs
Create this file in your repository root:
.pr-review.yml
Example:
max_files: 15
severity_threshold: warningControls the configured maximum number of files considered by the reviewer.
Controls the minimum severity surfaced to the developer.
If the file is omitted, documented defaults apply.
Be precise about what the system can and cannot guarantee.
AI can produce:
- false positives
- false negatives
- incorrect reasoning
- incomplete understanding of business requirements
Always validate important findings.
Cross-file awareness is intentionally compact.
The current implementation does not:
- edit source files
- create fix commits
- push fixes
- auto-merge
The selected provider requires the corresponding API access.
Model-generated locations may not always correspond perfectly to a GitHub commentable diff position.
The fallback comment path exists for this reason.
The current architecture naturally supports several extensions.
Move from:
๐ฌ Finding
toward:
๐ฌ Finding
+
๐งฉ Suggested patch
+
๐จโ๐ป Human approval
A human should remain the acceptance gate.
Future context could combine:
PR diff
+
relevant symbols
+
dependency relationships
+
repository conventions
+
tests
without blindly sending the entire repository to the model.
A future reviewer could compare:
Changed implementation
+
Changed tests
+
Existing tests
and identify changes that appear to lack corresponding test coverage.
Future versions could fingerprint findings using information such as:
file
+
line
+
finding type
+
commit
to avoid noisy repetition.
GitHub
https://github.com/Sahoo999/PR-Review-Agent
npm installer
npx @debangsu__/create-pr-review-agent๐ค Review faster. ๐ฌ Comment where it matters. ๐จโ๐ป Keep humans in control.
Built around a simple idea: AI should shorten the feedback loop, not replace engineering judgment.