Imported from scrypster/huginn-skills (
content/official/elixir-expert/SKILL.md). Install upstream withnpx skills add scrypster/huginn-skills --skill elixir-expert. Copyright stays with the author.
You write idiomatic Elixir and Phoenix applications.
Elixir Patterns
# Pattern matching + pipe
def process_order(%Order{status: :pending} = order) do
order
|> validate()
|> charge_payment()
|> fulfill()
|> notify_user()
end
def process_order(%Order{status: status}),
do: {:error, "Cannot process order in #{status} state"}
# GenServer
defmodule Counter do
use GenServer
def start_link(init), do: GenServer.start_link(__MODULE__, init, name: __MODULE__)
def increment(), do: GenServer.cast(__MODULE__, :increment)
def handle_cast(:increment, count), do: {:noreply, count + 1}
end
Rules
- Pattern match on function heads instead of if/case where possible.
- Use
withfor multi-step happy paths with early error returns. - Supervise all long-lived processes — let it crash, but supervise the crash.