Download the PHP package jcergolj/ai-pair-review without Composer
On this page you can find all versions of the php package jcergolj/ai-pair-review. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jcergolj/ai-pair-review
More information about jcergolj/ai-pair-review
Files in jcergolj/ai-pair-review
Package ai-pair-review
Short Description AI-powered code review using Claude Code CLI. Reviews for SOLID principles, design patterns, and code quality via composer commands.
License MIT
Informations about the package ai-pair-review
AI Review
🤖 AI-powered code review for Laravel projects using Claude Code CLI.
Automatically reviews your code for SOLID principles, design patterns, and code quality via composer commands.
Features
- 🎯 SOLID Principles - Detects violations of Single Responsibility, Open/Closed, etc.
- 🏗️ Design Patterns - Suggests Strategy, Factory, Repository, Observer patterns
- 🔧 Code Quality - Identifies code smells and refactoring opportunities
- ✅ Laravel Best Practices - N+1 queries, proper Eloquent usage, security
- 📝 Comprehensive Reports - Detailed analysis with actionable improvement plans
- 📋 Ready-to-Use Commands - Includes Claude prompts you can copy and paste
- ⚡ Simple & Fast - No interactive prompts, just run and get results
- 🔗 VS Code Integration - Auto-opens review files for easy access
Quick Start
Install and Setup
Usage
How It Works
Simple Code Review Process
- Run:
composer ai-review(orcomposer ai-review-staged) - AI Analysis: Claude AI analyzes your uncommitted PHP changes
- Automatic Save: Complete analysis saved to
.ai/code-reviews/YYYY-MM-DD-HH-MM-SS/review.md - Review Issues: Open the file to see detailed issues with File, Problem, and Fix information
- Copy & Apply: Use the included "Ready-to-Use Claude Command" to implement fixes
- Manual Control: You choose which issues to fix by copying them to Claude
File Outputs
- Detailed Review:
.ai/code-reviews/YYYY-MM-DD-HH-MM-SS/review.md- Full AI analysis for decision-making - Claude Command:
.ai/code-reviews/YYYY-MM-DD-HH-MM-SS/claude-command.txt- Ready-to-copy command with all issues - Auto-open: Review file automatically opens in VS Code if available
- Organized: Each review session gets its own timestamped folder
What You Get
Each review includes:
- Summary: Overview of code changes and quality
- Prioritized Issues: High/Medium/Low priority with specific file locations
- Detailed Analysis: File names, line numbers, problems, and suggested fixes
- Separate Command File: Clean Claude prompt with all issues ready to copy
- Positive Feedback: Recognition of good practices in your code
Implementing Fixes
You get two files for maximum convenience:
1. Review File (review.md)
Contains detailed analysis for your decision-making:
- Complete issue breakdown
- File locations and line numbers
- Priority levels (High/Medium/Low)
- Specific problems and suggested fixes
2. Claude Command File (claude-command.txt)
Ready-to-use command with complete issue context:
- Full Details: Each issue includes File, Problem, and Fix information
- Line Numbers: Specific locations for precise fixes
- Complete Context: Everything Claude needs to implement the fix
- Copy-Ready: Just copy the entire file and paste into Claude
Using Claude Web Interface
- Open:
.ai/code-reviews/YYYY-MM-DD-HH-MM-SS/claude-command.txt - Copy the entire file contents
- Paste into Claude web interface at https://claude.ai
- Review and apply the suggested changes
Customizing Before Use
Edit the claude-command.txt file to:
- Remove entire issues you don't want to fix (including all sub-bullets)
- Focus on specific priority levels only
- Add your own project-specific context
- Modify instructions to match your coding standards
Example Files Structure
claude-command.txt example:
Integration with Existing Workflow
Basic Integration
Advanced Integration
Add to your composer.json:
Then run: composer analyse-with-ai
Code Review Storage
All AI-generated code reviews are automatically stored in the .ai/code-reviews/ folder in your project root. Each review is saved as a markdown file with a timestamp:
Interactive Triage System
When issues are found, you'll be prompted for each one:
Options:
- [f]ix - Add to your fix list for immediate action
- [s]kip - Skip for this review, will appear again next time
- [i]gnore forever - Never show this issue again (until fresh changes)
- [q]uit - Exit the triage process
Smart Ignore System
Issues you ignore are stored in .ai/ignore.yml:
Key features:
- Persistent: Ignored issues won't appear in subsequent reviews
- Fresh start: When you commit changes, ignore list automatically resets
- Team-friendly:
.ai/ignore.ymlis gitignored (personal preferences)
This folder is automatically created on the first review and contains:
- Timestamped files - Each review gets a unique filename
- Editable markdown - Remove items you don't want to fix
- Actionable checklists - Ready to submit to Claude Code for implementation
After Committing
Managing Ignore List
Example Review
Generated review file:
What Gets Reviewed
🎯 SOLID Principles
- Single Responsibility - One class, one reason to change
- Open/Closed - Open for extension, closed for modification
- Liskov Substitution - Proper use of abstractions
- Interface Segregation - Focused, cohesive interfaces
- Dependency Inversion - Depend on abstractions, not concretions
🏗️ Architecture & Patterns
- Design pattern usage (Strategy, Factory, Repository, Observer, etc.)
- Dependency injection
- Domain-Driven Design principles
- God objects and procedural code
🔧 Code Quality
- Code smells (long methods, feature envy, data clumps)
- Duplicated code
- Complex conditionals → polymorphism
- Better use of collections
✅ Laravel Best Practices
- Eloquent relationships and query optimization
- N+1 query detection
- Service providers and facades
- Security (authorization, validation, mass assignment)
- Proper use of Form Requests, Events, Jobs
📝 Type Safety
- Missing type declarations
- Interface opportunities
- Value objects instead of primitives
Configuration
Basic Configuration
Edit .pre-commit-config in your project root:
Disable AI Review
Ignore System Configuration
The ignore system automatically creates .ai/ignore.yml to track issues you don't want to see again.
Structure:
Key behaviors:
- Issues persist: Ignored issues won't appear until fresh changes
- Auto-reset: When you commit new changes, ignore list resets (fresh start)
- Personal:
.ai/ignore.ymlis gitignored - each developer has their own preferences - Team-friendly: Doesn't interfere with team workflow
Manual management:
Large Changes & Token Limits
Claude has token limits (~200k tokens, roughly 800k characters). The hook automatically handles large changes:
- ⚠️ Warning at 300KB - Shows size and suggests splitting commits
- 🛑 Block at 500KB - Offers options:
- Skip AI review and commit normally
- Truncate diff for partial review
- Abort to split changes
- 🚨 Token errors - Clear error messages with suggestions
Best practices for large changes:
Commands
Install
Installs the AI review system and creates:
Options:
--force- Overwrite existing files
Uninstall
Removes the pre-commit hooks.
Requirements
- PHP 8.4+
- Laravel 12+
- Git repository
- Claude Code CLI installed and in PATH (default)
Note: Currently uses Claude Code CLI, but can be easily modified to use other AI providers (OpenAI, Gemini, Ollama, etc.). See EXTEND_TO_OTHER_AI.md for instructions.
Install Claude Code from https://claude.ai/code
Team Setup
Option 1: Commit config to repository
Team members run:
Option 2: Auto-install on composer install
Add to your project's composer.json:
Non-Laravel Projects
The hooks work with any PHP project! To install manually:
Support Other Languages
Edit .git/hooks/ai-reviewer.sh line 17:
Troubleshooting
"Claude CLI not found"
Install Claude Code from https://claude.ai/code
The hook will skip gracefully if Claude is not installed.
Hook not running
Review file not opening
Install VS Code CLI or the review is still saved to .ai/code-reviews/YYYY-MM-DD-HH-MM-SS/review.md
Slow reviews
For large commits (10+ files), reviews may take 20-30 seconds. Consider:
- Smaller, more focused commits
- Temporarily disable:
AI_REVIEW=false git commit
Examples
Before Review
After AI Suggestions
Why Use This?
📚 Educational
Learn SOLID principles by seeing them applied to your actual code
🔍 Quality
Catch architectural issues before code review
⚡ Fast
Get instant expert feedback on every commit
🎯 Actionable
Edit the review to keep what matters, submit to Claude for automatic fixes
Publishing to Packagist
To share this package publicly:
1. Create GitHub repository
2. Tag a release
3. Submit to Packagist
- Go to https://packagist.org/packages/submit
- Enter your GitHub URL:
https://github.com/jcergolj/ai-pair-review - Click Submit
4. Install in any project
Customization
Customize What Gets Reviewed
The AI review prompt is fully customizable! See CUSTOMIZE_PROMPT.md for the complete guide with examples.
Quick start:
Popular customizations:
- Security Focus - Prioritize vulnerabilities and security issues
- Performance Focus - Catch N+1 queries, caching opportunities
- Team Standards - Enforce your company's specific coding rules
- Educational Mode - Get detailed explanations for learning
- Strict Mode - Catch every small issue
- Lenient Mode - Only report critical problems
See CUSTOMIZE_PROMPT.md for copy-paste templates and examples.
Save Reviews to Custom Location
Edit .ai/scripts/ai-reviewer.sh around line 210:
Extending to Other AI Providers
While this package uses Claude Code CLI by default, it's built on standard Git hooks and can be easily modified to use:
- OpenAI GPT-4 (via API)
- Google Gemini (via API)
- Ollama (local, offline)
- GitHub Copilot CLI
- Any other AI service
The pre-commit hook is just a bash script - modify .git/hooks/ai-reviewer.sh to call your preferred AI provider.
Full guide with examples: EXTEND_TO_OTHER_AI.md
Quick example for OpenAI:
Contributing
Contributions welcome!
Especially wanted:
- Support for additional AI providers
- Improved prompts
- Bug fixes
- Documentation improvements
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT License - see LICENSE file
Credits
Built with Claude Code CLI by Anthropic
Support
- Issues: https://github.com/jcergolj/ai-pair-review/issues
- Documentation: This README
- Full Guide:
.git/hooks/README.md(after installation)