phoenix-liveview-essentials
Phoenix LiveView Essentials
Use this skill before writing ANY LiveView module or .heex template.
Canonical FP bar: docs/fcis-engineering-rules.md — Functional Core, Imperative Shell: pure domain modules; side effects at edges. Keep LiveView/controller callbacks thin; delegate business rules to contexts/pure modules.
RULES — Follow these with no exceptions
1. Always add @impl true before every callback (mount, handle_event, handle_info, render)
2. Initialize assigns before they're accessed in render/1 — use mount/3 for static defaults, handle_params/3 for URL-dependent assigns
3. Check connected?(socket) before PubSub subscriptions, timers, or side effects
4. Use Map.get(assigns, :key, default) for optional assigns in helper functions
5. Return proper tuples — {:ok, socket} from mount, {:noreply, socket} from handle_event
6. Use with for error handling in event handlers — assign errors to socket, don't crash
7. Never use auto_upload: true with form submission — manual uploads are required to control when files are consumed relative to form data
8. Check core_components.ex for existing components before creating custom ones
9. Never query the database directly from LiveViews — call context functions instead
10. Use streams for large collections — see liveview-streams skill for details