code-quality

Run code quality checks for Laravel Spectrum (PHPStan, Laravel Pint, PHPUnit). Use when user mentions "lint", "format", "code quality", "PR準備", "コミット前チェック", or before creating commits/PRs. Also use after writing significant code changes.

⭐1stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026

When & Why to Use This Skill

This Claude skill automates comprehensive code quality workflows for Laravel Spectrum projects by integrating Laravel Pint for styling, PHPStan for static analysis, and PHPUnit for testing. It ensures code consistency, identifies potential bugs through rigorous type-checking, and streamlines the development lifecycle by enforcing high engineering standards before code is committed or merged.

Use Cases

  • Pre-Commit Validation: Automatically run linting and formatting checks using Laravel Pint to ensure code adheres to project standards before every commit.
  • Pull Request Preparation: Execute a full suite of static analysis (PHPStan Level 5) and unit tests to guarantee high-quality submissions and minimize CI/CD pipeline failures.
  • Post-Refactoring Audit: Verify system integrity after significant architectural changes by running PHPUnit tests and checking for null safety or type-hinting issues.
  • Automated Code Styling: Instantly resolve formatting violations and maintain a unified codebase style across the Laravel Spectrum environment without manual intervention.
namecode-quality
descriptionRun code quality checks for Laravel Spectrum (PHPStan, Laravel Pint, PHPUnit). Use when user mentions "lint", "format", "code quality", "PR準備", "コミット前チェック", or before creating commits/PRs. Also use after writing significant code changes.

Code Quality

Quick Start

Run all checks in order:

composer format:fix && composer analyze && composer test

Workflow

Execute checks in this order. Fix issues at each step before proceeding.

1. Format (Laravel Pint)

composer format:fix    # Auto-fix code style
composer format        # Dry-run (check only)

2. Analyze (PHPStan Level 5)

composer analyze

No baseline additions allowed. Fix all reported issues.

3. Test (PHPUnit)

composer test                                    # All tests
vendor/bin/phpunit tests/Unit/SomeTest.php       # Specific file
vendor/bin/phpunit --filter testMethodName       # Specific method
composer test-coverage                           # With coverage report

Pre-PR Checklist

  1. composer format:fix - Fix code style
  2. composer analyze - Pass static analysis (no new errors)
  3. composer test - All tests pass
  4. Verify in demo-app:
    cd demo-app/laravel-12-app
    php artisan spectrum:generate
    

Common Issues

PHPStan Errors

  • Add proper type hints to method parameters and return types
  • Use @var annotations for complex types
  • Check for null safety issues

Pint Violations

Usually auto-fixed. If manual fix needed, check Laravel preset rules.

Test Failures

  • Run specific test: vendor/bin/phpunit --filter testName
  • Check test fixtures in tests/Fixtures/