Enterprise-grade AI-powered commit reviewer with super-modern code analysis across 24+ programming languages. Detects security, performance, logic errors, suggests modern code replacements, identifies code simplification opportunities and optimization sug
npm install ai-commit-reviewer-probash
npm install -g ai-commit-reviewer-pro
ai-review
`
$3
`bash
npm install ai-commit-reviewer-pro
npx ai-review
`
$3
`bash
Create pre-commit hook
chmod +x .git/hooks/pre-commit
echo 'npx ai-commit-reviewer-pro' > .git/hooks/pre-commit
`
βοΈ Quick Setup - Choose Your AI Provider
$3
1. Create GitHub Personal Access Token
- Go to https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Add scopes: repo, gist, read:user
- Copy your token
2. Add Token to .env
`bash
GITHUB_TOKEN=ghp_your_github_token_here
`
3. Start Using
`bash
ai-review
`
$3
1. Get OpenAI API Key
- Go to https://platform.openai.com/api-keys
- Create new secret key
- Copy your API key
2. Add Token to .env
`bash
OPENAI_API_KEY=sk-your-openai-key-here
OPENAI_MODEL=gpt-4o-mini
OPENAI_MAX_TOKENS=1000
`
3. Start Using
`bash
ai-review
`
$3
`bash
Test your configuration
ai-review
You should see: "π€ GitHub Copilot integration enabled" or "π€ OpenAI/ChatGPT integration enabled"
`
π― Usage Examples
$3
`bash
Stage your changes
git add .
Get AI code review
ai-review
If review passes, commit as usual
git commit -m "Add new feature"
`
$3
`bash
Setup (one-time)
echo '#!/bin/sh\nnpx ai-commit-reviewer-pro' > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
Now auto-reviewed on every commit
git commit -m "Your message"
`
$3
`javascript
import { validateCommit } from 'ai-commit-reviewer-pro';
// Run AI review
await validateCommit();
`
$3
`yaml
GitHub Actions example
- name: AI Code Review
run: npx ai-commit-reviewer-pro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
`
π Example Output
`bash
π Analyzing meaningful code changes...
π€ ChatGPT Analysis Complete:
WORLD_CLASS_SUGGESTIONS
π Production-Ready Code Improvements:
π HIGH PRIORITY:
π myfile.js:15 - Hardcoded API key detected (STAGED - will fix)
π myfile.js:23 - Empty catch block - silently ignoring errors (STAGED - will fix)
π‘ RECOMMENDED:
π myfile.js:8 - Console.log usage detected (INFO only)
π myfile.js:34 - Traditional for loop can be optimized (STAGED - will fix)
COPILOT_FIXES
1. Move to process.env.API_KEY
2. Add error logging, re-throw, or handle gracefully
3. Consider proper logging (winston, pino) for production
AUTO_APPLICABLE_FIXES
File: myfile.js
Line 15: const apiKey = "sk-123456" β const apiKey = process.env.API_KEY
Line 23: catch(e) {} β catch (error) { console.error('Error occurred:', error); }
`
π Configuration
$3
Create .env file in your project root:
`bash
============================================
OPTION 1: GitHub Copilot
============================================
GITHUB_TOKEN=ghp_your_github_token_here
============================================
OPTION 2: OpenAI / ChatGPT
============================================
OPENAI_API_KEY=sk-your-openai-key-here
OPENAI_MODEL=gpt-4o-mini
OPENAI_MAX_TOKENS=1000
============================================
Optional Settings
============================================
API_TIMEOUT=30000
ENABLE_AI_FALLBACK=true
AI_AUTO_OPEN_ERRORS=false
AI_SHOW_CODE_COMPARISON=true
NODE_ENV=development
`
$3
| Variable | Type | Default | Description |
|----------|------|---------|-------------|
| GITHUB_TOKEN | string | - | GitHub Personal Access Token (Option 1) |
| OPENAI_API_KEY | string | - | OpenAI API Key (Option 2) |
| OPENAI_MODEL | string | gpt-4o-mini | ChatGPT model to use |
| OPENAI_MAX_TOKENS | number | 1000 | Max tokens for OpenAI response |
| API_TIMEOUT | number | 30000 | API request timeout (ms) |
| ENABLE_AI_FALLBACK | boolean | true | Use local analysis if AI fails |
| AI_AUTO_OPEN_ERRORS | boolean | false | Auto-open files at errors |
| AI_SHOW_CODE_COMPARISON | boolean | true | Show side-by-side comparisons |
| AI_OPTIONAL_MODE | boolean | false | Make review non-blocking |
| AI_PROMPT_TIMEOUT_MS | number | 120000 | Interactive prompt timeout |
π Security
$3
- β
Never logs tokens to console
- β
Tokens stay in .env files
- β
No telemetry or data collection
- β
Works offline with local fallback
- β
MIT Licensed - open source code
$3
- π Store tokens in .env (add to .gitignore)
- π Rotate tokens regularly
- π« Never commit .env files
- π Use minimal required token scopes
- π Use environment-specific tokens for CI/CD
π Global Usage
ai-commit-reviewer-pro supports developers worldwide:
- π Multi-language - Works with any programming language
- π International Teams - Supports diverse coding standards
- βοΈ Framework Agnostic - Node.js, Python, Go, Rust, Java, etc.
- π§ Platform Independent - Windows, macOS, Linux
- π¬ Multiple AI Providers - GitHub Copilot or OpenAI
π Performance Metrics
| Metric | Value |
|--------|-------|
| Average Review Time | 2-5 seconds |
| Supported File Types | All text-based files |
| Multi-language Support | 50+ languages |
| API Cost | ~$0.01 per commit (OpenAI) |
| Uptime | 99.9% (GitHub/OpenAI) |
| Team Size | Unlimited |
π Troubleshooting
$3
`bash
Solution: Add either token to .env
GITHUB_TOKEN=ghp_... # OR
OPENAI_API_KEY=sk-...
`
$3
`bash
Solution: Verify your token/key
GitHub: https://github.com/settings/tokens
OpenAI: https://platform.openai.com/api-keys
`
$3
`bash
Solution: Stage files first
git add .
ai-review
`
$3
`bash
Solution: Wait for limit reset (usually 1 hour)
Or set SKIP_ON_RATE_LIMIT=true
`
π Full Documentation
For detailed setup, configuration, and advanced usage:
- GitHub Copilot Setup Guide
- OpenAI/ChatGPT Setup Guide
- CI/CD Integration Guide
- Configuration Reference
π€ Contributing
Contributions welcome! Please see CONTRIBUTING.md
π License
MIT License - See LICENSE for details
π― Use Cases
$3
- β
Learn best practices from AI feedback
- β
Catch bugs before pushing
- β
Improve code quality automatically
- β
Better commit messages
$3
- β
Consistent code standards
- β
Knowledge sharing through AI feedback
- β
Reduce code review bottlenecks
- β
Scale code quality across team
$3
- β
GitHub Copilot integration for organizations
- β
OpenAI for advanced team use
- β
Production-ready reliability
- β
Flexible provider options
- β
Non-blocking workflow integration
π Getting Started
`bash
1. Install globally
npm install -g ai-commit-reviewer-pro
2. Create .env with your AI provider
echo "GITHUB_TOKEN=your_token" > .env
OR
echo "OPENAI_API_KEY=your_key" > .env
3. Stage and review code
git add .
ai-review
4. Commit with confidence!
git commit -m "Better code with AI review"
`
---
Made with β€οΈ by developers for developers
- π Star on GitHub
- π¦ View on npm
- π¬ Report Issues
π Installation
$3
`bash
npm install -g ai-commit-reviewer-pro
`
$3
`bash
npm install ai-commit-reviewer-pro
`
βοΈ Configuration
$3
ai-commit-reviewer-pro uses GitHub's Copilot API for intelligent code analysis. You'll need a valid GitHub Personal Access Token with Copilot API access.
#### Step 1: Create GitHub Personal Access Token
1. Go to GitHub Settings
- Visit GitHub Personal Access Tokens
- Click "Generate new token" β "Generate new token (classic)"
2. Token Configuration
- Token name: ai-commit-reviewer-pro
- Expiration: 90 days (or your preference)
- Scopes to select:
- β
repo (full control of private repositories)
- β
gist (create gists)
- β
read:user (read user profile data)
- β
user:email (access email addresses)
3. Generate & Save
- Click "Generate token"
- β οΈ Important: Copy the token immediately (you won't see it again!)
- Store it safely - you'll need it in the next step
#### Step 2: Configure Environment Variables
Create a .env file in your project root:
`bash
GITHUB_TOKEN=ghp_your_github_token_here
`
Full Configuration Example:
`dotenv
GitHub Copilot API Token (REQUIRED)
GITHUB_TOKEN=ghp_your_personal_access_token
Optional: AI Review Mode Settings
AI_OPTIONAL_MODE=true
AI_AUTO_OPEN_ERRORS=false
AI_PROMPT_TIMEOUT_MS=30000
`
#### Step 3: Verify Token Works
`bash
Test your configuration
npm start
`
$3
| Variable | Required | Description | Default |
|----------|----------|-------------|---------|
| GITHUB_TOKEN | β
Required | GitHub Personal Access Token for Copilot API | - |
| AI_OPTIONAL_MODE | π‘ Recommended | Make AI review non-blocking (allows commits even if review fails) | true |
| AI_AUTO_OPEN_ERRORS | β Optional | Auto-open files at error locations in your editor | false |
| AI_DEFAULT_ON_CANCEL | β Optional | Default action on prompt timeout | auto-apply |
| AI_PROMPT_TIMEOUT_MS | β Optional | Timeout for interactive prompts (milliseconds) | 30000 |
| AI_AUTO_SELECT | β Optional | Auto-respond in non-interactive mode | - |
| AI_FORCE_PROMPT | β Optional | Force prompts in non-TTY environments | false |
$3
Set AI_OPTIONAL_MODE=true in your .env file for the best development experience:
`dotenv
Enable non-blocking AI review (recommended for teams)
AI_OPTIONAL_MODE=true
AI_AUTO_OPEN_ERRORS=true
GITHUB_TOKEN=ghp_your_github_token_here
`
Benefits of Non-Blocking Mode:
- β
Never blocks commits - Commits always proceed (even if review fails)
- π€ Smart suggestions - AI provides code improvement suggestions when available
- π Network resilient - Works gracefully when API is unavailable
- β‘ Fast commits - No waiting for AI analysis when in a hurry
- π§ Intelligent fallback - Uses local analysis when remote review unavailable
- π₯ Team-friendly - Doesn't disrupt development workflow
π― Usage
$3
`bash
Review staged changes
ai-review
`
$3
#### Option 1: Pre-commit Hook (Recommended)
Create .git/hooks/pre-commit:
`bash
#!/bin/sh
Run AI Commit Reviewer Pro
npx ai-review
`
Make it executable:
`bash
chmod +x .git/hooks/pre-commit
`
#### Option 2: Manual Review Before Commit
`bash
Stage your changes
git add .
Run AI review
ai-review
If review passes (or you approve), commit
git commit -m "Your commit message"
`
#### Option 3: Programmatic Usage
`javascript
import { validateCommit } from 'ai-commit-reviewer-pro';
// Run AI review
await validateCommit();
`
π Workflow
1. Stage Changes: Add files to git staging area
`bash
git add .
`
2. AI Analysis: The validator automatically:
- Analyzes your staged changes
- Sends the diff to GitHub Copilot API for intelligent review
- Receives professional code feedback
3. Interactive Decision: Based on AI feedback, you can:
- β
Apply suggestions - Make recommended changes
- β οΈ Skip with justification - Bypass with required reason
- β Cancel commit - Stop the commit process
4. Commit: If validation passes or is bypassed, proceed with commit
π Example Output
`bash
π Checking your staged changes...
π§ Sending code diff to AI for review...
π€ AI Review Feedback:
I found a few areas for improvement:
1. Security Issue: The API key is hardcoded in line 15. Consider using environment variables.
2. Performance: The loop in processData() could be optimized using map() instead of forEach().
3. Error Handling: Missing try-catch block around the database query on line 23.
What do you want to do?
β― Apply suggestions and continue
Skip validation with comment
Cancel commit
`
π¨ Features in Detail
$3
- Code Quality: Identifies potential bugs, security issues, and performance problems
- Best Practices: Suggests improvements following coding standards
- Documentation: Recommends better comments and documentation
- Refactoring: Suggests cleaner, more maintainable code patterns
$3
- Colored Output: Beautiful terminal interface with chalk.js
- Progress Indicators: Clear feedback during AI processing
- Smart Prompts: Contextual questions based on analysis results
$3
- Justification Required: Must provide reason when skipping suggestions
- Audit Trail: Logs bypass reasons for team accountability
- Configurable: Can be customized for team requirements
π οΈ Advanced Configuration
$3
Modify the analysis settings in .env:
`bash
Adjust timeout for slower networks
AI_PROMPT_TIMEOUT_MS=45000
Enable auto-opening of files with errors
AI_AUTO_OPEN_ERRORS=true
Keep AI review non-blocking (recommended)
AI_OPTIONAL_MODE=true
`
$3
Customize the AI review prompt for your team's needs by creating a .aicommitrc.json:
`json
{
"customPrompt": "You are a code reviewer for our team. Focus on: security, performance, and maintainability according to our coding standards.",
"rules": ["security", "performance", "readability"],
"maxAnalysisTime": 30000
}
`
π§ Troubleshooting
$3
Error: No GitHub Token
`bash
Error: GITHUB_TOKEN not found
`
Solution: Ensure .env file exists with GITHUB_TOKEN=ghp_your_token. See GitHub Token Setup section.
Error: Invalid Token Scopes
`bash
Error: Token does not have required scopes
`
Solution: Regenerate your token with proper scopes: repo, gist, read:user, user:email
Error: No staged changes
`bash
β οΈ No staged changes found
`
Solution: Stage files first with git add .
Error: API Rate Limit
`bash
Error: GitHub API rate limit exceeded
`
Solution: Wait an hour for rate limit reset, or optimize your repository size.
$3
Enable debug logging:
`bash
On Windows
set DEBUG=ai-commit-reviewer-pro:*
ai-review
On macOS/Linux
DEBUG=ai-commit-reviewer-pro:* ai-review
`
π Performance
- Average Analysis Time: 2-5 seconds
- API Cost: ~$0.001-0.01 per commit (depending on change size)
- Supported File Types: All text-based files (JS, TS, Python, etc.)
π€ Contributing
1. Fork the repository
2. Create a feature branch: git checkout -b feature/amazing-feature
3. Stage your changes: git add .
4. Run AI review: ai-review
5. Commit your changes: git commit -m "Add amazing feature"
6. Push to the branch: git push origin feature/amazing-feature
7. Open a pull request
See CONTRIBUTING.md for detailed guidelines.
π Requirements
- Node.js: >= 12.0.0
- Git: Any recent version
- GitHub Token: Required for GitHub Copilot API access (free tier available)
- Internet Connection: Required for AI code review (optional mode available for offline)
β
Getting Started (5 Minutes)
$3
`bash
npm install -g ai-commit-reviewer-pro
`
$3
Follow the GitHub Token Setup guide above.
$3
`bash
Create .env file in your project
echo "GITHUB_TOKEN=ghp_your_token_here" > .env
`
$3
`bash
Review your staged changes
ai-review
``