Skip to content

feat: Claude PR Reviewer agent — structured Markdown code reviews#513

Open
FraktalDeFiDAO wants to merge 1 commit intoclaude-builders-bounty:mainfrom
FraktalDeFiDAO:feature/pr-review-agent
Open

feat: Claude PR Reviewer agent — structured Markdown code reviews#513
FraktalDeFiDAO wants to merge 1 commit intoclaude-builders-bounty:mainfrom
FraktalDeFiDAO:feature/pr-review-agent

Conversation

@FraktalDeFiDAO
Copy link
Copy Markdown

🔍 Claude PR Reviewer Agent

What this does

A Claude Code sub-agent that takes a PR diff as input, analyzes it, and returns a structured Markdown review comment.

Acceptance Criteria Met

Requirement Status
CLI: claude-review --pr https://github.com/owner/repo/pull/123 ✅ Implemented
GitHub Action workflow YAML included .github/workflows/pr-review.yml
Structured Markdown: Summary (2-3 sentences)
Structured Markdown: Identified risks (list)
Structured Markdown: Improvement suggestions (list)
Structured Markdown: Confidence score (Low/Medium/High)
Tested on 2+ real GitHub PRs with outputs ✅ 3 PRs tested
README with setup and usage

Architecture

src/
├── index.ts       # CLI entry point & arg parsing
├── types.ts       # TypeScript interfaces
├── github.ts      # GitHub API (fetch diff, post comments)
├── claude.ts      # Anthropic API (AI-powered review)
├── template.ts    # Template-based review (no API key)
└── formatter.ts   # Markdown output formatting

agents/
└── pr-reviewer.md # Claude Code sub-agent prompt

.github/workflows/
└── pr-review.yml  # GitHub Action workflow

Two Modes

  1. AI Mode (with ANTHROPIC_API_KEY): Sends diff to Claude for deep analysis
  2. Template Mode (no API key): Pattern detection + heuristic analysis

Usage

# Install
npm install && npm run build

# Basic review (template mode)
node dist/index.js --pr https://github.com/owner/repo/pull/123

# AI-powered review
export ANTHROPIC_API_KEY=sk-ant-...
node dist/index.js --pr https://github.com/owner/repo/pull/123

# Post review as PR comment
node dist/index.js --pr https://github.com/owner/repo/pull/123 --post

# Save to file
node dist/index.js --pr https://github.com/owner/repo/pull/123 --output review.md

Test Outputs

See test-outputs/ for real PR review samples:

- CLI tool: claude-review --pr <URL> for structured PR reviews
- AI-powered analysis via Claude (Anthropic API)
- Template fallback mode (pattern detection, no API key needed)
- Structured Markdown output: summary, risks, suggestions, confidence
- --post flag to comment directly on PR
- --output flag to save review to file
- Claude Code agent config (agents/pr-reviewer.md)
- GitHub Action workflow (.github/workflows/pr-review.yml)
- Tested on 3 real PRs (TypeScript, Deno, Next.js)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant