laravel-idioms

SkillAI & models

Laravel rewards convention, Eloquent, and expressive syntax. Idiomatic Laravel = DRY, service-oriented, well-tested.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the laravel-idioms skill

About this capability

Comprehensive sets of standards and practices designed to elevate the capabilities of AI coding agents.

What this skill tells your AI

The instructions your AI receives, as published by irahardianto/awesome-agv in .agents/skills/laravel-idioms/SKILL.md and read by ahel’s review.

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

  1. Scopes for reusable queries:

    class Task extends Model {
        public function scopeActive(Builder $query): Builder {
            return $query->where('status', 'active');
        }
    }
    // Usage: Task::active()->paginate(25);
    
  2. Eager loading to avoid N+1: Task::with('user', 'tags')->get().

  3. Accessors/Mutators with Attribute cast (Laravel 9+).

Service Layer

  1. Services for business logic — controllers stay thin:
    class TaskService {
        public function __construct(
            private readonly TaskRepository $repository,
        ) {}
    
        public function create(CreateTaskRequest $request): Task { ... }
    }
    

Validation

  1. 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.

  1. 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']);
    });
    
  2. Factories for test data. RefreshDatabase trait for isolation.

Formatting and Static Analysis

ToolPurposeCommand
Laravel PintFormatting./vendor/bin/pint
PHPStan + LarastanStatic analysisphpstan analyse
composer auditCVE scanningcomposer audit

Related

  • PHP Idioms @.agents/skills/php-idioms/SKILL.md
  • Database Design Principles @.agents/rules/database-design-principles.md

Signals

GitHub stars
156
Forks
53
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
laravel-idioms
Source
github.com/irahardianto/awesome-agv