Agent skill

Phoenix Liveview Essentials

by j-morgan6 in j-morgan6/elixir-phoenix-guide

A skill your agent uses when writing LiveView modules or HEEx templates — mount/handleparams lifecycle, assigns, streams, events, components.

MITAuto-check passedAI & LLM Engineering

Install Phoenix Liveview Essentials

skills CLI
$ npx skills add j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-essentials -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install j-morgan6/elixir-phoenix-guide phoenix-liveview-essentials --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/j-morgan6/elixir-phoenix-guide.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/phoenix-liveview-essentials .claude/skills/phoenix-liveview-essentials && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
phoenix-liveview-essentials
GitHub stars
167
Token cost
~2.6k tokens
SKILL.md length
457 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when writing LiveView modules or HEEx templates — mount/handleparams lifecycle, assigns, streams, events, components.

  • Works in 9 steps: Always add @impl true before every… → Initialize assigns before they're… → Check connected?(socket) before PubSub… → …
  • Writing LiveView modules
  • SKILL.md covers RULES — Follow these with no…, Critical Concept: Two-Phase…, LiveView Lifecycle and Socket Assigns, plus 11 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Phoenix Liveview Essentials is an agent skill from j-morgan6/elixir-phoenix-guide. Use when writing LiveView modules or HEEx templates — mount/handleparams lifecycle, assigns, streams, events, components.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering LLM observability. The licence is MIT.

When your agent uses it

  • Writing LiveView modules
  • HEEx templates — mount/handleparams lifecycle

Example prompts

  • “/phoenix-liveview-essentials”

Workflow steps

9 steps, taken from the first numbered list in SKILL.md.

  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. auto_upload: true works with submit, but entries must be fully uploaded before you consume them — check entry.done? / rely on…
  8. Check core_components.ex for existing components before creating custom ones
  9. Never query the database directly from LiveViews — call context functions instead

What it can do on your machine

Read from SKILL.md and the folder at commit cdfddac. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are elixir and heex).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Phoenix Liveview Essentials loads about 2.6k tokens when it runs. Until then it costs about 38 tokens; SKILL.md has 457 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~38
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from j-morgan6/elixir-phoenix-guide at commit cdfddac, republished under its MIT licence (© j-morgan6). 457 words, ~2,621 tokens.

Download SKILL.mdSave it as .claude/skills/phoenix-liveview-essentials/SKILL.md (or your agent's skills folder).
name
phoenix-liveview-essentials
description
Use when writing LiveView modules or HEEx templates — mount/handle_params lifecycle, assigns, streams, events, components.
file_patterns
**/live/**/*.ex, **/*_live.ex, **/*.html.heex, **/live/**/*.html.heex
auto_suggest
true

Phoenix LiveView Essentials

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 (pagination, filters, sorting)
  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. auto_upload: true works with submit, but entries must be fully uploaded before you consume them — check entry.done? / rely on consume_uploaded_entries only after progress completes; default to manual uploads unless you need incremental upload UX
  8. Check core_components.ex for existing components before creating custom ones
  9. Never query the database directly from LiveViews — call context functions instead

Critical Concept: Two-Phase Rendering

LiveView renders happen in TWO phases:

  1. Static/Disconnected Render - Initial HTTP request

    • No WebSocket connection
    • connected?(socket) returns false
    • Side effects (PubSub, timers) won't work
  2. Connected Render - WebSocket established

    • Full live functionality active
    • connected?(socket) returns true
    • Events and live updates work

Common Bug: Accessing uninitialized assigns during static render crashes with KeyError.

Solution: Initialize assigns before render — use mount/3 for static defaults, handle_params/3 for URL-dependent state.


LiveView Lifecycle

Mount Callback
elixir
@impl true
def mount(_params, _session, socket) do
  # Initialize static defaults here; URL-dependent assigns go in handle_params
  socket =
    socket
    |> assign(:user, nil)
    |> assign(:loading, false)
    |> assign(:data, [])

  # Only subscribe when connected
  if connected?(socket) do
    Phoenix.PubSub.subscribe(MyApp.PubSub, "topic")
  end

  {:ok, socket}
end

Why check connected? PubSub subscriptions and timers only work with WebSocket connection.

Handle Event

Use pattern matching for different actions.

elixir
@impl true
def handle_event("save", %{"post" => post_params}, socket) do
  case Posts.create_post(post_params) do
    {:ok, post} ->
      socket =
        socket
        |> put_flash(:info, "Created!")
        |> assign(:post, post)

      {:noreply, socket}

    {:error, changeset} ->
      {:noreply, assign(socket, :changeset, changeset)}
  end
end

@impl true
def handle_event("delete", %{"id" => id}, socket) do
  Posts.delete_post(id)
  {:noreply, assign(socket, :posts, Posts.list_posts())}
end
Handle Info

Handle async messages and PubSub broadcasts.

elixir
@impl true
def handle_info({:post_created, post}, socket) do
  {:noreply, update(socket, :posts, fn posts -> [post | posts] end)}
end

@impl true
def handle_info(%{event: "presence_diff"}, socket) do
  {:noreply, assign(socket, :online_users, get_presence_count())}
end
Handle Params

Respond to URL changes (called in BOTH render phases).

elixir
@impl true
def handle_params(%{"id" => id}, _uri, socket) do
  # This runs during static AND connected render
  post = Posts.get_post!(id)

  if connected?(socket) do
    # Only subscribe when connected
    Phoenix.PubSub.subscribe(MyApp.PubSub, "post:#{id}")
  end

  {:noreply, assign(socket, :post, post)}
end

@impl true
def handle_params(_params, _uri, socket) do
  {:noreply, socket}
end

Socket Assigns

Use assign/2 or assign/3 to update socket state.

elixir
# Single assign
socket = assign(socket, :count, 0)

# Multiple assigns
socket = assign(socket, count: 0, name: "User", active: true)

# Update existing assign
socket = update(socket, :count, &(&1 + 1))
Show full SKILL.md (188 more words)Show less
Safe Assign Access

In render/1: Direct access is safe if initialized in mount.

elixir
@impl true
def mount(_params, _session, socket) do
  {:ok, assign(socket, :count, 0)}
end

@impl true
def render(assigns) do
  ~H"""
  <p>Count: <%= @count %></p>  <!-- Safe -->
  """
end

In helper functions: Use Map.get for optional assigns.

elixir
# ❌ BAD - Crashes if not a map with :name
defp format_user(%{name: name}), do: name

# ✅ GOOD - Handles nil case
defp format_user(socket) do
  case Map.get(socket.assigns, :current_user) do
    nil -> "Guest"
    user -> user.name
  end
end

Temporary Assigns

Use temporary assigns for large collections that don't need to persist.

elixir
@impl true
def mount(_params, _session, socket) do
  socket = assign(socket, :posts, [])
  {:ok, socket, temporary_assigns: [posts: []]}
end

For collections, prefer streams (below) — the current recommended mechanism; temporary_assigns remains useful for one-shot large payloads that aren't managed as a growing/shrinking collection.

Flash Messages

Use put_flash/3 and clear_flash/2 for user feedback.

elixir
@impl true
def handle_event("save", params, socket) do
  case save_data(params) do
    {:ok, _} ->
      socket = put_flash(socket, :info, "Saved successfully!")
      {:noreply, socket}

    {:error, _} ->
      socket = put_flash(socket, :error, "Failed to save")
      {:noreply, socket}
  end
end

Live Navigation

Use push_navigate/2 or push_patch/2 for navigation.

elixir
# Full page reload (new LiveView)
{:noreply, push_navigate(socket, to: ~p"/users")}

# Patch (same LiveView, different params)
{:noreply, push_patch(socket, to: ~p"/posts/#{post}")}

Streams

Use streams for efficient rendering of large lists.

elixir
@impl true
def mount(_params, _session, socket) do
  {:ok, stream(socket, :posts, Posts.list_posts())}
end

@impl true
def handle_event("add", %{"post" => attrs}, socket) do
  {:ok, post} = Posts.create_post(attrs)
  {:noreply, stream_insert(socket, :posts, post, at: 0)}
end

@impl true
def handle_event("delete", %{"id" => id}, socket) do
  Posts.delete_post(id)
  {:noreply, stream_delete_by_dom_id(socket, :posts, "posts-#{id}")}
end

Components

Extract reusable UI into function components.

elixir
def card(assigns) do
  ~H"""
  <div class="card">
    <h3><%= @title %></h3>
    <p><%= @content %></p>
  </div>
  """
end

# Usage in template
<.card title="Hello" content="World" />

Form Binding

Bind forms to changesets for validation.

heex
<%!-- Phoenix 1.8 removed the old simple-form component; use <.form> --%>
<.form for={@form} phx-change="validate" phx-submit="save">
  <.input field={@form[:title]} label="Title" />
  <.input field={@form[:body]} type="textarea" label="Body" />
  <:actions>
    <.button>Save</.button>
  </:actions>
</.form>
elixir
@impl true
def mount(_params, _session, socket) do
  changeset = Post.changeset(%Post{}, %{})
  {:ok, assign(socket, form: to_form(changeset))}
end

@impl true
def handle_event("validate", %{"post" => params}, socket) do
  changeset =
    %Post{}
    |> Post.changeset(params)
    |> Map.put(:action, :validate)

  {:noreply, assign(socket, form: to_form(changeset))}
end

Error Handling

Handle errors in handle_event to prevent LiveView crashes — assign errors to the socket instead of letting the process crash.

elixir
@impl true
def handle_event("save", params, socket) do
  case save_record(params) do
    {:ok, record} ->
      socket =
        socket
        |> put_flash(:info, "Saved successfully")
        |> assign(:record, record)

      {:noreply, socket}

    {:error, %Ecto.Changeset{} = changeset} ->
      socket =
        socket
        |> put_flash(:error, "Please correct the errors")
        |> assign(:changeset, changeset)

      {:noreply, socket}

    {:error, reason} ->
      socket = put_flash(socket, :error, "An error occurred: #{reason}")
      {:noreply, socket}
  end
end

Real-time updates: see the phoenix-pubsub-patterns skill.

Testing

When writing LiveView tests, invoke elixir-phoenix-guide:testing-essentials before writing any _test.exs file.

Common Lifecycle Mistakes

Mistakes 1 (uninitialized assigns) and 2 (subscribing without connected?) are covered by rules 2 and 3 above and the Two-Phase Rendering section. One more pitfall isn't covered by either rule:

❌ Expensive Operations in Both Phases
elixir
@impl true
def mount(_params, _session, socket) do
  # BAD - Runs expensive query twice (static + connected)
  data = run_expensive_query()
  {:ok, assign(socket, :data, data)}
end
✅ Fix: Defer to connected phase
elixir
@impl true
def mount(_params, _session, socket) do
  socket =
    if connected?(socket) do
      # Only run when connected
      assign(socket, :data, run_expensive_query())
    else
      # Placeholder for static render
      assign(socket, :data, [])
    end

  {:ok, socket}
end

Lifecycle Flow

1. HTTP Request arrives
   ↓
2. mount/3 called (connected? = false)
   ↓
3. handle_params/3 called (connected? = false)
   ↓
4. render/1 called (STATIC HTML generated)
   ↓
5. HTML sent to browser
   ↓
6. Browser connects WebSocket
   ↓
7. mount/3 called AGAIN (connected? = true)
   ↓
8. handle_params/3 called AGAIN (connected? = true)
   ↓
9. render/1 called (sent over WebSocket)
   ↓
10. LiveView now active and reactive

Quick Reference

Safe Patterns
elixir
# ✅ Initialize in mount
assign(socket, :key, default_value)

# ✅ Use Map.get for optional
Map.get(socket.assigns, :key, default)

# ✅ Check connected for side effects
if connected?(socket), do: subscribe()

# ✅ Pattern match with fallback
def helper(%{name: name}), do: name
def helper(_), do: "default"

# ✅ Add @impl true
@impl true
def mount(...), do: ...
Unsafe Patterns
elixir
# ❌ Direct access without initialization
socket.assigns.key

# ❌ Subscribe without checking
Phoenix.PubSub.subscribe(...)

# ❌ Expensive ops in both phases
mount(...) do
  data = expensive_query()
end

# ❌ Missing @impl true
def mount(...), do: ...

© j-morgan6, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/phoenix-liveview-essentials of j-morgan6/elixir-phoenix-guide.

Open the folder on GitHubat commit cdfddac

Compare with similar skills

Phoenix Liveview Essentials next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Phoenix Liveview Essentials compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Phoenix Liveview Essentials this skillj-morgan6/elixir-phoenix-guide167—~2.6kAutomated safety check: PassMIT
Elixir Expertpass-agent/loomkin1811 repos~796Automated safety check: PassMIT
Hex Docs Searchbradleygolden/claude-marketplace-elixir176—~4.1kAutomated safety check: NotesMIT
Phoenix Contextsoliver-kriska/claude-elixir-phoenix565—~841Automated safety check: PassMIT
Phoenixericrisco/rsc-harness180—~2.9kAutomated safety check: NotesMIT
Langfuse Codebase Navigatorlangfuse/langfuse36k—~1.4kAutomated safety check: PassCustom licence

Similar skills

  • Elixir Expert

    pass-agent/loomkin

    Expert in Elixir, Phoenix Framework, and OTP. An agent skill from pass-agent/loomkin.

    181 GitHub starsUsed in 1 repo~796 tokens
    AI & LLM EngineeringAuto-check passed
  • Hex Docs Search

    bradleygolden/claude-marketplace-elixir

    Research Hex packages (Sobelow, Phoenix, Ecto, Credo, Ash, etc).

    176 GitHub stars~4.1k tokensUpdated 9 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Phoenix Contexts

    oliver-kriska/claude-elixir-phoenix

    Phoenix context design — creating/splitting contexts, Scope (1.8+), Ecto.Multi, PubSub, routers, plugs, controllers.

    565 GitHub stars~841 tokensUpdated 4 days ago
    AI & LLM EngineeringAuto-check passed
  • Phoenix

    ericrisco/rsc-harness

    A skill your agent uses when building an Elixir web app with Phoenix — contexts, Ecto schemas, changesets and migrations, LiveView, channels and PubSub, the generators, and the boundary between…

    180 GitHub stars~2.9k tokensUpdated today
    AI & LLM EngineeringAuto-check: notes
  • Navigate Langfuse repositories, code areas, and agent skills.

    36k GitHub stars~1.4k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • LLM Trace Review Interface

    ai-evals-course/evals-skills

    Builds a browser-based annotation page for reviewing LLM traces one at a time with pass/fail labels, notes and saved results, tailored to your data.

    1.5k GitHub stars~1.4k tokensUpdated 15 days ago
    AI & LLM EngineeringAuto-check passed

More from j-morgan6/elixir-phoenix-guide

All 19 skills in this repo
  • Code Quality

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when refactoring for duplication, complexity, or dead code — includes the plugin's on-demand analysis scripts.

    167 GitHub stars~1.4k tokensUpdated 3 mo ago
    Auto-check passed
  • Deployment Gotchas

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when preparing releases or deployment config — runtime.exs vs compile-time config, release migrations, PHXHOST/PHXSERVER, assets, health checks.

    167 GitHub stars~2.6k tokensUpdated 3 mo ago
    Auto-check passed
  • Ecto Changeset Patterns

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when a resource needs multiple changesets (registration vs update), conditional validation, field transforms, or uniqueness validation — changeset composition.

    167 GitHub stars~2.1k tokensUpdated 3 mo ago
    Auto-check passed
  • Ecto Essentials

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when defining schemas, writing queries, or creating migrations — schema design, Repo usage, indexes, query composition.

    167 GitHub stars~2.2k tokensUpdated 3 mo ago
    Auto-check passed
  • Ecto Nested Associations

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when a form or operation manages parent and child records together — castassoc/castembed, onreplace, Ecto.Multi across tables, FK cascade design.

    167 GitHub stars~2.2k tokensUpdated 3 mo ago
    Auto-check passed
  • Elixir Essentials

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when writing or refactoring core Elixir — pattern matching, case/cond/with, pipes, {:ok, }/{:error, } contracts.

    167 GitHub stars~2.2k tokensUpdated 3 mo ago
    Auto-check passed

Questions about Phoenix Liveview Essentials

What does Phoenix Liveview Essentials do?

A skill your agent uses when writing LiveView modules or HEEx templates — mount/handleparams lifecycle, assigns, streams, events, components. Phoenix Liveview Essentials is an agent skill from j-morgan6/elixir-phoenix-guide. Use when writing LiveView modules or HEEx templates — mount/handleparams lifecycle, assigns, streams, events, components.

When should I use Phoenix Liveview Essentials?

Phoenix Liveview Essentials fits situations like: writing LiveView modules; HEEx templates — mount/handleparams lifecycle.

How do I install Phoenix Liveview Essentials in Claude Code?

Run `npx skills add j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-essentials -a claude-code`. Or copy the skill folder (skills/phoenix-liveview-essentials in j-morgan6/elixir-phoenix-guide) into .claude/skills/phoenix-liveview-essentials in your project. Claude Code loads it when a task matches its description.

How do I install Phoenix Liveview Essentials in Codex?

Run `npx skills add j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-essentials -a codex`. Or copy the skill folder (skills/phoenix-liveview-essentials in j-morgan6/elixir-phoenix-guide) into .agents/skills/phoenix-liveview-essentials in your project. Codex loads it when a task matches its description.

Can I use Phoenix Liveview Essentials in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-essentials -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/phoenix-liveview-essentials, .gemini/skills/phoenix-liveview-essentials, .github/skills/phoenix-liveview-essentials and .opencode/skills/phoenix-liveview-essentials in your project.

What does Phoenix Liveview Essentials need to run?

SKILL.md names no scripts, command-line tools or credentials: Phoenix Liveview Essentials is instructions for the agent only.

Does Phoenix Liveview Essentials access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Phoenix Liveview Essentials safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Phoenix Liveview Essentials use?

Phoenix Liveview Essentials is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Phoenix Liveview Essentials use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Phoenix Liveview Essentials?

Skills that share tags, products or a category with Phoenix Liveview Essentials: Elixir Expert (pass-agent/loomkin, 181 stars), Hex Docs Search (bradleygolden/claude-marketplace-elixir, 176 stars), Phoenix Contexts (oliver-kriska/claude-elixir-phoenix, 565 stars) and Phoenix (ericrisco/rsc-harness, 180 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Phoenix Liveview Essentials?

j-morgan6 (a GitHub user) maintains it in j-morgan6/elixir-phoenix-guide, which has 167 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on July 6, 2026.

Source: j-morgan6/elixir-phoenix-guide on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.