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: v10View 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 verification