assigns-audit
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.
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install elixir-phoenix-assigns-auditManual setup by platform
Claude Code
~/.claude/skills/elixir-phoenix-assigns-audit/SKILL.md
Instructions
LiveView Assigns Audit
Analyze LiveView socket assigns for memory efficiency, clarity, and best practices.
Iron Laws - Never Violate These
- Use streams for lists > 100 items - Never store large lists directly in assigns
- Use temporary_assigns for transient data - Flash messages, temp errors, notifications
- Preload only needed fields - Don't store full Ecto schemas when only needing subset
- Initialize all assigns in mount - Never access assigns that might not exist
- NEVER modify assigns or code during audit — this is a read-only diagnostic; report findings only
Quick Audit Commands
Extract All Assigns
Use Grep to find all assign( and assign_new( calls in the target LiveView file.
Find Large Data Patterns
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.
Audit Checklist
1. Memory Issues
| 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 |
2. Missing temporary_assigns
Should use temporary_assigns:
- Flash messages
- Form errors after submission
- One-time notifications
- Upload progress
def mount(_params, _session, socket) do
{:ok, socket, temporary_assigns: [flash_message: nil]}
end
3. Unused Assigns
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.
4. Missing Initialization
# 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
Memory Estimation
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 |
Usage
Run /lv:assigns path/to/live_view.ex to generate an assigns inventory with memory estimates and optimization recommendations.
Security
Reviews (0)
Related skills
Browse all →More from Elixir & Phoenix
View source →More Build skills
Browse category →Frequently asked questions about assigns-audit
What does the assigns-audit skill do?
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. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the assigns-audit skill?
Run `npx @skills-hub-ai/cli install elixir-phoenix-assigns-audit` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/elixir-phoenix-assigns-audit/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does assigns-audit work with?
assigns-audit runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the assigns-audit skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use assigns-audit after installing it?
In Claude Code, type `/elixir-phoenix-assigns-audit` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the assigns-audit skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.