• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
ianvph

ianvph

pr-reviewer

Public
Like
2
pr-reviewer
Home
Code
8
README.md
claude.ts
H
debug.ts
github.ts
H
index.ts
main.ts
H
test.ts
utils.ts
Branches
1
Pull requests
Remixes
1
History
Environment variables
3
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
11/20/2025
Viewing readonly version of main branch: v14
View latest version
README.md

Code Review Bot

A GitHub code review bot that automatically analyzes pull requests using Claude AI and posts review comments.

Features

  • Responds to GitHub pull request webhooks
  • Analyzes code changes using Anthropic's Claude
  • Posts detailed review comments on PRs
  • Secure webhook signature verification

Setup

1. Get Required API Keys

GitHub Token: Create a fine-grained personal access token at https://github.com/settings/personal-access-tokens/new with:

  • Repository access: Select the specific repository you want to review
  • Permissions > Repository permissions:
    • Metadata: Read-only (required)
    • Contents: Read-only (required to fetch file contents)
    • Pull requests: Read and write (required to post review comments)

Anthropic API Key: Get your API key from Anthropic Console

2. Configure Environment Variables

In Val Town, set these environment variables:

  • GITHUB_TOKEN: Your GitHub personal access token
  • ANTHROPIC_API_KEY: Your Anthropic API key
  • WEBHOOK_SECRET: A random secret string (generate with: openssl rand -hex 32)

3. Get Your Webhook URL

Your webhook URL will be: https://[your-username]--[val-id].web.val.run/webhook

You can find this URL by clicking on your index.ts val in Val Town.

4. Configure GitHub Webhook

In your GitHub repository:

  1. Go to Settings > Webhooks > Add webhook
  2. Set Payload URL: Your Val Town webhook URL (from step 3)
  3. Set Content type: application/json
  4. Set Secret: Same value as your WEBHOOK_SECRET environment variable
  5. Select Let me select individual events → Check Pull requests
  6. Ensure Active is checked
  7. Click Add webhook

5. Test the Setup

Create a test pull request in your repository. The bot should:

  1. Post an initial "review in progress" comment
  2. Analyze the changed files
  3. Post a detailed review comment within 30-60 seconds

Usage

The bot automatically reviews pull requests when they are opened or reopened. It will:

  1. Fetch the changed files from the PR
  2. Analyze the code using Claude
  3. Post a review comment with findings

File Structure

  • index.ts - Main webhook handler and review logic
  • github.ts - GitHub API integration
  • claude.ts - Claude AI integration
  • utils.ts - Utility functions for webhook verification
  • test.ts - Test utilities for debugging

Troubleshooting

Bot Not Responding

  1. Check that your webhook URL is correct in GitHub settings
  2. Verify all environment variables are set in Val Town
  3. Check the webhook delivery logs in GitHub (Settings > Webhooks > Recent Deliveries)
  4. Look at the Val Town logs for error messages

Authentication Errors

  • Ensure your GitHub token has the correct permissions
  • Verify the token hasn't expired
  • Check that the repository is accessible with your token

Review Quality Issues

  • The bot analyzes up to 10 files per PR to stay within API limits
  • Only code files are reviewed (JS, TS, Python, etc.)
  • Very large files are truncated to prevent token limit issues

Webhook Signature Errors

  • Ensure the WEBHOOK_SECRET in Val Town matches the secret in GitHub
  • Check that the webhook is configured to send JSON payloads

Limitations

  • Reviews up to 10 files per PR
  • File content is truncated to 2000 characters for analysis
  • Only reviews code files (filters out documentation, images, etc.)
  • Requires internet access to GitHub and Anthropic APIs
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.