livewire-component-design
Skill1 starsChanged 6 months agoMITView on GitHub
Design Livewire components with clear boundaries - state ownership, props vs events, performance (network round-trips, lazy, computed), forms, and Alpine handoff. Use when creating or reviewing Livewire components, deciding how to split a page into components, debugging re-render or state-sync issues, or when a Livewire page feels slow.
In this repository50 other files it gives its agents.
- accessibility-reviewSkill
- adr-authorSkill
- api-designSkill
- architecture-reviewSkill
- caching-strategySkill
- changelogSkill
- ci-cd-pipelineSkill
- codebase-explorationSkill
- code-reviewSkill
- code-style-guideSkill
- context-engineeringSkill
- conventional-commitsSkill
- cost-optimizationSkill
- database-migrationSkill
- data-privacy-reviewSkill
- debuggingSkill
- dependency-updateSkill
- deprecation-migrationSkill
- error-handlingSkill
- feature-flag-rolloutSkill
- filament-resource-designSkill
- flux-ui-patternsSkill
- git-workflowSkill
- i18n-reviewSkill
- idea-refineSkill
- incident-responseSkill
- incremental-implementationSkill
- inertia-patternsSkill
- laravel-ai-featuresSkill
- laravel-eloquent-performanceSkill
- laravel-queue-designSkill
- laravel-testingSkill
- llm-feature-designSkill
- observabilitySkill
- onboarding-docSkill
- performance-budgetSkill
- pr-descriptionSkill
- primevue-patternsSkill
- refactoringSkill
- release-checklistSkill
- resilience-patternsSkill
- runbook-authorSkill
- security-auditSkill
- spec-writingSkill
- task-breakdownSkill
- tech-debt-triageSkill
- test-writingSkill
- threat-modelingSkill
- using-elyra-skillsSkill
- vue-component-patternsSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Every Livewire interaction is a network round-trip carrying component state.
- Distinctive: line 36
Don't split static markup into components — Blade partials/components are free, Livewire components are not
- Distinctive: line 51
Never put secrets or other users' data in public properties — view-source shows them
- Distinctive: line 68
Always re-validate and re-authorize in the action method — client state is untrusted input
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Livewire Component Design
Every Livewire interaction is a network round-trip carrying component state. Good component design minimizes what crosses the wire and who owns what.
When to use
- Creating or splitting Livewire components ("one big component or three small?")
- State desync, unexpected re-renders, or lost input
- A Livewire page feels sluggish (too many/too heavy requests)
- Deciding Livewire vs Alpine for an interaction
Principles
- Components own state; children receive data and emit events. Two components owning the same state will disagree.
- Alpine for the browser, Livewire for the server. Toggles, tabs, dropdowns = Alpine (zero round-trips). Anything touching data/authorization = Livewire.
- Public properties are the payload — and the attack surface. Everything public crosses the wire every request and can be tampered with client-side. Keep it minimal, validate/authorize server-side always.
- A component is a unit of update, not a unit of markup. Split where update frequency differs, not where the design grid does.
Process
1. Decide what's a component
- Split when a region updates independently (search results vs filters vs cart badge)
- Don't split static markup into components — Blade partials/components are free, Livewire components are not
- Page-level component + small interactive islands beats a deep nesting tree
2. Assign state ownership
- The owner mutates; everyone else reads
- Parent → child: pass data as props (child re-renders when parent re-renders)
- Child → parent: dispatch events (
$this->dispatch('order-updated')), parent listens with#[On('order-updated')] - Cross-component shared state (cart count in navbar): events, or re-fetch in the listener — don't mirror writable copies
3. Keep the payload lean
- Public properties: scalars, arrays, IDs. Prefer passing IDs +
#[Computed]lookups over fat serialized models #[Computed]for derived data — cached per request, doesn't ride the payload#[Locked]on IDs and anything the client must not change (public #[Locked] int $orderId)- Never put secrets or other users' data in public properties — view-source shows them
4. Control the round-trips
| Pattern | Use |
wire:model.live.debounce.300ms | Search-as-you-type (default wire:model is deferred — already cheap) |
wire:model.blur | Validate a field on blur |
Alpine (x-show, x-data) | Pure UI state — no server trip at all |
#[Lazy] component | Below-the-fold or expensive components; loads after page paint |
Polling wire:poll.10s | Sparingly; prefer events/broadcasts for real-time |
wire:loading / optimistic UI | Mask unavoidable latency |
5. Forms
- Form objects (
UserFormextendsForm) once a form exceeds a few fields — validation rules, state, andsave()live together - Real-time validation:
wire:model.blur+$this->validateOnly($field) - Always re-validate and re-authorize in the action method — client state is untrusted input
6. Test it
Livewire::test(OrderTable::class)
->set('search', 'foo')
->assertSee('foo-order')
->call('delete', $order->id)
->assertForbidden(); // authorization is testable — test itCover: initial render, each action, validation errors, authorization, emitted events (assertDispatched).
Output format
## Livewire design: <page/feature>
### Components
| Component | Owns | Receives | Emits | Lazy? |
|-----------|------|----------|-------|-------|
| … | … | … | … | … |
### Wire-vs-Alpine
Alpine handles: … (zero round-trips). Livewire handles: …
### Payload review
Public props: … — locked: …, computed instead of serialized: …
### Round-trip budget
Interaction X: N requests → target M.Anti-patterns
- ❌ One God-component owning the whole page — every keystroke re-renders everything
- ❌ Two components with writable copies of the same state, synced by hope
- ❌
wire:model.liveon every input out of habit (request per keystroke) - ❌ Fat models in public properties when the view needs three fields
- ❌ Trusting a public property because "the UI doesn't let you change it" —
#[Locked]or re-check - ❌ Livewire round-trip for a dropdown toggle Alpine does for free
- ❌ Skipping authorization in actions because the button was hidden
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.

