본문으로 건너뛰기
cccskills
무료GitHub에 공개

laravel

Laravel 13 best practices: architecture, Eloquent, security, queues, testing, tooling. PHP 8.3+. Use when writing or reviewing Laravel applications.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md5.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Laravel

Architecture

  • Thin controllers: validate input, call service or action, return response. No business logic in controllers
  • Form Requests for validation and authorisation. Never validate in controller body
  • Service classes or Actions for domain logic. One responsibility each
  • Repositories only when swapping data sources is a real requirement
  • No logic in routes or middleware beyond stated purpose
  • Strict mode in AppServiceProvider: Model::shouldBeStrict() in non-production, Model::preventLazyLoading() in all envs

PHP Attributes (Laravel 13+)

  • PHP Attributes are optional but preferred for co-locating config with classes
  • Models: #[Fillable], #[Guarded], #[Hidden] replace $fillable, $guarded, $hidden properties
  • Controllers: #[Middleware], #[Authorize] replace $this->middleware() in constructor
  • Jobs: #[Tries], #[Backoff], #[Timeout], #[FailOnTimeout] replace class properties
  • Adopt Attributes on new code. No need to migrate existing property-based code — not deprecated

Eloquent

  • Eager-load all relationships with with(). Enable Model::preventLazyLoading() to catch N+1 in dev
  • Scope complex query logic into named scopes on the model
  • firstOrFail() / findOrFail() — never manually null-check query results
  • Mass assignment: #[Fillable] or explicit $fillable. Never $guarded = [] in production
  • Observers and model events for cross-cutting concerns only. No core logic inside them
  • DB::transaction(fn() => ...) for all multi-step writes
  • UUID or ULID primary keys for distributed systems: HasUuids / HasUlids traits
  • Always add indexes for foreign keys, frequently filtered columns, and unique constraints in migrations

Security

  • Sanctum for SPA/mobile API auth. Passport for OAuth server. Never hand-rolled token auth
  • Passkey auth available via Laravel 13 first-party support — prefer for new user-facing apps
  • Authorise with Policies or Gates. Never inline ownership checks
  • CSRF on by default — never disable
  • Validate all input with Form Requests. Use sometimes and nullable intentionally
  • Secrets in secret manager (AWS Secrets Manager, Vault). Never in .env committed to repo
  • Encrypt sensitive data at rest via Crypt facade
  • Rate-limit sensitive routes (login, register, password reset) with throttle middleware
  • Never DB::statement() with user input. Use query builder or Eloquent
  • Sanctum tokens: set expiry. Revoke on logout. Store hashed in DB (default behaviour — don't bypass)

Queues and jobs

  • All slow work (email, notifications, external API calls) in queued jobs
  • Jobs idempotent — they will be retried
  • Use #[Tries], #[Backoff], #[Timeout] attributes (L13+) or equivalent properties on every job
  • failed() method on every job for cleanup and alerting
  • Pass model IDs to jobs, not model instances — model may be deleted before job runs
  • Separate queues by priority and type: high, default, low, emails. Never one default queue for everything
  • Horizon for queue monitoring. Set balance, maxProcesses, and timeout per queue in horizon.php
  • Protect Horizon dashboard with HorizonServiceProvider gate — never expose in production without auth

API

  • Versioned routes: api/v1/, api/v2/. Never break existing API consumers
  • API Resources (JsonResource) for all responses. Never return raw Eloquent models
  • Consistent error response structure. Use exception handler to normalise 4xx/5xx shapes
  • Cache::touch() (L13+) to extend TTL on accessed entries without re-fetching
  • Throttle all API routes. Fine-grained limits per route, not just a global middleware

Testing

  • Pest preferred for new projects. PHPUnit supported — pick one per project, don't mix
  • Feature tests for HTTP endpoints with RefreshDatabase
  • Unit tests for service/action classes
  • Factories for all test data. Never raw DB::insert in tests
  • Http::fake(), Mail::fake(), Queue::fake(), Event::fake(), Storage::fake() — no real services in tests
  • Assert on HTTP status, JSON structure, and DB state
  • Pest::arch() for architecture tests: enforce namespace rules, no business logic in controllers
  • @pest datasets for parameterised cases

Performance

  • chunk() or cursor() for large dataset processing. Never ->get() on unbounded queries
  • Tagged cache for fine-grained invalidation. Invalidate on write
  • Cache::touch() (L13+) for sliding TTL on hot cache entries
  • php artisan optimize in production: caches config, routes, views, events
  • Octane (Swoole or RoadRunner) for high-throughput APIs. Requires stateless code — no static state between requests
  • OPcache enabled and warmed in production

Monitoring and tooling

  • Telescope in local/staging only. Never in production without access control and storage limits
  • Pulse for production monitoring: request throughput, queue depth, cache hits, slow queries, exceptions
  • Reverb for WebSockets (L13+). Database driver available — no Redis required for smaller workloads
  • Laravel AI SDK (stable in L13) for LLM integration. Provider-agnostic: OpenAI, Anthropic, etc.
  • Pennant for feature flags. Gate new features behind Feature::active('feature-name')
  • Nightwatch for production error tracking and alerting (first-party)

Code quality

  • Pint for code formatting (./vendor/bin/pint). Enforce in CI — no style debates
  • Larastan (PHPStan for Laravel) at level 6+ minimum. Raise level over time
  • php artisan about + php artisan model:show for runtime introspection in debugging
  • php artisan db:monitor and slow query logging in production

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

aws

무료

AWS best practices: IAM, secrets, networking, security, compute, IaC, ops. Use when building, reviewing, or modifying AWS resources.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

docker

무료

Docker best practices: image security, build efficiency, runtime hardening, Compose, local tooling (Colima, OrbStack). Use when writing or reviewing Dockerfiles and Compose files.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

gcp

무료

GCP best practices: IAM, secrets, networking, security, compute, IaC, ops. Use when building, reviewing, or modifying GCP resources.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

go

무료

Idiomatic Go 1.25 practices: errors, interfaces, concurrency, generics, testing, security, tooling. Use when writing or reviewing Go code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

java

무료

Modern Java practices: design, errors, concurrency, security, testing, tooling. Targets Java 21 LTS baseline; Java 25 LTS features called out explicitly. Use when writing or reviewing Java code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

SumonMSelim의 스킬 모두 보기

이 스킬의 문제 신고