# code_reviewer

Autonomous batch PR reviewer. Auto-discovers repos in `~/projects` with an
`orchard` remote, fetches open PRs via the `gh` CLI, generates structured
reviews via the Claude API, and saves them to `~/pr-reviews/<date>/`.

## Setup

```bash
cd ~/projects/code_reviewer
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
```

Add your Anthropic API key to `.env`:

```
ANTHROPIC_API_KEY=sk-ant-...
```

## Usage

```bash
# See what would be reviewed without making any API calls
python review_prs.py --dry-run

# Review all open PRs across discovered repos
python review_prs.py

# Review a single repo only
python review_prs.py --repo ows-account
```

## Output

Reviews land in `~/pr-reviews/YYYY-MM-DD/`:

| File | Description |
|------|-------------|
| `SUMMARY.md` | Table of all PRs reviewed, sorted by risk (High → Medium → Low) |
| `<repo>-PR<n>.md` | Full structured review for each PR |
| `meta.json` | Tracks reviewed PRs — re-runs skip already-reviewed ones |

## Configuration

`pr_review_config.yaml` controls defaults and per-repo overrides.

**Repos are auto-discovered** — any folder in `~/projects` with an `orchard`
remote is included automatically. No config changes needed when cloning new
repos.

### Excluding repos

Add repos to the `exclude` list to permanently skip them:

```yaml
exclude:
  - jira-analysis
  - ml
```

### Per-repo overrides

Add a repo under `repos:` only when its behavior should differ from the
defaults. Any key omitted at the repo level inherits the default.

```yaml
repos:
  # Filter to specific authors (GitHub login or display name)
  ows-account:
    authors: [githublogin1, githublogin2]

  # Always skip drafts without prompting
  frontend-workstation:
    skip_drafts: true

  # Include Dependabot PRs for this repo
  terraform-infra:
    skip_dependabot: false
```

### Default settings

| Setting | Default | Options |
|---------|---------|---------|
| `skip_drafts` | `prompt` | `true`, `false`, `prompt` |
| `skip_dependabot` | `true` | `true`, `false`, `prompt` |
| `authors` | `[]` (all) | List of GitHub logins/names |
| `parallelism` | `5` | Integer |

`prompt` means the script asks once at startup if matching PRs are found.
