elixir
Language-specific super-code guidelines for elixir.
Elixir / Erlang: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for elixir.
Table of Contents
- [Pattern Matching & Guards](#patterns)
- [Pipe Operator & Transforms](#pipes)
- [Processes & OTP](#otp)
- [Error Handling](#errors)
- [Collections & Enum](#collections)
- [Structs & Protocols](#structs)
- [Anti-patterns specific to Elixir/Erlang](#antipatterns)
1. Pattern Matching & Guards {#patterns}
# ❌ Extracting with Map.get then checking
value = Map.get(map, :key)
if value != nil do
process(value)
end
# ✅ — pattern match directly
case map do
%{key: value} -> process(value)
_ -> :noop
end
# or with if:
if value = map[:key], do: process(value)
# ❌ Nested case for multiple conditions
case fetch_user(id) do
{:ok, user} ->
case validate(user) do
{:ok, valid_user} -> save(valid_user)
{:error, reason} -> {:error, reason}
end
{:error, reason} -> {:error, reason}
end
# ✅ — with clause
with {:ok, user} <- fetch_user(id),
{:ok, valid_user} <- validate(user) do
save(valid_user)
end
# ❌ if/else for known shapes
def area(shape) do
if shape.type == :circle do
:math.pi() * shape.radius * shape.radius
else
shape.width * shape.height
end
end
# ✅ — multi-clause function with pattern matcSubscribers only
The full skill, its 1 bundled files and every download is included with every paid Complete AI plan.
Details
| Source | community |
|---|---|
| License | — |
| Risk label | safe ("critical" means the skill may run commands or touch files — read before use) |
| Files | SKILL.md |
| Added | 2026-06-16 |
