laravel/boost

laravel-best-practices

Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/laravel/boost --skill laravel-best-practices

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

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.

ConcernRead
Query count, eager loading, indexes, large datasets`rules/db-performance.md`
Subqueries, aggregates, complex ordering and query plans`rules/advanced-queries.md`
Models, relationships, scopes, casts`rules/eloquent.md`
Authentication, authorization, input safety, secrets, uploads`rules/security.md`
Form Requests and validation rules`rules/validation.md`
Controllers, route binding, resources, middleware`rules/routing.md`
Schema changes, columns, foreign keys, indexes`rules/migrations.md`
Jobs, retries, uniqueness, batches, Horizon`rules/queue-jobs.md`
Cache lifetime, invalidation, locks, memoization`rules/caching.md`
Outbound requests, retries, timeouts, fakes`rules/http-client.md`
Exceptions, reporting, rendering, log context`rules/error-handling.md`
Events and notifications`rules/events-notifications.md`
Mailables and mail assertions`rules/mail.md`
Scheduled tasks and overlap protection`rules/scheduling.md`
Collections, lazy iteration, bulk operations`rules/collections.md`
Blade components, attributes, composers`rules/blade-views.md`
Environment values and application configuration`rules/config.md`
Tests: coverage, factories, fakes, and assertionsthe testing-best-practices skill
Naming, helpers, file boundaries, PHP style`rules/style.md`
Actions, services, dependencies, application structure`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.