spatie/guidelines-skills
Spatie’s battle-tested coding guidelines packaged as AI skills for Laravel Boost and skills.sh. Includes skills for Laravel/PHP, JavaScript, version control, and security, helping teams apply consistent conventions and best practices.
Install via Laravel Boost (recommended for Laravel projects):
composer require spatie/guidelines-skills --dev
php artisan boost:install
php artisan boost:skills to confirm activation.Install via skills.sh (for non-Laravel or CLI-focused workflows):
npx skills add spatie/guidelines-skills
npx skills lint to validate setup.First Use Case: Enforce PHP/Laravel Standards
UserController@store).snake_case for DB columns).if (!empty($var)) over if ($var)).mysql_query())..boost/skills.json (for Laravel Boost) or skills.config.js (for skills.sh).
Example:
{
"skills": {
"spatie-laravel-php": {
"enabled": true,
"strict": true
},
"spatie-security": {
"enabled": true,
"rules": {
"no-mysql-query": "error"
}
}
}
}
php artisan boost:skills (list/manage skills).npx skills lint (run checks manually).spatie-laravel-php and spatie-version-control to standardize:
use statements, method naming).feat:, fix:).composer.json:
"require-dev": {
"spatie/guidelines-skills": "^1.0"
}
.boost/skills.json to enable spatie-version-control with strict: true.git commit with Conventional Commits.## Coding Guidelines
This project enforces [Spatie’s Laravel/PHP guidelines](https://spatie.be/guidelines).
Run `php artisan boost:skills` to see active rules.
spatie-security with Laravel’s built-in tools.
mysql_query(), exec(), or eval().config('services.stripe.key'))..boost/skills.json:
"spatie-security": {
"enabled": true,
"rules": {
"no-hardcoded-secrets": "error",
"use-csrf": "warning"
}
}
verify-csrf-token middleware for forms.php artisan boost:skills:test to validate security checks in CI.spatie-javascript.
camelCase for methods).package.json:
"devDependencies": {
"spatie/guidelines-skills": "^1.0"
}
skills.sh to auto-fix:
npx skills add spatie-javascript --fix
@typescript-eslint).name: Linting
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npx skills lint
spatie-version-control to block non-compliant commits:
- run: |
git diff --cached | npx skills check --skill spatie-version-control
[ $? -ne 0 ] && echo "::error::Commit message must follow conventions." && exit 1
php artisan boost:skills:test to validate all skills before merging..boost/skills.json:
"spatie-laravel-php": {
"rules": {
"naming": {
"methods": "snake_case" // Override default camelCase
}
}
}
skills.sh:
npx skills add spatie/guidelines-skills --all to enable all skills at once.npx skills lint --skill spatie-security to target specific checks.php-cs-fixer or PHPStan for deeper analysis.skills.sh to run ESLint first, then Spatie’s rules.spatie-version-control to reject commits with:
npx skills check --skill spatie-version-control
Overriding Rules Without Awareness
spatie-security rules (e.g., no-mysql-query) without compensating with Laravel’s security features (e.g., Query Builder).README.md:
## Security Overrides
Rule `no-mysql-query` is disabled for legacy `User` model. Use `DB::select()` instead.
Performance Impact in Large Codebases
npx skills lint on a monorepo with 10K+ files may be slow.--path to target specific directories:
npx skills lint --path app/Http/Controllers
Conflicts with Custom Conventions
PascalCase for controllers, but spatie-laravel-php enforces snake_case..boost/skills.json:
"spatie-laravel-php": {
"rules": {
"naming": {
"controllers": "PascalCase"
}
}
}
False Positives in Legacy Code
spatie-security flags mysql_query() in legacy code that’s already refactored..boost/ignore.json to exclude files:
{
"ignoredFiles": [
"app/OldLegacyClass.php"
]
}
Skills.sh vs. Laravel Boost Conflicts
skills.sh and Laravel Boost may lead to duplicate configurations.skills.sh for polyglot or CLI-heavy workflows.php artisan boost:skills # Laravel Boost
npx skills list # skills.sh
npx skills lint --skill spatie-security
php artisan boost:skills:show spatie-laravel-php.skills.sh: Check the Spatie Guidelines docs for rule explanations.How can I help you explore Laravel packages today?