mcpbeat Sign in

Elixir Idioms Skill for Claude

OTP/BEAM patterns and Elixir idioms — GenServer, Supervisor, Task, Registry, pattern matching, with chains, pipes. Use when designing processes or debugging BEAM issues.

12k tokens
context cost
the whole folder, loaded on every use
10
files
instructions only
0
copies elsewhere
how many repositories repackaged it
514
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/oliver-kriska/claude-elixir-phoenix --skill elixir-idioms

What comes with it

44 935 bytes besides the instruction
references/anti-patterns.md
references/elixir-118-features.md
references/elixir-120-type-system.md
references/error-handling.md
references/mix-tasks.md
references/otp-patterns.md
references/pattern-matching.md
references/troubleshooting.md
references/with-and-pipes.md

The instruction itself

11 sections, as written by the author

Elixir Idioms

Reference for writing idiomatic Elixir code with BEAM-aware patterns.

Iron Laws — Never Violate These

  • NO PROCESS WITHOUT A RUNTIME REASON — Processes model concurrency, state, isolation—NOT code structure
  • MESSAGES ARE COPIED — Keep messages small (except binaries >64 bytes)
  • GUARDS USE and/or/not — Never use short-circuit operators in guards (guards require boolean operands)
  • CHANGESETS FOR EXTERNAL DATA — Use cast/4 for user input, change/2 for internal
  • RESCUE ONLY FOR EXTERNAL CODE — Never use rescue for control flow
  • NO DYNAMIC ATOM CREATIONString.to_atom(user_input) causes memory leak (atoms aren't GC'd)
  • @external_resource FOR COMPILE-TIME FILES — Modules reading files at compile time MUST declare @external_resource
  • SUPERVISE ALL LONG-LIVED PROCESSES — Never bare GenServer.start_link/Agent.start_link in production. Use supervision trees
  • WRAP THIRD-PARTY LIBRARY APIs — Always facade external deps behind a project-owned module. Enables swapping without touching callers

10. MIX TASKS START ONLY WHAT THEY NEEDMix.Task.run("app.config") + Application.ensure_all_started/1, never Mix.Task.run("app.start") (boots the FULL tree: endpoint port, Oban consuming)

11. CAPTURE LOCALE BEFORE SPAWNING — Gettext/CLDR locale is process-local. Read it in the caller and pass explicitly; a spawned Task/GenServer starts with the default locale

BEAM Architecture (Why Elixir Works This Way)

  • Processes are cheap (2.6KB) — Spawn liberally for concurrency/isolation
  • Complete memory isolation — No shared state, no locks needed
  • Messages are copied (except binaries >64 bytes) — Keep messages small
  • Per-process GC — No global GC pauses
  • "Let it crash" — Supervisors restart to known-good state

Core Principles

  • Pattern match over conditionals — Function heads first, then case, then cond
  • Tagged tuples for expected failures{:ok, _}/{:error, _} for expected errors, raise for bugs
  • Pipe operator for data transformation — Start with data, never pipe single calls
  • Let it crash — Handle expected errors, crash on unexpected ones
  • Explicit over implicit — Be clear about intentions

Quick Decision Trees

Control Flow

Need patterns? → case (or function heads)
Multiple operations? → with
Boolean conditions? → cond (multiple) or if (single)

Error Handling

Expected failure? → {:ok, _}/{:error, _} tuples
Unexpected/bug? → raise exception (let supervisor handle)
External library? → rescue (only here!)

OTP

Need state?
├─ No → Plain functions
├─ Simple get/update → Agent or ETS
├─ Complex messages/timeouts → GenServer
└─ One-off async → Task

Quick Patterns

# Pattern match in function head
def process(%{status: :active} = user), do: activate(user)
def process(%{status: :inactive} = user), do: deactivate(user)

# with for happy path
with {:ok, user} <- get_user(id),
     {:ok, order} <- create_order(user) do
  {:ok, order}
end

# Task for async
Task.Supervisor.async_nolink(TaskSup, fn -> work() end)
|> Task.yield(5000) || Task.shutdown(task)

Common Pitfalls

| Wrong | Right |

|-------|-------|

| length(list) == 0 | list == [] or Enum.empty?(list) |

| list ++ [item] | [item \| list] \|> Enum.reverse() |

| String.to_atom(input) | String.to_existing_atom(input) |

| spawn(fn -> log(conn) end) | ip = conn.ip; spawn(fn -> log(ip) end) |

| unless condition | if !condition (unless deprecated in 1.18) |

References

For detailed patterns, see:

  • ${CLAUDE_SKILL_DIR}/references/pattern-matching.md - Pattern matching, guards, binary matching
  • ${CLAUDE_SKILL_DIR}/references/otp-patterns.md - GenServer, Supervisor, Task, Registry
  • ${CLAUDE_SKILL_DIR}/references/error-handling.md - Tagged tuples, rescue, with
  • ${CLAUDE_SKILL_DIR}/references/with-and-pipes.md - When to use with and |> (idiomatic patterns)
  • ${CLAUDE_SKILL_DIR}/references/troubleshooting.md - Production BEAM debugging (memory, performance, crashes)
  • ${CLAUDE_SKILL_DIR}/references/anti-patterns.md - Common mistakes and fixes
  • ${CLAUDE_SKILL_DIR}/references/mix-tasks.md - Mix task naming, option parsing, shell output
  • ${CLAUDE_SKILL_DIR}/references/elixir-118-features.md - Duration module, dbg improvements (1.18+)
  • ${CLAUDE_SKILL_DIR}/references/elixir-120-type-system.md - Gradual type checker, dynamic(), verified bugs as compile warnings (1.20+, OTP 27+)

Other skills for the same job

different authors, same section of the catalogue
Protocolsio Integration
by christophacham
×4

Integration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io functionality into workflows. Applicable for protocol discovery, collaborative protocol development, experiment tracking, lab protocol management, and scientific documentation.

16k tokens
Tailored Resume Generator
by frostant
×4

Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances

3k tokens
Excalidraw Diagram Generator
by github
vendor ×3

Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.

36k tokens scripts
Expo Dev Client
by openai
vendor ×3

Build and distribute Expo development clients locally or via TestFlight

961 tokens
Executing Plans
by ZhanlinCui
×3

Use when you have a written implementation plan to execute in a separate session with review checkpoints

542 tokens
Anndata
by christophacham
×3

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

16k tokens
Benchling Integration
by christophacham
×3

Benchling R&D platform integration. Access registry (DNA, proteins), inventory, ELN entries, workflows via API, build Benchling Apps, query Data Warehouse, for lab data management automation.

14k tokens
Biopython
by christophacham
×3

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

24k tokens

How to use it

Copy the folder

Take oliver-kriska/elixir-idioms from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.