Public
Like
2
pr-reviewer
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.
Viewing readonly version of main branch: v13View latest version
A GitHub code review bot that automatically analyzes pull requests using Claude AI and posts review comments.
- Responds to GitHub pull request webhooks
- Analyzes code changes using Anthropic's Claude
- Posts detailed review comments on PRs
- Secure webhook signature verification
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
In Val Town, set these environment variables:
GITHUB_TOKEN: Your GitHub personal access tokenANTHROPIC_API_KEY: Your Anthropic API keyWEBHOOK_SECRET: A random secret string (generate with:openssl rand -hex 32)
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.
In your GitHub repository:
- Go to Settings > Webhooks > Add webhook
- Set Payload URL: Your Val Town webhook URL (from step 3)
- Set Content type:
application/json - Set Secret: Same value as your
WEBHOOK_SECRETenvironment variable - Select Let me select individual events → Check Pull requests
- Ensure Active is checked
- Click Add webhook
Create a test pull request in your repository. The bot should:
- Post an initial "review in progress" comment
- Analyze the changed files
- Post a detailed review comment within 30-60 seconds
The bot automatically reviews pull requests when they are opened or reopened. It will:
- Fetch the changed files from the PR
- Analyze the code using Claude
- Post a review comment with findings
index.ts- Main webhook handler and review logicgithub.ts- GitHub API integrationclaude.ts- Claude AI integrationutils.ts- Utility functions for webhook verificationtest.ts- Test utilities for debugging
- Check that your webhook URL is correct in GitHub settings
- Verify all environment variables are set in Val Town
- Check the webhook delivery logs in GitHub (Settings > Webhooks > Recent Deliveries)
- Look at the Val Town logs for error messages
- Ensure your GitHub token has the correct permissions
- Verify the token hasn't expired
- Check that the repository is accessible with your token
- 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
- Ensure the
WEBHOOK_SECRETin Val Town matches the secret in GitHub - Check that the webhook is configured to send JSON payloads
- 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