elixir
What it does
This guide teaches how to write more efficient and clear code in the Elixir programming language. It shows better ways to organize code, handle errors, and use language features.
When to use it
- βWhen learning Elixir and wanting to write high-quality code.
- βWhen reviewing Elixir code to make it more readable.
- βWhen struggling to write Elixir code idiomatically.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/super-code/elixir/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow can I write a function that checks if a number is even more efficiently in Elixir?β
5 new skills a week. 1 minute to read.
How it works
The guide compares common approaches with code examples, showing how to use features like 'pattern matching' and the 'pipe' operator to simplify logic and avoid errors.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
- Pipe Operator & Transforms
- Processes & OTP
- Error Handling
- Collections & Enum
- Structs & Protocols
- Anti-patterns specific to Elixir/Erlang
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 match
def area(%{type: :circle, radius: r}), do: :math.pi() * r * r
def area(%{type: :rect, width: w, height: h}), do: w * h
# β Checking type at runtime
def process(x) do
if is_integer(x) and x > 0 do
x * 2
end
end
# β
β guard clause
def process(x) when is_integer(x) and x > 0, do: x * 2
def process(_), do: {:error, :invalid_input}
2. Pipe Operator & Transforms {#pipes}
# β Nested function calls
String.trim(String.downcase(String.replace(input, ~r/\s+/, " ")))
# β
input
|> String.replace(~r/\s+/, " ")
|> String.downcase()
|> String.trim()
# β Pipe into anonymous function awkwardly
data
|> (fn x -> x * 2 end).()
# β
β use then/1 or named function
data
|> then(&(&1 * 2))
# or better: extract a named function
data |> double()
# β Single-step pipe (no gain in readability)
result = list |> Enum.count()
# β
β direct call for single operation
result = Enum.count(list)
Pipe when 2+ transforms. Direct call for single operation. First arg flows through pipe.
3. Processes & OTP {#otp}
# β Raw spawn for stateful process
pid = spawn(fn -> loop(%{count: 0}) end)
send(pid, {:increment})
# β
β GenServer for stateful processes
defmodule Counter do
use GenServer
def start_link(init \\ 0), do: GenServer.start_link(__MODULE__, init)
def increment(pid), do: GenServer.call(pid, :increment)
@impl true
def init(count), do: {:ok, count}
@impl true
def handle_call(:increment, _from, count), do: {:reply, count + 1, count + 1}
end
# β Spawning without linking (orphan process on crash)
spawn(fn -> do_work() end)
# β
β Task for fire-and-forget with supervision
Task.start(fn -> do_work() end)
# or for awaitable result:
task = Task.async(fn -> do_work() end)
result = Task.await(task)
# β Manual process registry
Process.register(self(), :my_worker)
# β
β use Registry or named GenServer
{:ok, _} = Registry.start_link(keys: :unique, name: MyRegistry)
GenServer.start_link(Worker, arg, name: {:via, Registry, {MyRegistry, :my_worker}})
# β try/catch in GenServer (breaks supervision)
def handle_call(:work, _from, state) do
try do
result = risky_operation()
{:reply, result, state}
catch
_ -> {:reply, :error, state}
end
end
# β
β let it crash; supervisor restarts
def handle_call(:work, _from, state) do
result = risky_operation()
{:reply, result, state}
end
"Let it crash" β supervisors handle recovery. Don't defensively catch inside GenServers.
4. Error Handling {#errors}
# β Raising for expected failures
def find_user(id) do
case Repo.get(User, id) do
nil -> raise "User not found"
user -> user
end
end
# β
β tagged tuples for expected outcomes
def find_user(id) do
case Repo.get(User, id) do
nil -> {:error, :not_found}
user -> {:ok, user}
end
end
# β Ignoring error tuple
{:ok, result} = might_fail() # crashes on {:error, _}
# β
β handle both cases
case might_fail() do
{:ok, result} -> process(result)
β¦
FAQ
What is 'pattern matching'?
It's a way to elegantly check and extract data from code structures, like checking if a map has a specific key and getting its value at the same time.
What is the 'pipe' operator (`|>`)?
It allows chaining function calls readably, passing the result of one function as an argument to the next, from top to bottom.
What does 'Let it crash' mean?
It's a philosophy in Elixir where, instead of trying to catch every possible error, you let the program fail in a controlled way, and a supervision system restarts the necessary parts.
Details
Original description by the author
Language-specific super-code guidelines for elixir.
Popularity
- GitHub stars
- 48k
- Ranking position
- #5891
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.