Ever wished you had a slightly unhinged waterfowl reviewing your pull requests? Today, we’ll explore how to build a GitHub code review bot that channels the energy of an angry goose while leveraging the power of Claude AI to provide insightful code reviews.
The Stack: Simplicity Meets Power
Our application is built on the HONC stack - a modern, serverless-first approach combining Hono (a lightweight web framework), OpenTelemetry (for observability), Neon (serverless Postgres), and Claude (Anthropic’s AI model). Running on Cloudflare Workers provides us with a globally distributed, highly available platform without the hassle of managing servers.
How It Works
When a pull request is opened, our bot springs into action through a series of well-orchestrated steps:
- A GitHub webhook triggers our
/api/pull-requests
endpoint - The application fetches the diff content using GitHub’s API
- This diff is sent to Claude, along with instructions to embody an angry goose engineering manager
- The AI-generated review is posted back to GitHub and stored in our Neon database
Most of the heavy lifting is done in the POST /api/pull-requests
endpoint, that listens for incoming pull requests and initiates the review process.
The Secret Sauce: Personality Meets Precision
What makes this bot unique is its combination of technical precision and personality. Here’s how we achieve this balance:
The AI review focuses on critical aspects like potential bugs, security concerns, and performance implications, all while maintaining the persona of an irritated waterfowl. It’s both entertaining and valuable - a rare combination in developer tools.
Data Persistence and API Design
Using Drizzle ORM with Neon provides a type-safe and efficient way to manage our database operations. The schema is straightforward but effective:
pull_requests
table tracks PR metadata and GitHub referencesreviews
table stores the AI-generated reviews and their status
This setup allows for easy querying of review history and potential future analytics on review patterns and common issues.
Looking Forward
While the current implementation is fully functional, there’s room for exciting enhancements:
- Implementing real-time updates using Durable Objects
- Adding streaming responses for longer code reviews
- Expanding the AI’s review capabilities with more specialized focuses
- Turning the bot into a GitHub app (instead of using a personal access token)
Conclusion
Building this bot demonstrates how modern serverless technologies and AI can come together to create developer tools that are both useful and enjoyable to interact with. The combination of Cloudflare Workers’ edge computing capabilities, Neon’s serverless database, and Claude’s AI prowess makes for a powerful and scalable solution.
Whether you’re looking to improve code quality, add some personality to your development process, or just want to be honked at about your coding style, this bot provides a foundation that can be adapted and expanded to suit your team’s needs.
Remember: Sometimes the best code reviews come from an angry goose! 🪿