Agent skill
Assigns audit
Inspect LiveView socket assigns for memory bloat, missing temporary_
New to this? An agent skill is a file of instructions your AI assistant follows for one job. The text above is written for the assistant. How to use a skill
What it does
Assigns audit is an agent skill from oliver-kriska/
In short, it gives your assistant a fixed routine for one kind of job.
The file is 91 lines long and is set out in parts such as “Iron Laws, Never Violate These”, “Quick Audit Commands”, “Extract All Assigns” and “Find Large Data Patterns”.
It has 2 code examples your assistant can follow.
When to use it
Reach for it when you do this job often and want the same good result each time.
Everything it needs is in this one file.
It does not ask for special tools.
Safety check
Our checker read all 91 lines before we listed it.
It found no attack techniques, no hidden text and no steps that switch off your assistant's safety or send your data away.
It flagged nothing else to watch for.
The text links to no outside sites.
It is shared under the MIT license.
Still read it before you use it, like any instructions you give your AI.
Open in the appOriginal on GitHub
What is inside
- Iron Laws - Never Violate These
- Quick Audit Commands
- Extract All Assigns
- Find Large Data Patterns
- Audit Checklist
- 1. Memory Issues
- 2. Missing temporaryassigns
- 3. Unused Assigns
How to use it
- Claude Code: save the text as
.claude/skills/assigns-audit/SKILL.mdin your project. Claude reads it when a task needs it. - Claude, ChatGPT or Gemini: tap Copy skill and paste it into the chat. It arrives with a short line asking the assistant to use it.
- Cursor and other agents: add it to the project rules or instructions.
Read the full guide to using an agent skill
Want your own? How to write an agent skill that works
The full skill
---
name: assigns-audit
description: "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."
effort: medium
argument-hint: path/to/live_view.ex
---
# LiveView Assigns Audit
Analyze LiveView socket assigns for memory efficiency, clarity, and best practices.
## Iron Laws - Never Violate These
1. **Use streams for lists > 100 items** - Never store large lists directly in assigns
2. **Use temporary_assigns for transient data** - Flash messages, temp errors, notifications
3. **Preload only needed fields** - Don't store full Ecto schemas when only needing subset
4. **Initialize all assigns in mount** - Never access assigns that might not exist
5. **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
```elixir
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
```elixir
# 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.
Copyright (c) 2025‑2026 Oliver Kriska.
Published under the MIT License, which you can read in full there.
Shown as published on GitHub, with credit and a link to the original.
Read it before you use it.
More skills
Try it in your browser
Today's AI news, one card per swipe.
Free to start.