phoenix-liveview-essentials
Phoenix LiveView Essentials
RULES — Follow these with no exceptions
- Always add @impl true before every callback (mount, handle_event, handle_info, render)
- Initialize assigns before they're accessed in render/1 — use mount/3 for static defaults, handle_params/3 for URL-dependent assigns (pagination, filters, sorting)
- Check connected?(socket) before PubSub subscriptions, timers, or side effects
- Use Map.get(assigns, :key, default) for optional assigns in helper functions
- Return proper tuples —
{:ok, socket}from mount,{:noreply, socket}from handle_event - Use
withfor error handling in event handlers — assign errors to socket, don't crash - Never use auto_upload: true with form submission — use manual uploads instead
- Check
core_components.exfor existing components before creating custom ones - Never query the database directly from LiveViews — call context functions instead
Critical Concept: Two-Phase Rendering
LiveView renders happen in TWO phases:
More from j-morgan6/elixir-claude-optimization
phoenix-uploads
MANDATORY for file upload features. Invoke before implementing upload or file serving functionality.
14elixir-essentials
MANDATORY for ALL Elixir code changes. Invoke before writing any .ex or .exs file.
14phoenix-liveview
INVOKE BEFORE implementing any LiveView feature. REQUIRED for mount, handle_event, handle_info callbacks, file uploads, navigation, PubSub, streams, and LiveView testing. Essential for all LiveView development.
7elixir-patterns
INVOKE BEFORE writing any Elixir code. REQUIRED for pattern matching, pipe operators, with statements, guards, list comprehensions, and naming conventions. Use this skill to ensure idiomatic Elixir patterns.
6testing-essentials
MANDATORY for ALL test files. Invoke before writing any _test.exs file.
6ecto-essentials
MANDATORY for ALL database work. Invoke before modifying schemas, queries, or migrations.
5