Code Review Assistant
Automatically summarize PRs, check CI status, and provide initial code review feedback
š§ Ingredients
š APIs
pull_requests_diffs_ci_status_and_review_comments
š Alternatives:
notify_team_of_new_prs_and_review_status
š Alternatives:
š Step-by-Step Build Guide
Connect to GitHub API and set up webhook or polling for new PRs on your repos
1. Connect to GitHub API and set up webhook or polling for new PRs on your repos
Use the GitHub API to fetch the relevant data.
GET https://api.github.com/repos/{owner}/{repo}/{endpoint}
Headers: Authorization: Bearer {GITHUB_TOKEN}, Accept: application/vnd.github.v3+json
Parse the response and extract the key fields.
Handle pagination if results exceed one page (check Link header).
Rate limit: GitHub allows 5,000 requests/hour with auth. If you get 403, check X-RateLimit-Remaining header.
Format the output concisely with the most important information first.š§ Human Required
- ⢠## Connect the API 1. Sign up for the service if you don't have an account 2. Find the API settings in your account dashboard 3. Generate an API key or access token 4. Share the key with your agent when prompted š” Most services have a free tier that's sufficient to get started.
When a new PR is opened, pull the diff and file list
2. When a new PR is opened, pull the diff and file list
Use the GitHub API to fetch the relevant data.
GET https://api.github.com/repos/{owner}/{repo}/{endpoint}
Headers: Authorization: Bearer {GITHUB_TOKEN}, Accept: application/vnd.github.v3+json
Parse the response and extract the key fields.
Handle pagination if results exceed one page (check Link header).
Rate limit: GitHub allows 5,000 requests/hour with auth. If you get 403, check X-RateLimit-Remaining header.
Format the output concisely with the most important information first.Generate a PR summary
3. Generate a PR summary: what changed, which files, estimated complexity, and a plain-English description
Compile the gathered data into a structured report. Format as clean Markdown with: - Title/date header - Executive summary (2-3 sentences) - Key metrics section with actual numbers - Detailed sections with bullet points - Action items or recommendations at the end Keep it scannable ā busy people read reports in 30 seconds. Use emoji sparingly for visual anchors (š metrics, ā wins, ā ļø concerns, š action items). Include data comparisons: "X this period vs Y last period (āZ%)" If any data source was unavailable, note it clearly: "ā ļø [Source] data unavailable ā excluded from this report."
Run automated checks
4. Run automated checks: PR size (flag if >500 lines), test coverage (any test files changed?), sensitive files (env, config, auth)
Monitor the data for anomalies and trigger alerts when thresholds are exceeded. Detection rules: 1. Compare current values against defined thresholds 2. Check for sudden changes (>X% deviation from rolling average) 3. Look for pattern breaks (missing expected data, unusual timing) 4. Cross-reference multiple signals for higher confidence For each detected anomaly: - Severity: š“ Critical (immediate action) / š” Warning (attention needed) / šµ Info (notable) - What: specific metric and current value - Why: what threshold or pattern was violated - Context: recent trend, baseline comparison - Suggested action: what to do about it Suppress duplicate alerts ā don't re-alert for the same issue within the configured cooldown period.
Check CI status
5. Check CI status ā are all checks passing? Flag failures with relevant logs
Check CI status ā are all checks passing? Flag failures with relevant logs Steps: 1. Validate all required inputs are available 2. Execute the operation described above 3. Verify the result meets expected output format 4. Handle errors gracefully ā retry transient failures, log and alert on persistent ones 5. Return structured output with status and any relevant data If any required data is missing, request it from the user before proceeding.
Post a review comment with
6. Post a review comment with: summary, automated check results, and any flagged concerns
Post a review comment with: summary, automated check results, and any flagged concerns Steps: 1. Validate all required inputs are available 2. Execute the operation described above 3. Verify the result meets expected output format 4. Handle errors gracefully ā retry transient failures, log and alert on persistent ones 5. Return structured output with status and any relevant data If any required data is missing, request it from the user before proceeding.
Notify the team in Slack
7. Notify the team in Slack: 'New PR #123 by @author ā [summary]. CI: ā passing. Size: medium (247 lines)'
Use the GitHub API to fetch the relevant data.
GET https://api.github.com/repos/{owner}/{repo}/{endpoint}
Headers: Authorization: Bearer {GITHUB_TOKEN}, Accept: application/vnd.github.v3+json
Parse the response and extract the key fields.
Handle pagination if results exceed one page (check Link header).
Rate limit: GitHub allows 5,000 requests/hour with auth. If you get 403, check X-RateLimit-Remaining header.
Format the output concisely with the most important information first.Track PR lifecycle
8. Track PR lifecycle: time to first review, time to merge, review rounds
Track PR lifecycle: time to first review, time to merge, review rounds Steps: 1. Validate all required inputs are available 2. Execute the operation described above 3. Verify the result meets expected output format 4. Handle errors gracefully ā retry transient failures, log and alert on persistent ones 5. Return structured output with status and any relevant data If any required data is missing, request it from the user before proceeding.
š¤ Example Agent Prompt
Use the GitHub API to fetch the relevant data.
GET https://api.github.com/repos/{owner}/{repo}/{endpoint}
Headers: Authorization: Bearer {GITHUB_TOKEN}, Accept: application/vnd.github.v3+json
Parse the response and extract the key fields.
Handle pagination if results exceed one page (check Link header).
Rate limit: GitHub allows 5,000 requests/hour with auth. If you get 403, check X-RateLimit-Remaining header.
Format the output concisely with the most important information first.Copy this prompt into your agent to get started.