Automated code review bot for GitHub pull requests using Google Gemini AI.
This bot automatically reviews pull requests and provides line-by-line feedback on code changes. It integrates with GitHub webhooks and uses Google's Gemini API for intelligent code analysis.
- Automatic PR review on open/sync events
- Line-by-line code comments
- Support for multiple programming languages
- Webhook signature verification
- Cloudflare Workers deployment
- Runtime: Cloudflare Workers
- Framework: Hono
- Language: TypeScript
- AI: Google Gemini 2.0 Flash
- Deployment: Wrangler CLI
src/
├── types/ # TypeScript interfaces and types
├── services/ # Business logic services
│ ├── github.ts # GitHub API integration
│ ├── gemini.ts # Gemini AI integration
│ └── reviewer.ts # Code review orchestration
├── utils/ # Utility functions
│ └── webhook.ts # Webhook verification
└── index.ts # Main application entry point
Configure these environment variables in your Cloudflare Workers dashboard or via Wrangler:
wrangler secret put GITHUB_SECRET
wrangler secret put GITHUB_TOKEN
wrangler secret put GEMINI_API_KEYOr update wrangler.jsonc with your values:
{
"vars": {
"GITHUB_ID": "your-github-id",
"SECRET_CODE": "your-secret-code"
}
}GITHUB_SECRET: Webhook secret from GitHub repository settingsGITHUB_TOKEN: Personal access token with repo permissionsGEMINI_API_KEY: Google AI Studio API key
- Go to your repository settings
- Navigate to Webhooks section
- Add webhook with:
- Payload URL: Your deployed worker URL +
/webhook - Content type:
application/json - Secret: Same value as
GITHUB_SECRET - Events: Select "Pull requests"
- Active: Checked
- Payload URL: Your deployed worker URL +
npm install
npm run deploynpm run devGET /health- Health checkPOST /webhook- GitHub webhook handler
- JavaScript/TypeScript (.js, .ts, .jsx, .tsx)
- Python (.py)
- Java (.java)
- Go (.go)
- Ruby (.rb)
- PHP (.php)
- C# (.cs)
- C/C++ (.c, .cpp)
- Custom review rules configuration
- Multi-language support expansion
- Review history tracking
- Team-specific review templates
- Integration with issue tracking
- Performance metrics dashboard
- Custom AI model selection
- Review approval workflows