A portable, CLI-based AI code review system that performs comprehensive reviews at commit timeβpowered by GitHub Copilot.
Quick Start β’ Features β’ Workflows β’ Configuration β’ Troubleshooting
You're about to commit code with a hardcoded password. Or a SQL injection vulnerability. Or an empty catch block. Or naming convention violations.
Traditional code reviews catch these issuesβdays later. By then, they're already in your codebase, possibly in production.
This tool intercepts your commits before they happen, analyzes your staged changes with AI, and blocks commits that contain critical security, correctness, or quality issues.
Fix the issue. Commit again. Ship secure code.
This isn't just a security toolβit's a comprehensive AI code reviewer using a multi-agent architecture where specialized agents work in parallel to analyze different aspects of your code:
Multi-Agent System:
- π Security Agent: Focuses on vulnerabilities, secrets, and security patterns
- π Naming Agent: Checks Java naming conventions and code style
- β Quality Agent: Reviews correctness, performance, and best practices
- π€ Summarizer Agent: Aggregates results and eliminates duplicates
Review Categories:
| Category | Severity | Examples |
|---|---|---|
| π Security | BLOCK | Hardcoded secrets, SQL injection, unsafe deserialization |
| π Correctness | BLOCK | Null pointer risks, thread safety issues |
| β‘ Performance | WARN | Inefficient collections, O(n) when O(1) available |
| π Code Quality | WARN | Empty catch blocks, poor exception handling |
| π― Best Practices | INFO | Naming conventions, Java code standards |
Severity Levels:
- BLOCK: Commit rejected (security & critical bugs)
- WARN: Commit allowed with warnings (quality issues)
- INFO: Commit allowed with suggestions (style & conventions)
| Feature | Description |
|---|---|
| π Comprehensive Reviews | Checks security, correctness, performance, quality, and best practices |
| π€ Multi-Agent Architecture | Specialized agents (Security, Naming, Quality) run in parallel for faster reviews |
| π― Java-Focused Checklist | YAML-driven rules covering OWASP security + code quality standards |
| β‘ Reviews Only Changes | Analyzes staged diffs, not entire filesβfast and focused |
| π§ AI-Powered Analysis | Leverages GitHub Copilot for intelligent code understanding |
| π« Smart Blocking | Only blocks BLOCK-severity issues (security/bugs), allows WARN/INFO |
| π Structured Markdown Output | Human-readable results parsed with native tools (no jq required) |
| π₯οΈ Cross-Platform | Native PowerShell for Windows, bash for macOS/Linux |
| π§ IDE-Compatible | Works with IntelliJ IDEA, VS Code, PyCharm, WebStorm, and any git client |
| βοΈ Fully Customizable | Extend the YAML checklist with your own rules |
1. Install GitHub Copilot CLI
All platforms (requires Node.js):
npm install -g @githubnext/github-copilot-cliThen authenticate:
copilot authThis will open a browser window to authenticate with your GitHub account (requires GitHub Copilot subscription).
Windows (PowerShell) - Recommended:
.\install.ps1macOS/Linux (bash):
./install.shThe script checks dependencies, installs the pre-commit hook, and verifies everything works.
Manual Installation:
# Windows - copy the hook wrapper
Copy-Item pre-commit.ps1 -Destination . -Force
# The installer creates a bash wrapper in .git/hooks/pre-commit that calls the PowerShell script# macOS/Linux
cp pre-commit.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitNow every git commit triggers an automatic AI review:
git add src/main/java/MyClass.java
git commit -m "Add new feature"
# AI review runs automatically β¨| Platform | Script | Notes |
|---|---|---|
| Windows | pre-commit.ps1 |
Native PowerShell, runs parallel jobs |
| macOS | pre-commit.sh |
Native bash, runs background jobs |
| Linux | pre-commit.sh |
Native bash, runs background jobs |
The tool runs natively in PowerShell with full feature support:
- β Parallel agent execution using PowerShell jobs
- β Full emoji and Unicode support
- β No WSL required
- β Works with any IDE (IntelliJ, VS Code, etc.)
- β Works from PowerShell, CMD, or Git Bash
IntelliJ IDEA / PyCharm / WebStorm:
- Commit via IDE dialog (Ctrl+K) as normal
- The pre-commit hook runs automatically
- Review output appears in the IDE's console
VS Code:
- Commit via Source Control panel as normal
- The pre-commit hook runs automatically
- Review output appears in the terminal
Any Git Client: The hook works with any tool that uses gitβGitHub Desktop, GitKraken, Tower, etc.
β οΈ Critical: This tool sends your code to AI services. For proprietary/corporate code, you MUST use GitHub Copilot Business/Enterprise, Azure OpenAI, or local LLMs (Ollama). Do NOT use free/consumer AI tiers for confidential code.
flowchart LR
A[Your Code] --> B[git diff]
B --> C[Pre-commit Hook]
C --> D[GitHub Copilot API]
D --> E[AI Analysis]
E --> F[Markdown Response]
F --> G[Block/Allow Decision]
| Aspect | Enterprise/Business Plans | Individual/Free Plans |
|---|---|---|
| Data Retention | β Prompts discarded immediately after response | |
| Training Usage | β Your code is NOT used for AI training | |
| Contractual Protection | β Data Processing Agreement (DPA), GDPR compliance | |
| IP Indemnification | β Often includes IP infringement protection | β Typically not included |
For corporate/proprietary codebases, use ONLY these options:
-
GitHub Copilot Business/Enterprise
- β Code is discarded immediately after generating response
- β Never used to train AI models
- β Contractual data processing agreement (DPA)
- β GDPR compliant
-
Azure OpenAI Service
- β Enterprise SLA (99.9% uptime)
- β Data residency options
- β Your data never leaves your Azure tenant
- β Full RBAC and compliance controls
-
Local LLMs (Ollama + CodeLlama)
- β Data never leaves your machine
- β No internet connection required
- β Complete privacy
- β No subscription costs
Do NOT use free/individual AI plans for corporate code:
- β GitHub Copilot Individual - May retain prompts, different terms than Business/Enterprise
- β Free ChatGPT, Claude, etc. - Code may be used for model training
- β Free API trials - Limited data protection guarantees
Bottom line: If you're working on proprietary code, you MUST use GitHub Copilot Business/Enterprise, Azure OpenAI, or local models (Ollama). Consumer/free tiers are NOT suitable for confidential code.
Regardless of which tier you use, never send:
- β Hardcoded secrets, API keys, or passwords
- β Proprietary algorithms or trade secrets
- β Customer PII or HIPAA/GDPR protected data
- β Internal infrastructure details (IPs, hostnames, internal URLs)
- Use Enterprise AI for corporate/proprietary codebases
- Use
.gitignoreto exclude sensitive files - Use environment variables for all secrets
- Review staged files before committing:
git diff --cached - Consider local LLMs (Ollama, CodeLlama) for highly sensitive codebases
- Set
AI_REVIEW_ENABLED=falsefor sensitive commits
Commit β Review β Fix β Commit
See full workflow
git add src/main/java/UserService.java
git commit -m "Add user authentication"βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI REVIEW: COMMIT BLOCKED β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β [BLOCK] src/main/java/UserService.java:23
Hardcoded database password detected.
In your IDE (VS Code, IntelliJ):
- Open the file, select the problematic code
- Ask Copilot: "Fix this hardcoded password using environment variables"
Or via CLI:
gh copilot suggest "How do I fix hardcoded passwords in Java using environment variables?"// β Before (BLOCKED):
private static final String DB_PASSWORD = "admin123";
// β
After (GOOD):
private static final String DB_PASSWORD = System.getenv("DB_PASSWORD");git add src/main/java/UserService.java
git commit -m "Add user authentication with secure password handling"
# β
Review passes!# View full review
Get-Content .ai/last_review.json
# View individual agent reports
Get-Content .ai/agents/security/review.md
Get-Content .ai/agents/naming/review.md
Get-Content .ai/agents/quality/review.md
# Search for BLOCK issues
Select-String -Path .ai/last_review.json -Pattern "\[BLOCK\]"On macOS/Linux:
cat .ai/last_review.json
grep -A 2 '\[BLOCK\]' .ai/last_review.jsonWhen you absolutely must commit immediately:
git commit --no-verify -m "Emergency hotfix for production"
β οΈ Use sparingly! Always track bypassed security debt:Add-Content -Path SECURITY_DEBT.md -Value "TODO: Fix issues from $(git rev-parse HEAD)"
# .github/workflows/pr-check.yml
- name: Run AI Code Review
shell: pwsh
run: |
if (-not (.\pre-commit.ps1)) {
Write-Host "Code review failed"
Get-Content .ai/last_review.json
exit 1
}# Single commit
git commit --no-verify -m "Skip review for this commit"
# Permanently (session)
$env:AI_REVIEW_ENABLED = 'false'
# Remove hook entirely
Remove-Item .git/hooks/pre-commitWindows (PowerShell):
Remove-Item .git\hooks\pre-commitmacOS/Linux:
rm .git/hooks/pre-commitEdit .ai/java_code_review_checklist.yaml:
rules:
- id: custom-rule-001
description: "Check for deprecated API usage"
severity: WARN # BLOCK | WARN | INFO| Severity | Effect | Example Issues |
|---|---|---|
BLOCK |
β Prevents commit | Hardcoded secrets, SQL injection, null pointer risks |
WARN |
Poor exception handling, performance issues | |
INFO |
βΉοΈ Allows commit, shows info | Naming convention violations |
| Variable | Default | Description |
|---|---|---|
AI_REVIEW_MODEL |
gpt-4.1 |
AI model for code review (see models below) |
AI_REVIEW_ENABLED |
true |
Set to false to skip AI review |
SKIP_SENSITIVE_CHECK |
false |
Skip sensitive data warning prompt |
FORCE_COLOR |
false |
Force colored output (bash only) |
Available models: gpt-4.1, gpt-5, gpt-5-mini, gpt-5.1, gpt-5.1-codex, gpt-5.2, claude-sonnet-4, claude-sonnet-4.5, claude-haiku-4.5, claude-opus-4.5, gemini-3-pro-preview
# Use a different model
$env:AI_REVIEW_MODEL = 'claude-sonnet-4.5'
git commit -m "message".
βββ pre-commit.ps1 # PowerShell pre-commit hook (Windows)
βββ pre-commit.sh # Bash pre-commit hook (macOS/Linux)
βββ install.ps1 # PowerShell installation script
βββ install.sh # Bash installation script
βββ LICENSE # MIT License
βββ .ai/
β βββ agents/ # Multi-agent system
β β βββ security/ # Security agent
β β βββ naming/ # Naming conventions agent
β β βββ quality/ # Code quality agent
β β βββ summarizer/ # Results aggregator
β βββ java_code_review_checklist.yaml # Review rules (YAML)
β βββ java_review_prompt.txt # AI prompt template
β βββ last_review.json # Last review results
βββ docs/
β βββ ARCHITECTURE.md # System design
β βββ SECURITY.md # Security guide
β βββ linked_image.png # Project image
βββ examples/
β βββ BadClass.java # Example with intentional issues
β βββ a.java # Simple example file
β βββ README.md # Examples documentation
βββ README.md
"GitHub CLI (gh) not found"
Install GitHub CLI for your platform:
# Windows
winget install --id GitHub.cli
# Or with Chocolatey
choco install gh
# Or with Scoop
scoop install gh# macOS
brew install gh
# Linux
# See https://github.com/cli/cli/blob/trunk/docs/install_linux.md"GitHub Copilot CLI extension not installed"
gh extension install github/gh-copilot"Could not connect to GitHub Copilot"
- Ensure you're authenticated:
gh auth login - Check your GitHub Copilot subscription
- Verify extension:
gh extension list
Hook not running
Windows:
# Check if hook exists
Test-Path .git/hooks/pre-commit
# Re-run installer
.\install.ps1macOS/Linux:
# Check if executable
ls -la .git/hooks/pre-commit
# Make executable
chmod +x .git/hooks/pre-commitReview takes too long
- Large diffs (>20KB) are automatically truncated
- Consider smaller, focused commits
- Bypass for large refactors:
git commit --no-verify
PowerShell execution policy error
# Allow script execution for current user
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser"Too many arguments" or argument length errors (Windows)
Windows has a command-line argument length limit of ~8,191 characters. The PowerShell script automatically handles this by:
- Checking prompt length before invocation
- Using stdin piping (
copilot -p -) for large prompts - Writing prompts to temp files when needed
If you still encounter issues:
# Reduce diff size by committing smaller changes
git add -p # Stage partial changes
# Or increase MAX_DIFF_SIZE in pre-commit.ps1 if your prompts are within limits
# Default: $MAX_DIFF_SIZE = 20000 (bytes)
# Default: $MAX_ARG_LENGTH = 7000 (characters)MIT License - See LICENSE for details.

