agentleFS
igmarinigmarin/elixir-phoenix-skills/skills/phoenix-liveview-essentials/SKILL.md

phoenix-liveview-essentials

Skill4 starsChanged 4 months agoMITView on GitHub

Use when building or changing a Phoenix LiveView, event handler, form, navigation flow, or LiveView test.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep the LiveView as the UI edge.

    line 11
  2. Very specific:

    Put route-dependent loading in handle_params/3.

    line 16
  3. Distinctive:

    Keep assigns limited to data needed by the render.

    line 17
  4. Distinctive:

    Treat all event params as untrusted strings/maps.

    line 22
  5. Distinctive:

    Use tagged results to render expected failures.

    line 25

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Phoenix LiveView Essentials

Keep the LiveView as the UI edge. Parse events and params, call domain/context functions, then assign results or show errors. Keep business rules out of callbacks.

Lifecycle and data

  • mount/3 may run for the disconnected HTTP render and again for the connected socket. Keep it safe to repeat; subscribe or start live work only when connected?/1 is true.
  • Put route-dependent loading in handle_params/3. Use push_patch for same-LiveView state and push_navigate for a new LiveView.
  • Keep assigns limited to data needed by the render. Use streams for large or frequently updated collections.
  • Load records through the application's authorization boundary; a guessed ID is not proof of access.

Events and forms

  • Treat all event params as untrusted strings/maps. Validate with a changeset or domain parser before writing.
  • handle_event/3 should coordinate work and update the socket. Move multi-step rules into a context or pure module.
  • For forms, use to_form/1 and the project's current form conventions. Preserve changeset errors and keep validation behavior in the changeset.
  • Use tagged results to render expected failures. Let unexpected failures surface to normal error reporting.

Tests

Cover initial render, relevant events, invalid input, authorization, and navigation that changes behavior. Use Phoenix.LiveViewTest and the existing ConnCase/DataCase setup. Avoid duplicating assertions already covered by component or context tests.

For large lists use liveview-streams; for auth flows use phoenix-authentication and phoenix-authorization-patterns.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.