spatie-laravel-php — Claude Code skill: what it does, how to install
Applies Spatie guidelines and PSR-12 standards when generating, refactoring, or reviewing Laravel PHP files and Blade templates.
npx skills add spatie/guidelines-skills --skill spatie-laravel-php -a claude-codeWhat spatie-laravel-php does
This skill guides coding agents through Spatie's conventions for PHP and Laravel projects. It enforces typed properties, explicit return types including void, constructor property promotion, and early returns instead of nested else statements. When breaking a method chain across lines, every subsequent -> must start on a separate line.
The workflow standardises Laravel structures. Controllers use plural names, route definitions require tuple syntax such as [PostsController::class, 'index'], and configuration values come from config() rather than env(). The skill prevents redundant docblocks when native type hints exist and bans adding final or readonly keywords by default.
JavaScript, TypeScript, CSS, database schema design, and non-Laravel setups remain out of scope. If a guideline clashes with existing repository rules, standard Laravel conventions take precedence to preserve consistency.
What it helps with
- format Laravel controllers and Eloquent models to Spatie standards
- eliminate redundant docblocks covered by native PHP types
- replace nested else branches with early returns
- standardise route definitions with controller tuple syntax
Example prompts for the agent
- Refactor PostsController.php using Spatie coding conventions
- Create an Order model and migration with typed properties
- Review routes in routes/web.php to match Laravel standards
How to install spatie-laravel-php
1Skills CLI (Vercel)
npx skills add spatie/guidelines-skills --skill spatie-laravel-php -a claude-code2Manually: put the files in place
~/.claude/skills/spatie-laravel-php/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/spatie-laravel-php/
1Skills CLI (Vercel)
npx skills add spatie/guidelines-skills --skill spatie-laravel-php -a codex2Manually: put the files in place
.agents/skills/spatie-laravel-php/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add spatie/guidelines-skills --skill spatie-laravel-php -a cursor2Manually: put the files in place
.cursor/skills/spatie-laravel-php/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install spatie/guidelines-skills spatie-laravel-php2Manually: put the files in place
.github/skills/spatie-laravel-php/SKILL.md1Skills CLI (Vercel)
npx skills add spatie/guidelines-skills --skill spatie-laravel-php -a gemini-cli2Platform CLI
gemini skills install https://github.com/spatie/guidelines-skills --path resources/boost/skills/spatie-laravel-phpManually: put the files in place
.devin/skills/spatie-laravel-php/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add spatie/guidelines-skills --skill spatie-laravel-php -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about spatie-laravel-php
How to install spatie-laravel-php in Claude Code?
Run npx skills add spatie/guidelines-skills --skill spatie-laravel-php -a claude-code. You can also place the configuration file directly at ~/.claude/skills/spatie-laravel-php/SKILL.md.
What does spatie-laravel-php do?
It enforces Spatie style rules, PSR-12 guidelines, and Laravel conventions across PHP files, Blade views, migrations, and test suites.
What is out of scope for spatie-laravel-php?
The skill excludes JavaScript, TypeScript, CSS styling, database schema design, and non-Laravel PHP setups.
Source text
SKILL.md · MIT
---
name: spatie-laravel-php
description: Apply Spatie's Laravel and PHP coding standards for any task that creates, edits, reviews, refactors, or formats Laravel/PHP code or Blade templates; use for controllers, Eloquent models, routes, config, validation, migrations, tests, and related files to align with Laravel conventions and PSR-12.
license: MIT
metadata:
author: Spatie
---
# Spatie Laravel & PHP Guidelines
## Overview
Apply Spatie's Laravel and PHP guidelines to keep code style consistent and Laravel-native.
## When to Activate
- Activate this skill for any Laravel or PHP coding work, even if the user does not explicitly mention Spatie.
- Activate this skill when asked to generate, edit, format, refactor, review, or align Laravel/PHP code.
- Activate this skill when working on `.php` or `.blade.php` files, routes, controllers, models, config, validation, migrations, or tests.
## Scope
- In scope: `.php`, `.blade.php`, Laravel conventions (routes, controllers, config, validation, migrations, tests).
- Out of scope: JS/TS, CSS, infrastructure, database schema design, non-Laravel frameworks.
## Workflow
1. Identify the artifact (controller, route, config, model, Blade, test, etc.).
2. Read `references/spatie-laravel-php-guidelines.md` and focus on the relevant sections.
3. Apply the core Laravel principle first, then PHP standards, then section-specific rules.
4. If a rule conflicts with existing project conventions, follow Laravel conventions and keep changes consistent.
## Core Rules (Summary)
- Follow Laravel conventions first.
- Follow PSR-1, PSR-2, and PSR-12.
- Prefer typed properties and explicit return types (including `void`).
- Use short nullable syntax like `?string`.
- Use constructor property promotion when all properties can be promoted.
- One trait per line with separate `use` statements.
- Once a method chain breaks across lines, put every subsequent `->` on a new line; never mix single-line and multi-line chaining.
- Prefer early returns and avoid `else` when possible.
- Always use curly braces for control structures.
- Use string interpolation over concatenation.
- Happy path last: handle error conditions first.
## Do and Don't
Do:
- Use kebab-case URLs, camelCase route names, and camelCase route parameters.
- Use tuple notation for routes: `[Controller::class, 'method']`.
- Use plural resource names for controllers (`PostsController`).
- Use array notation for validation rules.
- Use `config()` helper and avoid `env()` outside config files.
- Add service configs to `config/services.php`, not new files.
- Use `__()` for translations instead of `@lang`.
- Use PascalCase for enum values and class constants.
Don't:
- Add docblocks when full type hints already exist.
- Use fully qualified classnames in docblocks.
- Use `final` or `readonly` by default.
- Use `else` when early returns work.
- Add spaces after Blade control structures.
## Examples
```php
// Happy path last with early returns
if (! $user) {
return null;
}
if (! $user->isActive()) {
return null;
}
// Process active user...
// Short ternary
$name = $isFoo ? 'foo' : 'bar';
// Constructor property promotion
class MyClass {
public function __construct(
protected string $firstArgument,
protected string $secondArgument,
) {}
}
```
```blade
@if($condition)
Something
@endif
```
## References
- `references/spatie-laravel-php-guidelines.md`
© Spatie · MIT · spatie/guidelines-skills