laravel-idioms
Skill157 starsChanged 4 months agoMITView on GitHub
Laravel framework patterns: Eloquent ORM relationships, N+1 query prevention, Form Request validation, Service layer architecture, and Pest/PHPUnit testing. Use when building or reviewing Laravel web apps and APIs. Pair with php-idioms.
In this repository59 other files it gives its agents.
- github-pages/agents.mdAGENTS.md
- adrSkill
- agent-protocolsSkill
- angular-idiomsSkill
- api-documentationSkill
- axum-idiomsSkill
- browser-automationSkill
- chaos-testingSkill
- ci-cdSkill
- cli-developmentSkill
- code-auditSkill
- code-reviewSkill
- cpp-idiomsSkill
- csharp-idiomsSkill
- data-engineeringSkill
- debugging-protocolSkill
- django-idiomsSkill
- dotnet-idiomsSkill
- elixir-idiomsSkill
- embedded-systemsSkill
- feature-flagsSkill
- flutter-idiomsSkill
- frontend-designSkill
- git-commit-integritySkill
- go-idiomsSkill
- guardrailsSkill
- hono-idiomsSkill
- incident-responseSkill
- java-idiomsSkill
- javascript-idiomsSkill
- kotlin-idiomsSkill
- logging-implementationSkill
- ml-engineeringSkill
- mobile-designSkill
- mobile-testingSkill
- nextjs-idiomsSkill
- parallel-dispatchSkill
- payment-integrationSkill
- perf-optimizationSkill
- php-idiomsSkill
- postgres-idiomsSkill
- python-idiomsSkill
- rails-idiomsSkill
- react-idiomsSkill
- refactoring-patternsSkill
- research-methodologySkill
- ruby-idiomsSkill
- rust-idiomsSkill
- security-auditSkill
- sequential-thinkingSkill
- spring-boot-idiomsSkill
- sql-idiomsSkill
- structured-specSkill
- supply-chain-securitySkill
- swift-idiomsSkill
- testability-patternsSkill
- testing-strategySkill
- typescript-idiomsSkill
- vue-idiomsSkill
The file
Files
Laravel Idioms and Patterns
Laravel rewards convention, Eloquent, and expressive syntax. Idiomatic Laravel = DRY, service-oriented, well-tested.
Scope: Laravel-specific patterns. For PHP:
@.agents/skills/php-idioms/SKILL.md.
Eloquent
- Scopes for reusable queries:
class Task extends Model { public function scopeActive(Builder $query): Builder { return $query->where('status', 'active'); } } // Usage: Task::active()->paginate(25); - Eager loading to avoid N+1:
Task::with('user', 'tags')->get(). - Accessors/Mutators with
Attributecast (Laravel 9+).
Service Layer
- Services for business logic — controllers stay thin:
class TaskService { public function __construct( private readonly TaskRepository $repository, ) {} public function create(CreateTaskRequest $request): Task { ... } }
Validation
- Form Requests for validation — never validate in controllers:
class CreateTaskRequest extends FormRequest { public function rules(): array { return [ 'title' => ['required', 'string', 'max:200'], 'priority' => ['required', Rule::enum(Priority::class)], ]; } }
Testing
For universal testing principles, see
.agents/rules/testing-strategy.md. Below: language-specific patterns only.
- Pest (preferred) or PHPUnit:
test('creating a task returns 201', function () { $response = $this->postJson('/api/tasks', ['title' => 'Test', 'priority' => 'high']); $response->assertCreated(); $this->assertDatabaseHas('tasks', ['title' => 'Test']); }); - Factories for test data. RefreshDatabase trait for isolation.
Formatting and Static Analysis
| Tool | Purpose | Command |
| Laravel Pint | Formatting | ./vendor/bin/pint |
| PHPStan + Larastan | Static analysis | phpstan analyse |
composer audit | CVE scanning | composer audit |
Related
- PHP Idioms @.agents/skills/php-idioms/SKILL.md
- Database Design Principles @.agents/rules/database-design-principles.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

