@levelxup/ai-git-review
v1.0.0
Published
AI Git Code Reviewer for Laravel + Vue projects
Readme
AI Git Code Reviewer
A global AI code review tool for Laravel + Vue projects.
Automatically reviews staged code before commits and blocks commits if critical issues are found (e.g., dd(), dump(), console.log(), security or performance issues).
This tool uses OpenRouter or compatible OpenAI endpoints.
Installation
- Install the package globally via NPM:
npm install -g ai-git-reviewMake sure you have Node.js >= 18 installed.
Configuration
Copy the .env-example to .env inside the package folder:
cd $(npm root -g)/ai-git-review
cp .env-example .envEdit the .env file and add your API key and configuration:
OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENROUTER_MODEL=deepseek/deepseek-coder
OPENROUTER_API_ENDPOINT=https://openrouter.ai/api/v1
OPENROUTER_MAX_TOKENS=400⚠️ The script will always use the
.envfile located next toindex.js, not your project's.env.
Setup Git Pre-commit Hook (Optional)
To automatically run AI review on every commit:
1. Create a global Git hooks folder (if you don't have one yet):
mkdir -p ~/.git-hooks2. Create a pre-commit file inside it:
nano ~/.git-hooks/pre-commit3. Add the following content:
#!/bin/sh
# Run the global AI reviewer
AI_REVIEWER="$(npm root -g)/ai-git-review/index.js"
if [ ! -f "$AI_REVIEWER" ]; then
echo "❌ AI reviewer script not found at $AI_REVIEWER"
exit 0
fi
node "$AI_REVIEWER"
STATUS=$?
if [ $STATUS -eq 1 ]; then
echo "❌ Commit blocked due to AI detected issues."
exit 1
fi
echo "✅ Commit passed AI review."
exit 04. Make it executable:
chmod +x ~/.git-hooks/pre-commit5. Tell Git to use this global hooks folder:
git config --global core.hooksPath ~/.git-hooksNow all your repositories will automatically run AI code review on commit.
Usage
Run manually in any repo:
ai-git-reviewOr automatically via the Git pre-commit hook (recommended).
Logging
All AI review results and errors are logged in your project at:
storage/logs/ai-review.logThe log includes timestamps and reasons for failed commits.
Notes
- Only staged changes (
git add) are reviewed. - Only
.php,.js, and.vuefiles are checked. - Large diffs (>15,000 characters) are skipped automatically.
- Commits are blocked only if AI detects critical issues.
