Using our guidelines with AI
#Introduction
We've created AI-optimized guidelines specifically formatted for AI assistants like Claude Code and GitHub Copilot to ensure they generate code that follows Spatie's Laravel & PHP standards.
Our AI-optimized guidelines cover:
- Core Laravel principles - Follow documented Laravel conventions first
- PHP standards - PSR compliance, type declarations, nullable syntax
- Class structure - Typed properties, constructor promotion, traits
- Control flow - Early returns, avoiding else statements, happy path patterns
- Laravel conventions - Routes, controllers, configuration, artisan commands
- Naming conventions - Complete reference for classes, methods, files, and URLs
- Code quality reminders - Essential principles for maintainable code
#Using Laravel Boost (Recommended)
The easiest way to use our guidelines in your Laravel projects is with Laravel Boost.
If you haven't already, install Laravel Boost, and then our guideline package.
composer require laravel/boost --dev composer require spatie/boost-spatie-guidelines --dev
After installing, run the following and select the Spatie guidelines from the list under Agent Skills.
php artisan boost:install
Choose the coding agents you want to install Boost for, and you're all set! Your agent will now automatically follow our guidelines when creating code.
You can view the raw AI-optimized guidelines file here.
#Alternative: Global Integration using Claude Code
If you're not using Laravel Boost, you can add the guidelines to your global Claude Code configuration so they're available across all projects:
# Make sure the Claude configuration file exists mkdir -p ~/.claude && touch ~/.claude/CLAUDE.md # Download our guidelines curl -o ~/.claude/laravel-php-guidelines.md https://spatie.be/laravel-php-ai-guidelines.md # Tell Claude to read the guidelines file echo -e '\n## Coding Standards\nWhen working with Laravel/PHP projects, first read the coding guidelines at @~/.claude/laravel-php-guidelines.md' >> ~/.claude/CLAUDE.md
#Alternative: Project-Specific Integration using Claude Code
For individual Laravel projects not using Laravel Boost, you can download the guidelines to your project root:
# Make sure the Claude configuration file exists touch CLAUDE.md # Download our guidelines curl -o laravel-php-guidelines.md https://spatie.be/laravel-php-ai-guidelines.md # Tell Claude to read the guidelines file echo -e '\n## Coding Standards\nWhen working on this Laravel/PHP project, first read the coding guidelines at @laravel-php-guidelines.md' >> CLAUDE.md
Optionally, you can create a Composer script to keep guidelines updated:
{ "scripts": { "update-guidelines": "curl -o docs/laravel-php-guidelines.md https://spatie.be/laravel-php-ai-guidelines.md" } }
#AI docs for Spatie packages
The Context7 MCP project contains docs for various Spatie packages.