Livewire architect

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

Livewire architect is an AI agent skill from the GitHub repository event4u-app/agent-config. Use when shaping a Livewire component before code — full-page vs partial, parent/child split, event flow, state-vs-props boundary, hydration cost — even on 'add this Livewire component'.

How to use this skill

Skill file

livewire-architect

Architectural lens above the existing tactical CODE0

skill. Decides component shape, lifecycle ownership, and the

full-page-vs-partial split before the first mount() is written.

The livewire skill handles Flux-component patterns and hydration

debugging once the shape is locked.

When to use

components is unclear (one big component vs nested children?).

concerns, large $listeners, props bag growing turn over turn.

ambiguous (who owns $user, who emits, who listens?).

Teilkomponente?", "wer feuert das Event?".

Do NOT use when:

(Flux variant, wire:model modifier, @entangle) — route to

CODE0.

to CODE0 or CODE1.

not redesign with this skill.

Procedure

1. Analyze the existing screen — before designing anything

Inspect the route and read the existing Blade / Livewire files to

understand what's already there. List every dynamic surface on the

page (form, table row, modal, nav badge). Mark each: **shared

state (other surfaces re-render on change), local state** (only

this surface cares), server state (must hit DB / queue). This

analysis feeds every later step — do NOT skip ahead before the

inventory is on paper.

2. Choose the component shape

Pick one before writing code:

| Shape | When | Cost |

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

| Full-page component | Route owns the whole screen, single backing model, ≤ 3 related actions | Cheapest; one mount, one render |

| Parent + nested children | Two or more independent state islands on one route | Two mounts; coordinate via events, not props churn |

| Partial component on Blade | Mostly static page, one reactive island | Cheap; component sees the world via props only |

| Stack of full-page components | Wizard / multi-step flow with own URL per step | Expensive; pick only when URL semantics matter |

Rule: if a child needs ≥ 4 props from the parent and emits ≥ 3

events back, the boundary is wrong — collapse or re-cut.

3. Lock the state-vs-props boundary

For each piece of data the component reads, mark public property

(reactive, persisted in payload, expensive to dehydrate) or

computed / method-local (cheap, recomputed on render). Public

properties are the budget — keep ≤ 8 per component; more means

the component is doing two jobs.

4. Map the event flow

Draw the events: dispatch('foo') → who listens? Cross-component

events use dispatch(); parent ↔ child stays on $parent.method()

when the child is owned. Avoid global events for parent-owned

children — they break the ownership story.

5. Lifecycle ownership

For each side-effect (DB write, queue dispatch, redirect, flash),

name the lifecycle hook: mount (one-time setup), boot (every

request, idempotent), action method (user-initiated), updated*

(reactive on property change). One hook per side-effect; if two

hooks fire the same write, the design is wrong.

6. Validate the design — before any code is written

Walk the design back through these checks; every "no" means

re-cut, not push forward:

If any check fails, return to the relevant step and re-cut. The

design must be approved by the user before handing off to

/livewire for implementation.

Output format

Return:

  1. Component shape decision — full-page / parent+children / partial /

stack — with the one-sentence trade-off rationale.

  1. Component inventory — for each: public props (≤ 8), state islands

owned, events listened/dispatched, side-effects on mount and action.

  1. Boundary-risk list and tactical follow-up — prop bags > 8, event

chains > 3 hops, shared mutable state, and the next handoff.

Concrete shape:

Screen:           <route or feature>
Component shape:  <full-page | parent+children | partial | stack>
Why:              <one sentence — the trade-off chosen>

Components:
  - <Name> (full-page | partial)
      Public props: [a, b, c]   (≤ 8)
      Owns:         <state islands>
      Listens to:   [event1, event2]
      Dispatches:   [event3]
      Side-effects: mount=<...>, action=<...>

Boundary risks:
  - <prop bag > 8 / event chain > 3 hops / shared mutable state>

Tactical follow-up:
  Hand off to /livewire for Flux variant + hydration check.

Gotcha

ships in the payload. Big arrays / DTOs as public state are a

performance bug waiting to fire under load.

ownership story per component tree.

into a god-component over three tickets.

mount cycle; do not push modal state into the page component.

Do NOT

filled in — picking the shape after coding is the most common

source of refactor debt.

in the same step — they sit at different tiers; pick one per phase.

state-vs-props axis differs; route to the matching stack skill.

is a design note for refinement, not implementation steps.

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.