Overview AI coding assistants rely heavily on context files like CLAUDE.md to follow project standards. However, LLMs often overlook text-based instructions in large files. This tutorial explores shifting these rules from passive documentation to active automation using Laravel tools. By offloading linting, type-checking, and architecture validation to the machine, you ensure 100% compliance while saving valuable context window tokens. Prerequisites To follow this guide, you should be comfortable with the PHP ecosystem and Laravel framework. Familiarity with Composer for package management and basic knowledge of CI/CD concepts like pre-commit hooks will help you implement these automations effectively. Key Libraries & Tools * Laravel Pint: A zero-config PHP code style fixer built on top of PHP-CS-Fixer. * Larastan: A wrapper around PHPStan specifically designed to handle Laravel's magic methods and relationships. * Pest PHP: A testing framework that includes powerful architectural testing capabilities. Code Walkthrough Automating Style with Pint Instead of asking an AI to "always use curly braces," define these in `pint.json`. This ensures the rules are enforced every time you run the tool. ```json { "preset": "laravel", "rules": { "braces": true, "no_empty_comment": true, "no_unused_imports": true } } ``` You can trigger this via a pre-commit hook or directly through Claude Code events to fix styling immediately after the AI edits a file. Enforcing Strict Types with Larastan Move rules regarding return types and type hints out of your markdown files. Larastan catches missing type hints in relationship methods and method signatures far more reliably than an LLM. ```neon phpstan.neon parameters: level: 5 paths: - app checkMissingIterableValueType: true ``` Architectural Tests with Pest Use Pest to prevent developers (and AI) from using forbidden functions or violating folder structures. ```php // tests/ArchTest.php arch('globals') ->expect(['dd', 'dump', 'ray']) ->not->toBeUsed(); arch('app') ->expect('App\Models') ->toOnlyBeUsedIn('App\Repositories'); ``` Syntax Notes When configuring `pint.json`, notice the use of boolean flags to toggle specific PSR standards. In Larastan (and PHPStan), the `level` parameter is your primary lever for strictness; higher levels require more explicit type definitions. Practical Examples By moving 22 lines of text-based rules into these tools, you save roughly 800 tokens per prompt. In a real-world CI/CD pipeline, this setup prevents "style drift" where different AI models might interpret
Pest PHP
Products
- Feb 23, 2026
- Feb 9, 2026
- Aug 5, 2025
- Jul 30, 2025
- Nov 25, 2024