An AI-powered code review GitHub App that automatically reviews pull requests and direct commits using OpenAI's GPT-4 model. The app provides detailed feedback on code quality, potential bugs, security issues, and suggested improvements.
- Automatic code review on pull request creation and updates
- Code review for direct commits to branches
- Detailed feedback on:
- Code quality and best practices
- Potential bugs and security issues
- Performance considerations
- Maintainability and readability
- Suggested improvements
- Configurable file type filtering
- Error handling and reporting
-
Go to your GitHub account settings
-
Navigate to "Developer settings" > "GitHub Apps" > "New GitHub App"
-
Fill in the following details:
- Name: Choose a unique name for your app
- Homepage URL: Your app's homepage or repository URL
- Webhook URL: Your server's webhook endpoint (e.g.,
https://your-domain.com/api/webhook
) - Webhook secret: Generate a secure random string
-
Set the following permissions:
- Repository permissions:
- Contents: Read
- Issues: Write
- Pull requests: Write
- Subscribe to events:
- Pull request
- Push
- Repository permissions:
-
After creation, note down:
- App ID
- Client ID
- Client Secret
- Generate and download a private key
-
Copy
.env.example
to.env
:cp .env.example .env
-
Fill in the environment variables:
# GitHub App Configuration APP_ID=your_app_id PRIVATE_KEY=your_private_key WEBHOOK_SECRET=your_webhook_secret GITHUB_CLIENT_ID=your_client_id GITHUB_CLIENT_SECRET=your_client_secret # OpenAI Configuration OPENAI_API_KEY=your_openai_api_key # Server Configuration PORT=3000
-
Install dependencies:
npm install
-
Start the server:
# Development npm run dev # Production npm start
- Go to your GitHub App's settings page
- Click "Install App"
- Choose the repositories you want to enable the app for
- The app will automatically start reviewing code on:
- New pull requests
- Updates to existing pull requests
- Direct commits to branches
- When a pull request is opened or updated, the app:
- Retrieves the changed files
- Filters out non-code files (images, locks, etc.)
- Sends the code to OpenAI for review
- Posts the review as a pull request comment
- When code is pushed directly to a branch, the app:
- Analyzes the commit changes
- Filters out non-code files
- Gets AI review feedback
- Creates a new issue with the review results
- For pull requests: Errors are posted as comments on the PR
- For direct commits: Errors create new issues with the 'error' label
- All errors are logged server-side for debugging
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details