🧠 AI Code Review
An AI-powered VS Code extension that automatically reviews your JavaScript and TypeScript files using Google's Gemini model.
🚀 Features
- 🔍 Reviews your changed files automatically after each Git commit
- ⚙️ Highlights potential errors and improvements
- 💬 Displays AI review results in VS Code Output panel
- 🤖 Uses Gemini API for intelligent code insights
🧩 Usage
🪜 Step-by-step Guide
Clone or open your project in VS Code
git clone <your-repo-url>
cd <your-repo-folder>
code .
Install dependencies
npm install
Compile TypeScript (if the extension is written in TypeScript)
npm run compile
Run the extension in the Extension Development Host
- Press
F5 (or select Run → Start Debugging)
- A new VS Code window (Extension Development Host) will open
Trigger a review
Make a code change, then stage and commit it to trigger the automatic review hook:
git add .
git commit -m "Test AI Review"
The extension detects the commit and starts the AI Code Review. Results appear in View → Output → AI Code Review.
⚙️ Commands
| Command |
Description |
AI Code Review: Start Review |
Manually trigger an AI review |
(Auto) |
Runs automatically on every Git commit (if enabled) |
🛠 Requirements
- ✅ Internet connection (for Gemini API)
- ✅ Node.js >= 16
- ✅ Git initialized in the workspace (
git init)
- ✅ Valid Gemini API key configured inside your extension code or environment
🔐 Configuring the Gemini API Key
⚠️ Never commit your API keys to source control. Use environment variables or a secrets manager.
Create a .env file at the root of the extension project (not checked into Git):
GEMINI_API_KEY=YOUR_GEMINI_API_KEY_HERE
In your extension code, load the key with dotenv (example):
// src/extension.ts (example)
import dotenv from "dotenv";
dotenv.config();
const GEMINI_API_KEY = process.env.GEMINI_API_KEY;
If you prefer other secure methods, configure the key in your CI environment or use OS-level environment variables instead.
📦 Installation (VSIX)
To package and install the extension manually:
Build and package the extension:
npm run package
# this should produce a .vsix file
Install the resulting .vsix in VS Code:
- Open Extensions → the
... menu → Install from VSIX...
- Select the generated
.vsix file
🧩 Example: How the extension triggers reviews
The extension watches for local commits (or a Git hook) and then:
- Collects changed files from the commit
- Sends code snippets / diffs to the Gemini API
- Receives AI suggestions and formats them
- Writes the results to the Output panel under the
AI Code Review channel
Implementation details vary — the above is a typical flow. See src/ for the actual implementation.
🐞 Troubleshooting
✅ Recommended package.json snippets
"contributes": {
"commands": [
{
"command": "aiCodeReview.startReview",
"title": "AI Code Review: Start Review"
}
]
}
activationEvents (example):
"activationEvents": [
"onCommand:aiCodeReview.startReview",
"onStartupFinished"
]
🧪 Running tests (if available)
npm test
🤝 Contributing
Contributions are welcome. Please open issues and PRs for bugs, feature requests, or improvements.
- Fork the repository
- Create a branch:
git checkout -b feat/your-feature
- Make your changes and add tests
- Submit a PR with a clear description and screenshots if applicable
📝 License
MIT © Pankaj Shahare
Made with ❤️ — happy coding!
| |