{"slug":"lv-assigns","title":"lv-assigns","summary":"Inspect LiveView socket assigns for memory bloat — missing temporary_assigns,","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-10-04T15:14:22.624279Z","repo":{"url":"https://github.com/oliver-kriska/claude-elixir-phoenix","stars":560,"forks":44,"license":"MIT","updatedAt":"2026-10-02T04:11:38Z"},"bodyHtml":"<hr>\n<h2>name: lv-assigns\ndescription: Inspect LiveView socket assigns for memory bloat — missing temporary_assigns,\nunused assigns, unbounded lists needing streams, memory estimates. Use when LiveView\nmemory grows or you need to add temporary_assigns.</h2>\n<h1>LiveView Assigns Audit</h1>\n<p>Analyze LiveView socket assigns for memory efficiency, clarity, and best practices.</p>\n<h2>Iron Laws - Never Violate These</h2>\n<ol>\n<li><strong>Use streams for lists &gt; 100 items</strong> - Never store large lists directly in assigns</li>\n<li><strong>Use temporary_assigns for transient data</strong> - Flash messages, temp errors, notifications</li>\n<li><strong>Preload only needed fields</strong> - Don't store full Ecto schemas when only needing subset</li>\n<li><strong>Initialize all assigns in mount</strong> - Never access assigns that might not exist</li>\n<li><strong>NEVER modify assigns or code during audit</strong> — this is a read-only diagnostic; report findings only</li>\n</ol>\n<h2>Quick Audit Commands</h2>\n<h3>Extract All Assigns</h3>\n<p>Use Grep to find all <code>assign(</code> and <code>assign_new(</code> calls in the target LiveView file.</p>\n<h3>Find Large Data Patterns</h3>\n<p>Use Grep to find large data patterns: lists stored in assigns (<code>assign.*\\[\\]</code>, <code>assign.*Repo\\.all</code>) and full schema storage (<code>assign.*Repo\\.get</code>) in the target file.</p>\n<h2>Audit Checklist</h2>\n<h3>1. Memory Issues</h3>\n<table>\n<thead>\n<tr>\n<th>Pattern</th>\n<th>Problem</th>\n<th>Solution</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>assign(:items, Repo.all(...))</code></td>\n<td>Unbounded list</td>\n<td>Use <code>stream/3</code></td>\n</tr>\n<tr>\n<td><code>assign(:user, Repo.get!(...))</code></td>\n<td>Full schema</td>\n<td>Select only needed fields</td>\n</tr>\n<tr>\n<td><code>assign(:file_data, binary)</code></td>\n<td>Large binary</td>\n<td>Store reference, not data</td>\n</tr>\n<tr>\n<td>Nested preloads</td>\n<td>Excessive data</td>\n<td>Preload only what's rendered</td>\n</tr>\n</tbody>\n</table>\n<h3>2. Missing temporary_assigns</h3>\n<p>Should use <code>temporary_assigns</code>:</p>\n<ul>\n<li>Flash messages</li>\n<li>Form errors after submission</li>\n<li>One-time notifications</li>\n<li>Upload progress</li>\n</ul>\n<pre><code>def mount(_params, _session, socket) do\n  {:ok, socket, temporary_assigns: [flash_message: nil]}\nend\n</code></pre>\n<h3>3. Unused Assigns</h3>\n<p>Search for assigns defined but never used in templates:</p>\n<p>Use Grep to extract all assign names (<code>assign\\(:(\\w+)</code>) from the LiveView file, then use Grep to find all <code>@\\w+</code> references in the corresponding <code>.heex</code> template. Compare to find unused assigns.</p>\n<h3>4. Missing Initialization</h3>\n<pre><code># BAD: @items might not exist\ndef render(assigns) do\n  ~H\"&lt;%= for item &lt;- @items do %&gt;\"\nend\n\n# GOOD: Initialize in mount\ndef mount(_params, _session, socket) do\n  {:ok, assign(socket, items: [])}\nend\n</code></pre>\n<h2>Memory Estimation</h2>\n<p>For each assign, estimate memory footprint:</p>\n<table>\n<thead>\n<tr>\n<th>Data Type</th>\n<th>Approx Size</th>\n<th>Concern Level</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Integer</td>\n<td>8 bytes</td>\n<td>Low</td>\n</tr>\n<tr>\n<td>String (100 chars)</td>\n<td>~200 bytes</td>\n<td>Low</td>\n</tr>\n<tr>\n<td>List of 100 maps</td>\n<td>~10-50 KB</td>\n<td>Medium</td>\n</tr>\n<tr>\n<td>List of 1000 items</td>\n<td>~100-500 KB</td>\n<td>High</td>\n</tr>\n<tr>\n<td>Binary (image)</td>\n<td>Varies</td>\n<td>Critical</td>\n</tr>\n<tr>\n<td>Full Ecto schema</td>\n<td>~1-5 KB each</td>\n<td>Medium</td>\n</tr>\n</tbody>\n</table>\n<h2>Usage</h2>\n<p>Run <code>lv-assigns path/to/live_view.ex</code> to generate an assigns inventory with memory estimates and optimization recommendations.</p>\n","files":[{"path":"SKILL.md","sizeBytes":2930,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-10-04T15:16:16.070479Z","sha256":"01E0FEEBB8E99AD6D01031CC914A8149ADCBFAA8D366E749127E3338ACB3DA43","sizeBytes":1490},"review":null,"source":{"repositoryUrl":"https://github.com/oliver-kriska/claude-elixir-phoenix","path":"targets/amp/skills/lv-assigns","license":"MIT","commit":"9767a82d24ddddad553e85f88efc2869a7fd7d88","subtreeSha":"3926CC776EB63E540CF04622F715D99CBB9E08DE6845DA5CED2AB348BF708ABB","lastSyncedAt":"2026-10-04T15:14:09.139242Z"},"reviewedAt":"2026-10-04T15:19:37.79327Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/oliver-kriska/claude-elixir-phoenix/tree/main/targets/amp/skills/lv-assigns"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install oliver-kriska-claude-elixir-phoenix@llmmart"},{"target":"git","command":"git clone https://github.com/oliver-kriska/claude-elixir-phoenix.git"}]}