Skip to content

nivedita285/pr-reviewer-workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PR Reviewer — Team-Aware AI Code Review for GitHub

PR Reviewer is a GitHub Actions toolkit that performs automated pull request reviews using Gemini and LangGraph.

Unlike traditional linters or generic AI reviewers, PR Reviewer learns how your team reviews code and applies those standards automatically to future pull requests.

The system consists of three workflows:

Workflow Purpose
G1 — Pattern Learner Learns your team's review standards from historical PRs
G2 — PR Reviewer Reviews new pull requests using those standards
G3 — Fix Verifier Checks whether review comments were actually addressed

The workflows are designed to work together:

Historical PRs
      ↓
G1 Pattern Learner
      ↓
team_patterns.json
team_tone.json
      ↓
G2 PR Reviewer
      ↓
Review Comments
      ↓
Developer Fixes Issues
      ↓
G3 Fix Verifier

No database is required. All learned patterns are stored directly in your repository.


Why This Exists

Most AI code reviewers provide generic feedback.

Real engineering teams have their own standards. Some teams:

  • require explicit timeout handling.
  • care heavily about authorization checks.
  • enforce strict naming conventions.
  • intentionally ignore certain stylistic issues.

PR Reviewer learns these team-specific preferences from real review comments and uses them when reviewing future pull requests.

The goal is to make automated reviews feel like they came from one of your senior engineers.


What Each Workflow Does

G1 — Pattern Learner

G1 analyses historical pull requests and extracts:

  • Reusable review patterns
  • Team-specific coding standards
  • Reviewer preferences
  • Comment tone and style
  • Things your team consistently ignores

Optionally, you can give usernames of senior reviewers so the tonality of the pr review comments posted matches the standard practice followed in your team. Examples:

Learns:

  • "All external API calls must define timeouts."
  • "Database writes should always be wrapped in transactions."
  • "Authorization checks must occur before service calls."

Does not learn:

  • One-off comments specific to a single PR.

The extracted knowledge is stored in:

.github/pattern_store/team_patterns.json
.github/pattern_store/team_tone.json
.github/pattern_store/team_config.json

It is preferrable to run G1 before using G2. Consumes only one Gemini API request.


G2 — PR Reviewer

G2 can review automatically whenever a PR is opened or updated, or manually on demand.

Three specialist reviewers run in parallel:

  • Security Reviewer
  • Logic Reviewer
  • Style Reviewer

Each reviewer:

  • Analyses the PR diff
  • Applies team patterns learned by G1
  • Generates structured review comments
  • Posts comments directly on the pull request

Comments include:

  • Severity
  • Category
  • Explanation
  • Suggested fix

G3 — Fix Verifier

G3 verifies whether review comments have actually been addressed. If yes, it posts a proper response to the comment explaining the fix that was applied. This slashes the manual work to half: apply the fixes (whether manually or using github mcp server), commit, and let the bot handle the communication on github.

It:

  1. Reads existing review comments

  2. Compares them against the latest PR diff

  3. Determines whether each issue is:

    • Resolved
    • Partially Resolved
    • Unresolved
  4. Posts a reply for the resolved comments, explaining the result

This helps reviewers avoid manually checking every requested change.


Documents

On running G2 and G3, the following directories are generated; you can add these to .gitignore as they are for your reference and don't need to be committed in you repo:

  1. resolver_documents
    • contains Verification Documents
    • inline comments that were left by the pr-reviewer bot on a pull request
    • .txt file containing structured metadata of each of the comment for bot's reference
  2. reviewer_summaries
    • structured summary of the comments posted by the bot along with it's metadata
    • used by the bot to post comments
  3. resolver_responses
    • metadata generated by G3
    • contains comment_id, status (resolved/unresolved), and the reply posted by the bot

Installation

Step 1 — Copy the Workflow Files

Copy the enitre .github directory from this repository into your project. After copying, your repository should contain:

.github/
├── workflows/
│   ├── g1_pattern_learner.yml
│   ├── g2_pr_reviewer.yml
│   └── g3_fix_verifier.yml
│
├── src/
│   ├── g1_pattern_learner.py
│   ├── g2_pr_reviewer.py
│   └── g3_fix_verifier.py
│
└── pattern_store/
|   ├── team_patterns.json
|   ├── team_tone.json
|   └── team_config.json
└── requirements.txt

commit this in the main branch of your repo.


Step 2 — Create GitHub Secrets

Open:

Repository → Settings → Secrets and Variables → Actions

Create the following secrets.

GEMINI_API_KEY

Create an API key from:

https://aistudio.google.com

Store it as:

GEMINI_API_KEY

GH_TOKEN

Create a GitHub Personal Access Token.

Recommended permissions:

Contents: Read and Write
Pull Requests: Read and Write
Metadata: Read

Store it as:

GH_TOKEN

Step 3 — Verify Actions Are Enabled

Open:

Repository → Actions

You should see:

  • G1 — Learn Team Patterns
  • G2 — Automated PR Review
  • G3 — Verify PR Fixes

If they appear, installation is complete.


First-Time Setup

Before reviewing pull requests, teach the system how your team reviews code.

Run G1 once using several historical pull requests.

Choose PRs that contain meaningful review discussions.


Running G1 — Learn Team Patterns

  1. Open GitHub.

  2. Go to Actions.

  3. Select:

    • G1 — Learn Team Patterns
  4. Click:

    • Run Workflow

Provide:

PR Numbers

Comma-separated list of historical PRs.

Example:

12,18,27,31,42

Senior Reviewers

Optional.

Comma-separated GitHub usernames.

Example:

alice,bob

These reviewers receive additional weight during pattern extraction.

Click:

Run Workflow

When complete, the workflow automatically updates:

team_patterns.json
team_tone.json
team_config.json

and commits them back into your repository.


Running G2 — Review Pull Requests

Automatic Mode

G2 automatically runs whenever:

  • A pull request is opened
  • New commits are pushed to a pull request

No manual action is required.


Manual Mode

  1. Actions
  2. G2 — Automated PR Review
  3. Run Workflow
  4. Enter PR Number
  5. Run

Review comments will appear directly on the pull request.


Running G3 — Verify Fixes

After the author addresses review comments:

  1. Open Actions

  2. Select:

    • G3 — Verify PR Fixes
  3. Run Workflow

Provide:

PR Number

The PR to verify.

Post Replies for Resolved Comments

If enabled, G3 confirms resolved issues.

Post Replies for Unresolved Comments

If enabled, G3 notifies developers about remaining issues.

The workflow replies directly within each review thread.


Daily Workflow

A typical team workflow looks like:

Run G1 once
      ↓
Developer opens PR
      ↓
G2 reviews PR automatically
      ↓
Developer fixes issues
      ↓
Run G3
      ↓
Reviewer confirms changes and posts replies.

Re-run G1 periodically as your team's standards evolve.


Troubleshooting

G2 Does Not Use Team Patterns

Possible causes:

  • G1 has never been run
  • team_patterns.json is empty
  • pattern store files were not committed

Run G1 using at least one historical PR.


Permission Errors

Verify that:

  • GH_TOKEN has write access
  • Actions are enabled
  • The token can access the repository

Duplicate Review Comments

G2 was executed multiple times on the same PR.

Remove duplicate comments manually from the pull request. (intended future fix)


Data Storage

No external database is used.

All learned patterns, review tone, and reviewer configuration are stored directly in your repository under:

.github/pattern_store/

This makes the system easy to audit, version, and reset using normal Git workflows.

About

Automated PR review toolkit — scans pull requests using Gemini AI, posts inline review comments, and verifies fixes after changes are pushed, along with posting replies about the fix on user's behalf. Git workflows for end-to-end pr -automation

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors