スキル一覧に戻る
masterfermin02

laravel-best-practices

by masterfermin02

This package publishes an agent skill folder into multiple locations to support various AI agents and editors.

1🍴 0📅 2026年1月22日
GitHubで見るManusで実行

SKILL.md


name: laravel-best-practices description: Enforce Laravel Best Practices when generating code, reviewing code, and writing tests (SRP, skinny controllers, FormRequests, service/action classes, DRY, Eloquent/Collections, Blade query avoidance, eager loading, chunking). metadata: installed_path: .codex/skills/laravel-best-practices outputs: - review (findings + patch outline) - generate (file plan + code) - tests (test matrix + starter tests)

Purpose

This skill guides an AI coding agent to:

  1. generate Laravel code aligned with established best practices,
  2. review Laravel code (or diffs) and propose refactors aligned to those practices,
  3. propose and scaffold tests (Pest preferred; PHPUnit supported).

Use when

  • Implementing or refactoring controllers, FormRequests, service/action classes, jobs, events/listeners, policies, observers
  • Reviewing PRs, diffs, or entire files in a Laravel application
  • Designing maintainable application layering and test strategy

Rulebook

Use references/rulebook.json as the source of truth for:

  • rule ids
  • detection signals
  • recommended refactor patterns
  • expected outputs

When you flag an issue, always include:

  • rule_id
  • evidence (file + line numbers or excerpt)
  • minimal refactor steps first
  • test impact plan

Core principles (high-level)

  • Single Responsibility: one reason to change per class; one main concern per method.
  • Thin controllers: controllers orchestrate; business logic lives elsewhere.
  • Validation in FormRequests: move validation and authorization there.
  • Business logic in services/actions: extract workflows into testable units.
  • DRY: centralize repeated logic (Eloquent scopes, value objects/DTOs, helpers).
  • Prefer Eloquent + Collections: use expressive domain modeling where practical.
  • No queries in Blade: views must not query the database; eager load to avoid N+1.
  • Chunk/stream large datasets: avoid loading large tables into memory.

Workflow: Review

When asked to review code:

  1. Identify the layer (Controller, Request, Model, Service/Action, Blade, etc.).
  2. Apply rules from rulebook.json; emit findings with rule ids.
  3. Provide a patch outline (what files to create/change) and a test plan.

Return a JSON object:

  • summary: score, counts
  • findings[]: rule_id, severity, evidence, rationale, recommendations, patch outline
  • tests: a short matrix or list of impacted tests

Workflow: Generate code

When asked to implement a feature:

  1. Propose file layout first (Controller + FormRequest + Service/Action + Model scopes, etc.).
  2. Generate code using Laravel idioms: dependency injection, FormRequests, policies, resources.
  3. Include a minimal test plan (Feature + Unit tests).

Workflow: Generate tests

Prefer Pest if repository uses Pest (presence of pestphp/pest in composer.json); otherwise PHPUnit.

  • FormRequest validation/authorization
  • Service/action business rules (unit)
  • Feature tests for endpoints (happy path + validation + authz)
  • Mock external systems (HTTP, queues, notifications) as needed

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です