GitHub PR Review AI
May 21, 2025 · View on GitHub
A modern web application that provides AI-powered code reviews for GitHub pull requests. This tool helps developers get instant feedback on their code changes without waiting for human reviewers.
Features
- AI-Powered Code Reviews: Get comprehensive feedback on code style, security, performance, and design
- GitHub Integration: Seamlessly fetch pull request diffs from any public GitHub repository
- Post Comments: Automatically post reviews as comments on GitHub pull requests
- Markdown Rendering: Beautifully formatted review feedback with syntax highlighting
- Responsive Design: Works on desktop and mobile devices
- Dark Mode Support: Choose between light and dark themes
Installation
Prerequisites
- Node.js 18.x or higher
- npm or yarn
- GitHub Personal Access Token
- Gaia LLM API access (or another compatible LLM)
Setup
- Clone the repository:
git clone https://github.com/yourusername/github-pr-review-ai.git
cd github-pr-review-ai
- Install dependencies:
npm install
# or
yarn install
- Set up environment variables:
Create a .env.local file in the root directory with the following variables:
GITHUB_TOKEN=your_github_personal_access_token
GAIA_API_KEY=your_gaia_api_key
GAIA_API_BASE_URL=your_gaia_api_base_url
GAIA_MODEL=gpt-4o # or your preferred model
- Run the development server:
npm run dev
# or
yarn dev
- Open http://localhost:3000 in your browser to see the application.
Usage
- Enter the GitHub repository owner (username or organization)
- Enter the repository name
- Enter the pull request number
- Optionally check "Post review as a GitHub comment" to post the review directly to the PR
- Click "Review Pull Request"
- Wait for the AI to analyze the code changes
- Review the AI-generated feedback
Environment Variables
| Variable | Description | Required |
|---|---|---|
GITHUB_TOKEN | GitHub Personal Access Token with repo access | Yes |
GAIA_API_KEY | API key for Gaia LLM | Yes |
GAIA_API_BASE_URL | Base URL for Gaia API | Yes |
GAIA_MODEL | Model name to use (defaults to gpt-4o) | No |
Technologies Used
- Next.js: Full-stack React framework
- TypeScript: Type-safe JavaScript
- Tailwind CSS: Utility-first CSS framework
- shadcn/ui: High-quality UI components
- React Hook Form: Form validation
- Zod: Schema validation
- LangChain: LLM integration
- React Markdown: Markdown rendering
- React Syntax Highlighter: Code syntax highlighting
Project Structure
github-pr-review-ai/
├── app/
│ ├── actions.ts # Server actions for PR review
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/
│ ├── review-form.tsx # Main form component
│ ├── theme-provider.tsx # Dark/light mode provider
│ └── ui/ # UI components
├── lib/
│ └── utils.ts # Utility functions
├── public/
│ └── ... # Static assets
├── .env.local # Environment variables (create this)
├── next.config.js # Next.js configuration
├── package.json # Dependencies
├── README.md # This file
└── tsconfig.json # TypeScript configuration
How It Works
- Input Collection: The user provides GitHub repository details and PR number
- GitHub API Integration: The application fetches the PR diff using the GitHub API
- AI Analysis: The diff is sent to the Gaia LLM for analysis
- Feedback Generation: The AI generates structured feedback on the code changes
- GitHub Comment (Optional): The review can be posted as a comment on the PR
- Rendering: The feedback is rendered as formatted markdown with syntax highlighting
Future Enhancements
- GitHub OAuth integration to avoid needing a personal token
- Save review history
- Visual diff viewer
- Customizable review templates
- Support for private repositories
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.