phoenix-liveview-auth
Installation
SKILL.md
Phoenix LiveView Authentication
RULES — Follow these with no exceptions
- Always use
on_mountcallbacks for LiveView auth — never check auth inmount/3directly;on_mountruns before mount and centralizes auth logic - Use
mount_current_scope/2to extract scope from session — never access session tokens manually or parse session data in LiveViews - Handle both
:contand:haltreturns fromon_mount—:haltmust redirect with a flash message, never silently drop the connection - Resolve import conflicts explicitly —
Phoenix.ControllerandPhoenix.LiveViewboth exportredirect/2andput_flash/3; useexcept:to avoid ambiguity - Use bracket access
assigns[:current_scope]in templates — dot access@current_scopecrashes on nil when user is not authenticated - Test auth redirects by asserting
{:error, {:redirect, %{to: path}}}— don't test auth by checking rendered content; verify the redirect tuple fromlive/2 - Define
on_mounthooks once, reference vialive_sessionin router — never duplicate auth logic across LiveView modules
on_mount Authentication Pattern
The standard pattern for LiveView authentication. Define once, use everywhere via live_session.
Related skills
More from j-morgan6/elixir-phoenix-guide
oban-essentials
MANDATORY for ALL Oban work. Invoke before writing workers or enqueuing jobs.
1phoenix-json-api
MANDATORY for ALL JSON API work. Invoke before writing API controllers, pipelines, or JSON responses.
1ecto-essentials
MANDATORY for ALL database work. Invoke before modifying schemas, queries, or migrations.
1otp-essentials
MANDATORY for ALL OTP work. Invoke before writing GenServer, Supervisor, Task, or Agent modules.
1code-quality
Automated code quality detection — duplication, complexity, unused functions. Invoke when analyzing or refactoring Elixir code.
1phoenix-uploads
MANDATORY for file upload features. Invoke before implementing upload or file serving functionality.
1