laravel-best-practices — скилл для Claude Code: обзор и установка
Индексирует правила Laravel для написания контроллеров, моделей, миграций и очередей. Помогает соблюдать принятые в проекте шаблоны и избегать проблем с N+1.
npx skills add laravel/boost --skill laravel-best-practices -a claude-codeЧто делает laravel-best-practices
Скилл задаёт строгий процесс внесения изменений в код на Laravel. Сначала ассистент изучает соседние контроллеры, модели или тесты, чтобы повторить уже принятый в проекте подход. Правило консистентности здесь главное: если в кодовой базе уже есть рабочий шаблон, скилл требует следовать ему, а не внедрять второй способ решения той же задачи.
Внутри собраны ссылки на файлы правил под каждую задачу: от оптимизации запросов в rules/db-performance.md и валидации в rules/validation.md до очередей и архитектуры сервисов. Если нужно проверить синтаксис конкретной версии фреймворка, скилл обращается к команде search-docs или исходникам установленного пакета.
Для тестирования скилл перенаправляет на отдельный testing-best-practices. Запрет на доступ к базе из Blade-шаблонов защитит от скрытых N+1 запросов ещё на этапе написания кода.
Какие задачи решает
- найти скрытые N+1 запросы в контроллерах и ресурсах
- проверить соответствие Eloquent-моделей и миграций соглашениям Laravel
- настроить обработку очередей и повторные попытки для jobs
- провести ревью серверного PHP-кода перед слиянием ветки
Примеры запросов агенту
- Проверь контроллер OrderController на N+1 запросы и вынеси логику по правилам laravel-best-practices
- Создай миграцию и модель для подписок, сверяясь с правилами laravel-best-practices
- Сделай рефакторинг обработчика очередей ProcessPayment с учётом повторных попыток
Как установить laravel-best-practices
1Через Skills CLI (Vercel)
npx skills add laravel/boost --skill laravel-best-practices -a claude-code2Вручную: положить файлы
~/.claude/skills/laravel-best-practices/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/laravel-best-practices/
1Через Skills CLI (Vercel)
npx skills add laravel/boost --skill laravel-best-practices -a codex2Вручную: положить файлы
.agents/skills/laravel-best-practices/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add laravel/boost --skill laravel-best-practices -a cursor2Вручную: положить файлы
.cursor/skills/laravel-best-practices/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install laravel/boost laravel-best-practices2Вручную: положить файлы
.github/skills/laravel-best-practices/SKILL.md1Через Skills CLI (Vercel)
npx skills add laravel/boost --skill laravel-best-practices -a gemini-cli2Командой платформы
gemini skills install https://github.com/laravel/boost --path .ai/laravel/skill/laravel-best-practicesВручную: положить файлы
.devin/skills/laravel-best-practices/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add laravel/boost --skill laravel-best-practices -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Похожие
Вопросы о laravel-best-practices
Как установить laravel-best-practices в Claude Code?
Выполните команду npx skills add laravel/boost --skill laravel-best-practices -a claude-code. Также файл правил можно положить напрямую по пути ~/.claude/skills/laravel-best-practices/SKILL.md.
Что делает скилл laravel-best-practices?
Он направляет ИИ-агента по правилам разработки под Laravel, заставляя сначала проверить существующий стиль проекта. Индекс правил охватывает Eloquent, безопасность, валидацию, миграции, маршруты и очереди.
Что имеет приоритет: правила скилла или существующий код проекта?
Проектный код всегда важнее. Скилл запрещает внедрять альтернативный подход, если в репозитории уже сложился собственный шаблон реализации, кроме случаев явных ошибок безопасности.
Исходный текст
SKILL.md · MIT
--- name: laravel-best-practices description: "Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns." license: MIT metadata: author: laravel --- # Laravel best practices Best practices for Laravel, organized as an index of rule files. Each rule file teaches what to do and why. For exact API syntax, verify with `search-docs`. ## Consistency first Before applying any rule, check what the application already does. Laravel offers several valid approaches. The best choice is the one the codebase already uses, even if another pattern would be better in theory. Inconsistency is worse than a suboptimal pattern. Check sibling files and related controllers, models, or tests for established patterns. If one exists, follow it. Don't introduce a second way. These rules are defaults for when no pattern exists yet, not overrides. ## How to apply 1. Check the changed files, nearby code, project configuration, and relevant tests for established patterns. Deviate only for a correctness or security defect, and call the deviation out. 2. Map every affected concern to the rule index below. Read each mapped rule file before editing. Skip unrelated rule files. 3. Make the smallest coherent change. Keep the application's architecture and naming instead of introducing a second pattern for the same job. 4. Verify version-sensitive Laravel APIs for the installed version with `search-docs`, or inspect the installed framework when `search-docs` is unavailable. 5. Run the narrowest relevant tests first, then the project's formatting and static-analysis checks when the change warrants them. 6. Re-read the diff against every mapped rule before finishing. ## Rule index Cross-cutting changes often need more than one rule file. | Concern | Read | | --- | --- | | Query count, eager loading, indexes, large datasets | [`rules/db-performance.md`](rules/db-performance.md) | | Subqueries, aggregates, complex ordering and query plans | [`rules/advanced-queries.md`](rules/advanced-queries.md) | | Models, relationships, scopes, casts | [`rules/eloquent.md`](rules/eloquent.md) | | Authentication, authorization, input safety, secrets, uploads | [`rules/security.md`](rules/security.md) | | Form Requests and validation rules | [`rules/validation.md`](rules/validation.md) | | Controllers, route binding, resources, middleware | [`rules/routing.md`](rules/routing.md) | | Schema changes, columns, foreign keys, indexes | [`rules/migrations.md`](rules/migrations.md) | | Jobs, retries, uniqueness, batches, Horizon | [`rules/queue-jobs.md`](rules/queue-jobs.md) | | Cache lifetime, invalidation, locks, memoization | [`rules/caching.md`](rules/caching.md) | | Outbound requests, retries, timeouts, fakes | [`rules/http-client.md`](rules/http-client.md) | | Exceptions, reporting, rendering, log context | [`rules/error-handling.md`](rules/error-handling.md) | | Events and notifications | [`rules/events-notifications.md`](rules/events-notifications.md) | | Mailables and mail assertions | [`rules/mail.md`](rules/mail.md) | | Scheduled tasks and overlap protection | [`rules/scheduling.md`](rules/scheduling.md) | | Collections, lazy iteration, bulk operations | [`rules/collections.md`](rules/collections.md) | | Blade components, attributes, composers | [`rules/blade-views.md`](rules/blade-views.md) | | Environment values and application configuration | [`rules/config.md`](rules/config.md) | | Tests: coverage, factories, fakes, and assertions | the `testing-best-practices` skill | | Naming, helpers, file boundaries, PHP style | [`rules/style.md`](rules/style.md) | | Actions, services, dependencies, application structure | [`rules/architecture.md`](rules/architecture.md) | ## Decision rules - Prefer framework features and existing application abstractions over new helpers or dependencies. - Avoid speculative abstractions. Extract code when it creates a clear domain boundary, removes meaningful duplication, or makes behavior independently testable. - Keep database access out of Blade views and prevent hidden N+1 queries across controllers, resources, jobs, and serialization.
© laravel · MIT · laravel/boost