Prerequisites
- Node.js 18+
- pnpm (or npm/yarn)
- A GitHub repository where you have admin access
- A Redis instance for state management
- A Vercel account
Create a Hono app
Scaffold a new Hono project and install dependencies:Terminal
Select the
vercel template when prompted by create-hono. This sets up the project for Vercel deployment with the correct entry point.Configure a GitHub webhook
- Go to your repository Settings then Webhooks then Add webhook
- Set Payload URL to
https://your-domain.com/api/webhooks/github - Set Content type to
application/json - Set a Secret and save it — you’ll need this as
GITHUB_WEBHOOK_SECRET - Under Which events would you like to trigger this webhook?, select Let me select individual events and check:
- Issue comments (for @mention on the PR conversation tab)
- Pull request review comments (for @mention on inline review threads)
Get credentials
- Go to Settings > Developer settings > Personal access tokens and create a token with
reposcope — you’ll need this asGITHUB_TOKEN - Copy the Webhook secret you set above — you’ll need this as
GITHUB_WEBHOOK_SECRET
Configure environment variables
Create a.env file in your project root:
.env
anthropic/claude-sonnet-4.6) uses AI Gateway. Develop locally by linking to your Vercel project with vc link then pulling your OIDC token with vc pull --environment development.
Define the review function
Create the core review logic. This clones the repo into a Vercel Sandbox, then uses AI SDK with a bash tool to let Claude analyze the diff and read files directly.src/review.ts
createBashTool gives the agent bash, readFile, and writeFile tools — all scoped to the sandbox. The agent can run git diff, read source files, and explore the repo freely without any code escaping the sandbox.
The function returns the review text instead of posting it directly. This lets the Chat SDK handler post it as a threaded reply.
Create the bot
Create aChat instance with the GitHub adapter. When someone @mentions the bot on a PR, it fetches the PR metadata, runs the review, and posts the result back to the thread.
src/bot.ts
onNewMention fires when a user @mentions the bot — for example, @codereview can you review this?. The handler extracts the PR details from the message’s raw payload, runs the sandboxed review, and posts the result. Calling thread.subscribe() lets the bot respond to follow-up messages in the same thread.
Handle the webhook
Create the Hono app with a single webhook route that delegates to Chat SDK:src/index.ts
waitUntil option ensures the review completes after the HTTP response is sent.
Test locally
- Start your development server (
pnpm dev) - Expose it with a tunnel (e.g.
ngrok http 3000) - Update the webhook URL in your GitHub repository settings to your tunnel URL
- Open a pull request
- Comment
@my-review-bot can you review this?— the bot should respond with “Starting code review…” followed by the full review
Deploy to Vercel
Deploy your bot to Vercel:Terminal
GITHUB_TOKEN, GITHUB_WEBHOOK_SECRET, REDIS_URL, BOT_USERNAME). Update the webhook URL in your GitHub repository settings to your production URL.
Next steps
- GitHub adapter — Authentication options, thread model, and full configuration reference
- Redis state — Production state adapter for subscriptions and distributed locking