Skip to main content
Glama
README.md
# PR Coach — Junior Dev Accelerator

> Not just code review — a CLI that sits between you and your PR, teaches you **why** something is wrong, and tracks your growth over time.

```
  ██████╗ ██████╗     ██████╗ ██████╗  █████╗  ██████╗██╗  ██╗
  ██╔══██╗██╔══██╗   ██╔════╝██╔═══██╗██╔══██╗██╔════╝██║  ██║
  ██████╔╝██████╔╝   ██║     ██║   ██║███████║██║     ███████║
  ██╔═══╝ ██╔══██╗   ██║     ██║   ██║██╔══██║██║     ██╔══██║
  ██║     ██║  ██║   ╚██████╗╚██████╔╝██║  ██║╚██████╗██║  ██║
  ╚═╝     ╚═╝  ╚═╝    ╚═════╝ ╚═════╝ ╚═╝  ╚═╝ ╚═════╝╚═╝  ╚═╝
```

Before AI-assisted review, only **16% of PRs received substantive comments**. After — that jumped to **54%**. PR Coach brings that to individuals, not just teams.

---

## Two Ways to Use PR Coach

### Option A: Inside Claude Code (MCP Server) — Recommended

PR Coach runs **alongside Claude** as an MCP tool server. Claude can use it directly while you're coding.

```bash
# Install
npm install -g claude-pr-coach

# Add to Claude Code (one command)
claude mcp add pr-coach -- pr-coach-mcp

# That's it — Claude now has these tools available:
#   pr_coach_review    — Review your changes before opening a PR
#   pr_coach_explain   — Explain your changes in depth
#   pr_coach_patterns  — View your learning patterns over time
#   pr_coach_settings  — Configure depth, strictness, provider
```

Or add manually to your Claude Code config (`~/.claude/settings.json`):

```json
{
  "mcpServers": {
    "pr-coach": {
      "command": "pr-coach-mcp",
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-...",
        "GEMINI_API_KEY": "AI...",
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}
```

Or for a project-specific setup (`.claude/settings.json` in your repo):

```json
{
  "mcpServers": {
    "pr-coach": {
      "command": "npx",
      "args": ["-y", "claude-pr-coach", "--mcp"]
    }
  }
}
```

**Then just ask Claude:**
- "Review my changes before I open a PR"
- "Explain what my code changes do, in mentor mode"
- "Show me my learning patterns"
- "Set PR Coach to strict mode"

### Option B: Standalone CLI

Use directly from your terminal:

```bash
# Install globally
npm install -g claude-pr-coach

# Or run instantly with npx
npx claude-pr-coach

# Set your AI provider key (pick one)
export ANTHROPIC_API_KEY=sk-ant-...    # Anthropic Claude
export GEMINI_API_KEY=AI...            # Google Gemini
export OPENAI_API_KEY=sk-...           # OpenAI GPT-4o

# Review your code before opening a PR
pr-coach review

# Get your changes explained to you
pr-coach explain --depth mentor
```

---

## What Makes This Different

| Traditional Code Review | PR Coach |
|------------------------|----------|
| Flags problems | **Teaches why** it's a problem |
| One-time feedback | **Tracks patterns** over time |
| Same depth for everything | **4 depth levels** from quick flags to full mentoring |
| Single reviewer perspective | **3 AI providers** to choose from |
| Team-level tooling | **Individual-level** learning |

## MCP Tools (when running inside Claude Code)

| Tool | What it does |
|------|-------------|
| `pr_coach_review` | Review changes with severity levels, code examples, teaching moments |
| `pr_coach_explain` | Understand your own code — depth adjustable from brief to mentor |
| `pr_coach_patterns` | See recurring issues tracked over time |
| `pr_coach_settings` | View/change provider, depth, strictness, pattern tracking |

## CLI Commands (when running standalone)

### `pr-coach review`
Review your changes before opening a PR.

```bash
pr-coach review                    # Review all changes (auto-detects staged/branch)
pr-coach review --staged           # Only staged changes
pr-coach review --branch develop   # Compare against specific branch
pr-coach review --depth mentor     # Full teaching mode
pr-coach review --strict strict    # Comprehensive review
pr-coach review --provider gemini  # Use specific AI provider
```

### `pr-coach explain`
Understand your own code changes in depth.

```bash
pr-coach explain                    # Explain with default depth
pr-coach explain --depth brief      # Quick summary per file
pr-coach explain --depth detailed   # Line-by-line with concepts
pr-coach explain --depth mentor     # Full teaching mode with questions
```

### `pr-coach patterns`
View your learning patterns over time.

```bash
pr-coach patterns                   # See your learning profile
pr-coach patterns --resolve 0       # Mark a pattern as resolved
```

### `pr-coach settings`
Configure how PR Coach works for you.

```bash
pr-coach settings                          # View current settings
pr-coach settings --set provider=gemini    # Switch AI provider
pr-coach settings --set depth=mentor       # Set explanation depth
pr-coach settings --set strictness=strict  # Set review strictness
```

## AI Providers

PR Coach works with any of these. Set one API key and you're good:

| Provider | Model | Env Variable | Best For |
|----------|-------|-------------|----------|
| **Anthropic** | Claude Sonnet | `ANTHROPIC_API_KEY` | Nuanced teaching, detailed explanations |
| **Google Gemini** | Gemini 2.5 Flash | `GEMINI_API_KEY` | Fast reviews, good value |
| **OpenAI** | GPT-4o | `OPENAI_API_KEY` | Broad knowledge, familiar style |

Auto-detection: if you have multiple keys set, PR Coach uses your configured preference. Override per-command with `--provider`.

## Depth Levels

| Level | What You Get |
|-------|-------------|
| `brief` | Quick flags — what to fix, minimal words |
| `normal` | What's wrong, why it matters, how to fix |
| `detailed` | Full explanations, code examples, related concepts |
| `mentor` | Pair-programming style — teaches principles, asks you questions, suggests what to study |

## How It Works

```
  1. Make changes on a feature branch
  2. Run  pr-coach review  (or ask Claude to review)
  3. Fix issues and learn from the feedback
  4. Check  pr-coach patterns  to track growth
  5. Use  pr-coach explain  to go deeper
```

Your learning profile is stored locally at `~/.pr-coach/` — it's yours, on your machine.

## Example Output

### CLI Mode
```
╭────────────────────────────────────────────────────────────╮
│   REVIEW SUMMARY                                           │
├────────────────────────────────────────────────────────────┤
│                                                            │
│   Good progress on the auth module. Two critical issues    │
│   around input validation and one recurring pattern with   │
│   error handling that we've seen before.                   │
│                                                            │
├────────────────────────────────────────────────────────────┤
│   Score:  ████████████████░░░░  8/10                       │
│   Status: ✓ Ready to open PR                               │
│                                                            │
│   ◆ 0 critical  ▲ 2 warnings  ● 3 suggestions  ★ 2 praise│
╰────────────────────────────────────────────────────────────╯
```

### MCP Mode (inside Claude Code)
Just ask Claude naturally:
> "Hey Claude, review my changes before I open this PR. Use mentor mode."

Claude will call `pr_coach_review` and present the results inline in your conversation.

## Contributing

PRs welcome! This project is MIT licensed.

```bash
git clone https://github.com/harrykang/claude-pr-coach.git
cd claude-pr-coach
npm install
npm run build

# Test CLI
node dist/index.js coach

# Test MCP server
node dist/mcp-server.js
```

## License

MIT