PHPackages                             jcergolj/ai-pair-review - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jcergolj/ai-pair-review

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jcergolj/ai-pair-review
=======================

AI-powered code review using Claude Code CLI. Reviews for SOLID principles, design patterns, and code quality via composer commands.

v1(6mo ago)0196MITShellPHP ^8.2

Since Oct 22Pushed 6mo agoCompare

[ Source](https://github.com/jcergolj/ai-pair-review)[ Packagist](https://packagist.org/packages/jcergolj/ai-pair-review)[ RSS](/packages/jcergolj-ai-pair-review/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

AI 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
--------

[](#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 &amp; Fast** - No interactive prompts, just run and get results
- **🔗 VS Code Integration** - Auto-opens review files for easy access

Quick Start
-----------

[](#quick-start)

### Install and Setup

[](#install-and-setup)

```
# Install the package
composer require --dev jcergolj/ai-pair-review

# Setup scripts and directories
php artisan ai-review:install

```

### Usage

[](#usage)

```
# Review all uncommitted changes
composer ai-review

# Review only staged changes
composer ai-review-staged

# Integration with existing workflow
composer analyse && composer ai-review

```

How It Works
------------

[](#how-it-works)

### Simple Code Review Process

[](#simple-code-review-process)

1. **Run**: `composer ai-review` (or `composer ai-review-staged`)
2. **AI Analysis**: Claude AI analyzes your uncommitted PHP changes
3. **Automatic Save**: Complete analysis saved to `.ai/code-reviews/YYYY-MM-DD-HH-MM-SS/review.md`
4. **Review Issues**: Open the file to see detailed issues with File, Problem, and Fix information
5. **Copy &amp; Apply**: Use the included "Ready-to-Use Claude Command" to implement fixes
6. **Manual Control**: You choose which issues to fix by copying them to Claude

### File Outputs

[](#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

[](#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
------------------

[](#implementing-fixes)

You get two files for maximum convenience:

### 1. Review File (review.md)

[](#1-review-file-reviewmd)

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)

[](#2-claude-command-file-claude-commandtxt)

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

```
# Quick copy approach
cat .ai/code-reviews/2024-10-22-15-45-30/claude-command.txt | pbcopy

# Then paste into Claude Code CLI
claude
# Paste and press enter

```

### Using Claude Web Interface

[](#using-claude-web-interface)

1. Open: `.ai/code-reviews/YYYY-MM-DD-HH-MM-SS/claude-command.txt`
2. Copy the entire file contents
3. Paste into Claude web interface at
4. Review and apply the suggested changes

### Customizing Before Use

[](#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

[](#example-files-structure)

```
.ai/code-reviews/2024-10-22-15-45-30/
├── review.md          # Detailed analysis
└── claude-command.txt # Clean command ready to copy

```

**claude-command.txt example:**

```
I need you to implement the following code improvements in my Laravel project:

## Issues to Fix:

- [ ] **Duplicate Job Dispatch in CompletedOrderController**
  - File: app/Http/Controllers/Webhooks/CompletedOrderController.php:27-35
  - Problem: The `AllocateOneDirectToClientTokenJob` is dispatched twice with identical conditions and parameters (lines 27-30 and lines 32-35). This will cause the same job to run twice for every OneDirectToClient order, leading to duplicate emails, potential data inconsistencies, and unnecessary queue processing.
  - Fix: Remove one of the duplicate `AllocateOneDirectToClientTokenJob::dispatchIf()` calls. Keep only lines 27-30 or 32-35, but not both.

- [ ] **Missing type hints for parameters**
  - File: UserController.php:25
  - Problem: Method parameters lack type declarations
  - Fix: Add proper type hints for better code safety

## Context:
- This is a Laravel application
- Follow SOLID principles and design patterns
[... rest of context and instructions ...]

```

Integration with Existing Workflow
----------------------------------

[](#integration-with-existing-workflow)

### Basic Integration

[](#basic-integration)

```
# Your existing scripts + AI review
composer pint
composer phpstan
composer ai-review  # send(new WelcomeEmail());
        Log::info("Registered: {$user->email}");
        return $user;
    }
}

```

### After AI Suggestions

[](#after-ai-suggestions)

```
// Single Responsibility - one action
class RegisterUserAction {
    public function execute(RegisterUserData $data): User {
        $user = User::create($data->toArray());
        event(new UserRegistered($user));
        return $user;
    }
}

// Event for cross-cutting concerns
class SendWelcomeEmail {
    public function handle(UserRegistered $event): void {
        $event->user->notify(new WelcomeNotification());
    }
}

// Value object for type safety
class RegisterUserData {
    public function __construct(
        public readonly string $name,
        public readonly Email $email,
        public readonly HashedPassword $password,
    ) {}
}

```

Why Use This?
-------------

[](#why-use-this)

### 📚 Educational

[](#-educational)

Learn SOLID principles by seeing them applied to your actual code

### 🔍 Quality

[](#-quality)

Catch architectural issues before code review

### ⚡ Fast

[](#-fast)

Get instant expert feedback on every commit

### 🎯 Actionable

[](#-actionable)

Edit the review to keep what matters, submit to Claude for automatic fixes

Publishing to Packagist
-----------------------

[](#publishing-to-packagist)

To share this package publicly:

### 1. Create GitHub repository

[](#1-create-github-repository)

```
cd ai-pair-review
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/jcergolj/ai-pair-review.git
git push -u origin main

```

### 2. Tag a release

[](#2-tag-a-release)

```
git tag -a v1.0.0 -m "First release"
git push origin v1.0.0

```

### 3. Submit to Packagist

[](#3-submit-to-packagist)

1. Go to
2. Enter your GitHub URL: `https://github.com/jcergolj/ai-pair-review`
3. Click Submit

### 4. Install in any project

[](#4-install-in-any-project)

```
composer require --dev jcergolj/ai-pair-review
php artisan ai-review:install

```

Customization
-------------

[](#customization)

### Customize What Gets Reviewed

[](#customize-what-gets-reviewed)

The AI review prompt is fully customizable! See **[CUSTOMIZE\_PROMPT.md](CUSTOMIZE_PROMPT.md)** for the complete guide with examples.

**Quick start:**

```
# Open the reviewer script
code .git/hooks/ai-reviewer.sh

# Edit the REVIEW_PROMPT variable (starts at line 33)

```

**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](CUSTOMIZE_PROMPT.md) for copy-paste templates and examples.

### Save Reviews to Custom Location

[](#save-reviews-to-custom-location)

Edit `.ai/scripts/ai-reviewer.sh` around line 210:

```
# Save to a different location
mkdir -p "$PROJECT_ROOT/.reviews"
REVIEW_FILE="$PROJECT_ROOT/.reviews/code-review-$TIMESTAMP.md"

```

Extending to Other AI Providers
-------------------------------

[](#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](EXTEND_TO_OTHER_AI.md)

Quick example for OpenAI:

```
# Replace line 118 in .git/hooks/ai-reviewer.sh
REVIEW_OUTPUT=$(curl -s https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{"model":"gpt-4","messages":[...]}' | jq -r '.choices[0].message.content')

```

Contributing
------------

[](#contributing)

Contributions welcome!

**Especially wanted:**

- Support for additional AI providers
- Improved prompts
- Bug fixes
- Documentation improvements

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Submit a pull request

License
-------

[](#license)

MIT License - see LICENSE file

Credits
-------

[](#credits)

Built with [Claude Code CLI](https://claude.ai/code) by Anthropic

Support
-------

[](#support)

- **Issues**:
- **Documentation**: This README
- **Full Guide**: `.git/hooks/README.md` (after installation)

---

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance66

Regular maintenance activity

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

202d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/111d8d25ce610ce3d6cb7413529089ce6482e34dfc5a6a8bf04592719a0abe07?d=identicon)[jcergolj](/maintainers/jcergolj)

---

Top Contributors

[![jcergolj](https://avatars.githubusercontent.com/u/6940394?v=4)](https://github.com/jcergolj "jcergolj (1 commits)")

---

Tags

composercode reviewlaravelaicode qualitygitdesign patternssolidclaude

### Embed Badge

![Health badge](/badges/jcergolj-ai-pair-review/health.svg)

```
[![Health](https://phpackages.com/badges/jcergolj-ai-pair-review/health.svg)](https://phpackages.com/packages/jcergolj-ai-pair-review)
```

###  Alternatives

[dealerdirect/phpcodesniffer-composer-installer

PHP\_CodeSniffer Standards Composer Installer Plugin

596161.9M1.9k](/packages/dealerdirect-phpcodesniffer-composer-installer)[laraveldaily/filacheck

Static analysis for Filament projects - detect deprecated patterns and code issues

9016.5k](/packages/laraveldaily-filacheck)[exakat/exakat

The smart static analyzer for PHP

457.7k](/packages/exakat-exakat)[claude-php/claude-php-sdk-laravel

Laravel integration for the Claude PHP SDK - Anthropic Claude API

5010.8k](/packages/claude-php-claude-php-sdk-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
