Laravel

From event4u-app/agent-config · View interactive version

Laravel is an AI agent skill from the GitHub repository event4u-app/agent-config. Writes Laravel PHP — Eloquent, Artisan controllers, FormRequests, jobs, events, policies, providers. For Symfony / Doctrine use `symfony-workflow`. For framework-free PHP use `php-coder`.

How to use this skill

Skill file

laravel

When to use

Use this skill for all Laravel-specific code generation and editing tasks, especially when working with:

This skill extends the base php-coder skill and applies Laravel conventions on top of the project's general PHP rules.

When NOT to use — components without the framework

A DEPENDENCY PROVES A LIBRARY IS AVAILABLE. ONLY THE ENTRY POINT AND THE
ROUTER PROVE WHICH APPLICATION SHAPE IS RUNNING.
`illuminate/*` PACKAGES WITH NO SKELETON MARKER IS A THIRD STATE, AND THIS SKILL
DOES NOT APPLY TO IT.

Laravel ships its ORM, container, collections and HTTP layer as

independently installable packages, usable with no framework present — a

published distribution model, not one consumer's arrangement. An application

built that way has a custom entry point and a custom router. Routing it here

offers a CLI that does not exist, a request-validation primitive that is not

wired, and a routes file that was never there: every suggestion confidently

wrong, and the reason visible only from the entry point.

The probe set, and its cost. A fixed set of filesystem existence checks plus

one manifest read — no directory walk, no content scan, and never re-derived per

session. Any ONE marker present means the framework is real:

| Probe | Meaning |

|---|---|

| artisan | the console entry point the skeleton writes |

| config/app.php | the skeleton's bootstrap config |

| bootstrap/app.php | the application bootstrap |

illuminate/* in composer.json with none of those markers is

components-without-the-framework. Say so and route away from this skill rather

than answering as though the framework were there.

Implemented deterministically in src/install/detect_php_shape.ts

(detectPhpShape), whose PROBE_PATHS is this table and whose verdict names

what a wrong route would have offered.

Procedure: Write Laravel code

→ First apply the php-coder skill — it handles project docs, module docs, patterns, and quality tools.

Then add these Laravel-specific checks:

  1. Confirm this is a Laravel app — check whether artisan exists.
  2. Inspect app structure — classic Laravel, modules (app/Modules/), or domain folders.
  3. Check routes and HTTP flow — understand how requests enter the application and where logic belongs.
  4. Check test conventions — inspect existing tests in the same domain before writing new code.

Core Laravel principles

HTTP layer rules

Validation rules

Service layer rules

Routing rules

Response rules

Queues, jobs, and async work

Events and listeners

Auth, policies, and authorization

Config and environment

Database interaction

Migrations and schema changes

Blade and view rules

Translations and language files

Nested arrays ('type' => ['daily_report' => …]) are forbidden: they break

key referencing and make a one-line addition a nested diff.

__('report.type.daily_report'), __('email.report.created.subject', ['number' => $number]).

lang/de/ is a bug, not a TODO — the app ships to both audiences.

What NOT to do

Output expectations

When generating Laravel code:

Output format

  1. Laravel code following framework conventions and project architecture
  2. All related files (controller, service, request, resource, test) as needed

Do NOT

Known pitfalls

| Symptom | Root cause | Fix |

|---|---|---|

| A list endpoint fires hundreds of queries / is slow under load | N+1: a relation is accessed inside a loop without eager loading | Eager-load with with('relation'); enable Model::preventLazyLoading() in non-prod to catch it early |

| Config changes / new env vars have no effect in production | config:cache cached the old config, and env() returns null once config is cached | Read env only in config/*, use config() elsewhere; re-run config:cache on deploy |

| A form field silently isn't saved | The attribute isn't in $fillable and mass-assignment drops it | Add it to $fillable (or set it explicitly); never blanket-$guarded = [] on user input |

| Queued jobs never run / run with stale code | No worker is running, or workers weren't restarted after a deploy so they hold the old code in memory | Run/supervise queue:work; queue:restart on every deploy |

| Timestamps or times are off by hours | Comparing/formatting a Carbon instance without honoring config('app.timezone') vs the DB's UTC storage | Store UTC; convert for display; set the app timezone explicitly, don't assume server local time |

Gotcha

Auto-trigger keywords

Security audit checks (from security-audit)

Laravel-specific audit list (carved out of the generic security-audit

skill, 2026-07-12):

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.