Automatically reviews every pull request using AI — tags issues by severity, scores PR health, and notifies your team on Slack.
flowchart TD
A([👤 Developer opens a Pull Request]) --> B[GitHub triggers PR-Solver Action]
B --> C{Filter files\nby path rules}
C -->|Excluded files| D[⏭️ Skip]
C -->|Valid files| E[📥 Fetch file content + diff]
E --> F[🔀 Split diff into patches]
F --> G[🤖 AI Summarize Stage]
F --> H[🔍 AI Review Stage]
G --> G1[Summarize each file diff]
G1 --> G2[Generate final PR summary]
G2 --> G3[Generate release notes]
G2 --> G4{pr_score_enabled?}
G4 -->|Yes| G5[📊 Score PR 0-100]
G4 -->|No| G6
H --> H1[Send file content for context]
H1 --> H2[Send diff for context]
H2 --> H3[Review each patch chunk]
H3 --> H4{Detect severity}
H4 -->|🔴 Critical| I1[Post Critical comment]
H4 -->|🟡 Warning| I2[Post Warning comment]
H4 -->|💡 Suggestion| I3[Post Suggestion comment]
H4 -->|✅ LGTM| I4[Skip or post LGTM]
G5 --> G6[💬 Post summary comment on PR]
G3 --> G7[📝 Update PR description]
G6 --> G8{Slack webhook\nconfigured?}
G8 -->|Yes| G9[📣 Send Slack notification]
G8 -->|No| G10([✅ Done])
G9 --> G10
style A fill:#6e40c9,color:#fff
style G10 fill:#39d353,color:#fff
style D fill:#555,color:#fff
style I1 fill:#d73a49,color:#fff
style I2 fill:#e3b341,color:#000
style I3 fill:#388bfd,color:#fff
style I4 fill:#39d353,color:#fff
graph LR
subgraph GitHub["🐙 GitHub"]
PR[Pull Request Event]
API[GitHub API\nOctokit]
Comments[PR Comments\n& Reviews]
end
subgraph Action["⚙️ PR-Solver Action"]
Main[main.ts\nEntry Point]
Bot[bot.ts\nConversation Manager]
Review[review.ts\nReview Pipeline]
Scorer[scorer.ts\nPR Health Score]
Commenter[commenter.ts\nComment Manager]
Options[options.ts\nConfig & Prompts]
end
subgraph AI["🤖 AI Providers"]
OpenAI[OpenAI\nGPT-4o-mini / GPT-4o]
Anthropic[Anthropic\nClaude 3.5 Sonnet]
end
subgraph Notify["🔔 Notifications"]
Slack[Slack\nWebhook]
end
PR --> Main
Main --> Bot
Main --> Review
Review --> Commenter
Review --> Scorer
Bot --> OpenAI
Bot --> Anthropic
Commenter --> API
API --> Comments
Scorer --> Slack
style GitHub fill:#161b22,color:#fff,stroke:#30363d
style Action fill:#0d1117,color:#fff,stroke:#6e40c9
style AI fill:#1a1a2e,color:#fff,stroke:#412991
style Notify fill:#1a2a1a,color:#fff,stroke:#39d353
sequenceDiagram
actor Dev as 👤 Developer
participant GH as 🐙 GitHub
participant Bot as 🤖 PR-Solver
participant AI as ✨ AI Provider
Dev->>GH: Opens Pull Request
GH->>Bot: Triggers pull_request event
Bot->>GH: Fetch diff & file contents
GH-->>Bot: Returns files + patches
Bot->>AI: Summarize each file diff
AI-->>Bot: File summaries
Bot->>AI: Generate final summary + score
AI-->>Bot: Summary + PR score (0-100)
Bot->>GH: Post summary comment 💬
Bot->>AI: Review each patch chunk
AI-->>Bot: Severity-tagged feedback
Bot->>GH: Post inline review comments 📝
Bot->>GH: Update PR description 📋
Dev->>GH: Replies "@openai explain this"
GH->>Bot: Triggers pull_request_review_comment
Bot->>GH: Fetch conversation chain
Bot->>AI: Send context + comment
AI-->>Bot: Response
Bot->>GH: Post reply 💬
Create .github/workflows/pr-solver.yml in your repo:
name: PR-Solver Code Review
permissions:
contents: read
pull-requests: write
on:
pull_request:
pull_request_review_comment:
types: [created]
concurrency:
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: ${{ github.event_name != 'pull_request_review_comment' }}
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: achalcipher/PR-solver@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
ai_provider: openai
openai_model: gpt-4o-mini
pr_score_enabled: true
review_comment_lgtm: falseGo to Settings → Secrets and variables → Actions
| Secret | Required | Get it from |
|---|---|---|
OPENAI_API_KEY |
✅ OpenAI | platform.openai.com/api-keys |
ANTHROPIC_API_KEY |
✅ Anthropic | console.anthropic.com |
SLACK_WEBHOOK_URL |
Optional | Slack App → Incoming Webhooks |
graph TD
R[AI reviews a patch] --> P{Parse severity\nfrom response}
P --> C1["🔴 [CRITICAL]\nBug / Security / Breaking change"]
P --> C2["🟡 [WARNING]\nCode smell / Performance / Risk"]
P --> C3["💡 [SUGGESTION]\nImprovement / Style / Best practice"]
P --> C4["✅ [LGTM]\nPatch looks correct"]
C1 --> POST1[Always post comment]
C2 --> POST2[Always post comment]
C3 --> POST3[Always post comment]
C4 --> CHECK{review_comment_lgtm\nenabled?}
CHECK -->|Yes| POST4[Post LGTM comment]
CHECK -->|No| SKIP[Skip — no noise]
style C1 fill:#d73a49,color:#fff
style C2 fill:#e3b341,color:#000
style C3 fill:#388bfd,color:#fff
style C4 fill:#39d353,color:#fff
style SKIP fill:#555,color:#fff
pie title Scoring Criteria
"Code Quality & Clarity" : 25
"Test Coverage" : 20
"Complexity & Size" : 20
"Documentation" : 15
"Error Handling" : 10
"Security" : 10
| Score | Badge | Meaning |
|---|---|---|
| 80 – 100 | 🟢 | Great PR — ready to merge |
| 50 – 79 | 🟡 | Decent but needs some work |
| 0 – 49 | 🔴 | Significant issues found |
| Input | Default | Description |
|---|---|---|
ai_provider |
openai |
openai or anthropic |
openai_model |
gpt-4o-mini |
Model name |
openai_model_temperature |
0.0 |
0 = deterministic |
openai_retries |
5 |
Retries with exponential backoff |
openai_timeout_ms |
60000 |
API timeout in ms |
openai_concurrency_limit |
4 |
Parallel API calls |
pr_score_enabled |
false |
Enable health score |
review_comment_lgtm |
false |
Post LGTM comments |
max_files |
60 |
Max files to review |
debug |
false |
Log AI messages in CI |
flowchart LR
A[API Call] --> B{Success?}
B -->|✅ Yes| C[Return response]
B -->|❌ No| D{Max retries\nreached?}
D -->|Yes| E[Throw error]
D -->|No| F[Wait 2ⁿ seconds\n1s → 2s → 4s → 8s...]
F --> A
style C fill:#39d353,color:#fff
style E fill:#d73a49,color:#fff
style F fill:#e3b341,color:#000
| Layer | Technology |
|---|---|
| Language | TypeScript |
| Runtime | Node.js 20 |
| CI Platform | GitHub Actions |
| AI (OpenAI) | GPT-4o-mini / GPT-4o via native fetch |
| AI (Anthropic) | Claude 3.5 Sonnet via native fetch |
| GitHub API | Octokit |
| Concurrency | p-limit |
| Token Counting | tiktoken |
| Notifications | Slack Incoming Webhooks |
git clone https://github.com/achalcipher/PR-solver.git
cd PR-solver
npm install
npm run build # compile TypeScript → lib/
npm run package # bundle → dist/index.js
npm test # run 28 unit tests