AI-powered code review tool using LLMs via OpenRouter. Reviews code in two modes:
- File mode:
--file <filename>- reviews ANY code file from your device - Git mode:
--gitmode [repoPath]- reviews staged changes in current or any local repo
This application writes a Markdown report to ./reports/ each time is run.
Three agents used:
- Maintainer (maintainability) & Optimizer (performance) -> Parallel work
- Senior Developer Judge -> Synthesis/Aggregation (Writes report)
Before running the application, follow these steps:
- For this repository, create a GitHub Codespace (Cloud) OR clone it locally and open it with your preferred code editor (e.g. Visual Studio Code, ...).
Important
From this point on, make sure that your present working directory on your terminal is the root directory of the application: .\Code-Reviewer.
-
Install Node.js (If not already installed):
- Windows: Download the latest installer from nodejs.org or use:
winget install OpenJS.NodeJS.LTS - macOS: Use Homebrew:
brew install node - Linux (Ubuntu/Debian):
sudo apt update && sudo apt install nodejs npm - Cloud Workspaces (Codespaces, etc.): Node.js is usually pre-installed. Run
node --versionto verify and skip this step.
- Windows: Download the latest installer from nodejs.org or use:
-
Install ripgrep (required for
grep_codebasetool):- Windows:
winget install BurntSushi.ripgrep.MSVC - macOS:
brew install ripgrep - Linux (Ubuntu/Debian):
sudo apt install ripgrep
- Windows:
-
Install Dependencies:
npm install
-
Environment Configuration:
- Create a local
.envfile by copying the template file.env.example. This file contains all required API keys for the application:
# On Windows (Command Prompt) copy .env.example .env # On macOS/Linux or PowerShell cp .env.example .env
- Create a local
Important
Always copy the template. Do not rename .env.example directly, as it must remain in the repository as a reference for required environment variables.
- Open the newly created
.envfile and fill in yourOPENROUTER_API_KEY. The application will not function without a valid.envfile in the repository root.
- Main Directories Glossary:
./src/: Main source code (review.ts, schemas.ts, tools.ts)./src/system_prompts/: Agent instructions (INSTRUCTIONS1-3.md)./node_modules/: Installed npm dependencies./reports/: Generated review reports (created automatically)
- File mode:
report/report_[FILENAME].md - Git mode:
report/report_staged_#[N].md(incrementing number)
- Missing API Key: Ensure
OPENROUTER_API_KEYis correctly set in your.envfile at the repository root. - Dependency Issues: If running in a new environment, ensure you have executed
npm install(Step 4). - ripgrep not found: Install ripgrep (Step 3) - required for the
grep_codebaseLLM tool. - Git not found: Required for
--gitmodeandget_file_historytool. Install Git if missing. - TypeScript errors: Run
npx tsc --noEmitto typecheck.
Important
All paths used as parameters should be absolute paths and wrapped in quotes for safety.
Review a single file:
npx tsx src/review.ts --file "path/to/your/file.ts" [--verbose]Note
Verbose flag (--verbose) generates a src/debug.txt file with log traces (overridden per run), use it for engineering purposes only.
Review staged changes in a local cloned repo:
npx tsx src/review.ts --gitmode "/path/to/other/repo" [--verbose]