plugins/elixir-phoenix/skills/assigns-audit/SKILL.md
Inspect LiveView socket assigns for memory bloat — missing temporary_assigns, unused assigns, unbounded lists needing streams, memory estimates. Use when LiveView memory grows or you need to add temporary_assigns.
npx skillsauth add oliver-kriska/claude-elixir-phoenix assigns-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze LiveView socket assigns for memory efficiency, clarity, and best practices.
Use Grep to find all assign( and assign_new( calls in the target LiveView file.
Use Grep to find large data patterns: lists stored in assigns (assign.*\[\], assign.*Repo\.all) and full schema storage (assign.*Repo\.get) in the target file.
| Pattern | Problem | Solution |
|---------|---------|----------|
| assign(:items, Repo.all(...)) | Unbounded list | Use stream/3 |
| assign(:user, Repo.get!(...)) | Full schema | Select only needed fields |
| assign(:file_data, binary) | Large binary | Store reference, not data |
| Nested preloads | Excessive data | Preload only what's rendered |
Should use temporary_assigns:
def mount(_params, _session, socket) do
{:ok, socket, temporary_assigns: [flash_message: nil]}
end
Search for assigns defined but never used in templates:
Use Grep to extract all assign names (assign\(:(\w+)) from the LiveView file, then use Grep to find all @\w+ references in the corresponding .heex template. Compare to find unused assigns.
# BAD: @items might not exist
def render(assigns) do
~H"<%= for item <- @items do %>"
end
# GOOD: Initialize in mount
def mount(_params, _session, socket) do
{:ok, assign(socket, items: [])}
end
For each assign, estimate memory footprint:
| Data Type | Approx Size | Concern Level | |-----------|-------------|---------------| | Integer | 8 bytes | Low | | String (100 chars) | ~200 bytes | Low | | List of 100 maps | ~10-50 KB | Medium | | List of 1000 items | ~100-500 KB | High | | Binary (image) | Varies | Critical | | Full Ecto schema | ~1-5 KB each | Medium |
Run /lv:assigns path/to/live_view.ex to generate an assigns inventory with memory estimates and optimization recommendations.
tools
Compatibility alias for the Elixir/Phoenix plugin's LiveView assigns audit. Invoke explicitly with /lv:assigns.
development
Trace Elixir call trees from entry points via mix xref. Use when debugging data flow, planning signature changes, or understanding how a bug reaches code.
tools
Compatibility alias for the Elixir/Phoenix plugin's N+1 query checker. Invoke explicitly with /ecto:n1-check.
tools
Compatibility alias for the Elixir/Phoenix plugin's Ecto constraint debugger. Invoke explicitly with /ecto:constraint-debug.