Code Review Analyzer is an AI-powered tool that automates the process of analyzing pull requests and code review comments from GitHub.
It fetches merged PRs and their review comments directly from a GitHub repository, and uses OpenAI to extract meaningful insights:
recurring issues, context, and clear recommendations — all grouped and tagged for easy analysis.
git clone https://github.com/OfekSagiv/code-review-analyzer.git
cd code-review-analyzernpm installCreate a .env file in the root directory and add the following variables:
OPENAI_API_KEY=your_openai_key_here
GITHUB_TOKEN=your_github_token_here
GITHUB_REPO=username/repo-name
DATABASE_URL="postgresql://name:password@localhost:5433/code_reviewer"Ensure
DATABASE_URLmatches the Docker setup below: username, passwordpassword, and port5433
- Go to https://platform.openai.com/account/api-keys
- Click "Create new secret key"
- Copy and paste it into your
.envasOPENAI_API_KEY
- Go to https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Select scopes:
repo(for accessing PRs and comments)
- Copy and paste it into
.envasGITHUB_TOKEN
To run the local database safely, use docker-compose.yml:
✅ This configuration ensures PostgreSQL is accessible only from your machine (localhost) and not exposed to the network or internet.
Start the container:
docker compose up -dTo connect Prisma to the local PostgreSQL database and create the necessary tables, follow these steps:
1. Generate Prisma client
npx prisma generate
2. Push the schema to the database
npx prisma db pushThis will sync the schema defined in
prisma/schema.prismawith the local database.
This command pulls data from GitHub, tags comments using GPT, and generates an insights report:
node scripts/runAll.jsAfter running the scripts, you'll get:
insights_report.txt– a grouped and readable summary of all tagged insights from review comments.
Your insights report is ready – fully sorted, grouped by tags, and clearly documented, making it easy to review patterns and improve code quality. You can use this file as input for chat-based advisors, integrate it into documentation, or build tools that learn from recurring code review insights.