Home › Laravel › Laravel Livewire AGENTS.md
Laravel Livewire AGENTS.md
AGENTS.md for Livewire 3+ components in Laravel: properties, validation attributes, computed data, and Alpine.
AGENTS.mdLaravel
How to use
Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.
Note: Review and test before use. Provided as is, without warranty. See Terms.
AGENTS.mdDownload # AGENTS.md: Livewire components
## Commands
`php artisan make:livewire Orders/Index` · `php artisan test` · `./vendor/bin/pint`
- Check `composer.json` for the Livewire major version and follow its docs (v3 vs v4 differ in file layout).
## Component rules
- Public properties are sent to the browser and can be changed by the user. Never store secrets or trust them: lock ids with `#[Locked]`, and re-authorize in every action (`$this->authorize('update', $this->order)`).
- Validate with `#[Validate('required|email')]` on properties or a Form object (`Livewire\Form`), and call `$this->validate()` in actions.
- Derived data via `#[Computed]` methods (cached per request) instead of storing large collections in public properties.
- Pass models as properties (they're dehydrated to ids) instead of arrays of data.
- Inputs: `wire:model` (deferred) by default; `.live` with `.debounce.300ms` only for search-as-you-type.
- Loops use `wire:key` with a stable id on each item.
- Loading states with `wire:loading` and `wire:target`; disable buttons during submits.
- Small client interactions with Alpine (`x-data`, `$wire`) instead of extra round trips.
- Pagination with `WithPagination`; reset the page when filters change.
- Events between components with `$this->dispatch('order-saved')` and `#[On('order-saved')]`.
## Tests
`Livewire::test(Index::class)->set('search', 'x')->assertSee(...)`, plus authorization tests for every action.