🎯

erlang

🎯Skill
g1joshi/agent-skills5 Installs9Last Updated Feb 10, 2026

Installation

$npx skills add g1joshi/agent-skills --skill erlang

Run it in a terminal; it asks which AI coding tools to install it for (Claude Code, Codex, Cursor and more).

Uses skills.sh Β· Node.js 22.20+

After installing

Ask for related work and the agent uses it on its own, or call it yourself.

Run it (Claude Code)/erlang
Install by hand

Copy the whole skill folder from GitHub to the place below. Copying only SKILL.md can leave out files the skill uses.

Open the skill folder β†’
  • This project .claude/skills/erlang/
  • All projects ~/.claude/skills/erlang/

These paths are for Claude Code. For other tools, the command above puts it in the right place.

Expert Erlang programming assistance covering BEAM virtual machine, actor concurrency, supervision trees, and OTP. Use when developing telecom systems, distributed databases, or messaging backbones.

Erlang

Erlang is a battle-tested functional programming language designed for massive concurrency, high fault-tolerance, and distributed telecom systems on the BEAM virtual machine.

When to Use

  • Nine-Nines High Availability Infrastructure: Telecommunications, payment switching networks, and messaging systems requiring 99.9999999% uptime.
  • Massively Scalable Chat Systems (WhatsApp/ejabberd): Connecting millions of concurrent WebSocket and XMPP connections simultaneously.
  • Hot Code Swapping: Upgrading running production systems and deploying bugfixes without stopping the server.
  • Low-Latency Distributed Clusters (OTP): Building distributed node clusters with built-in node discovery and heartbeats.

Quick Start

-module(hello).
-export([start/0]).

start() ->
    io:format("Hello from Erlang/OTP!~n").

Core Concepts

Open Telecom Platform (OTP) GenServer Behavior

Standardized generic client-server framework managing state, calls, and asynchronous casts:

-module(counter_server).
-behaviour(gen_server).

-export([start_link/0, increment/0, get_count/0]).
-export([init/1, handle_call/3, handle_cast/2, terminate/2]).

start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
increment()  -> gen_server:cast(?MODULE, inc).
get_count()  -> gen_server:call(?MODULE, get).

init([]) -> {ok, 0}.

handle_call(get, _From, Count) -> {reply, Count, Count}.
handle_cast(inc, Count)        -> {noreply, Count + 1}.
terminate(_Reason, _State)    -> ok.

Pattern Matching Function Clauses

Functions declare multiple clauses matching input parameters structurally:

-module(finance).
-export([tax/2]).

tax(Amount, {state, "CA"}) -> Amount * 0.0825;
tax(Amount, {state, "NY"}) -> Amount * 0.08875;
tax(Amount, {state, _Other}) -> Amount * 0.05.

Hot Code Upgrades

Reloads module code live in memory while preserving active process state:

% Compile and reload module in running Erlang VM
c(my_worker).

Common Patterns

Simple Actor Message Passing Loop

Problem: Managing asynchronous message queues and state without threads and mutexes.

Solution: Use tail-recursive receive loops:

-module(actor_counter).
-export([loop/1, start/0]).

start() ->
    spawn(fun() -> loop(0) end).

loop(Count) ->
    receive
        {increment, N} ->
            loop(Count + N);
        {get, Sender} ->
            Sender ! {current_count, Count},
            loop(Count);
        stop ->
            ok
    end.

Best Practices

Do:

  • Adhere Strictly to OTP Principles: Build applications around standard OTP behaviors (gen_server, gen_statem, supervisor).
  • Use Erlang Term Storage (ETS) for Shared Cache: Leverage ETS tables for high-concurrency in-memory read lookups across processes.
  • Run Dialyzer for Static Type Analysis: Add -spec type specifications to all public functions and run Dialyzer in CI.
  • Monitor BEAM Metrics via Telemetry: Track process count, reductions, and scheduler utilization.

Don't:

  • Register thousands of named processes: Atom tables are global and un-garbage-collected; dynamic atoms risk crashing the VM.
  • Use defensive try/catch everywhere: Let processes crash on unexpected errors; let supervisors reset them to known good state.
  • Block schedulers with non-yielding C-NIFs: Keep C Native Implemented Functions (NIFs) under 1ms or use dirty schedulers.

Troubleshooting

ErrorCauseSolution
{badmatch, Value}Pattern matching failed on = or function argument.Verify return structure and provide clauses for all expected outcomes.
noproc: process not aliveSending a message or RPC call to a process PID that already exited.Verify supervisor restart strategies and link/monitor processes with monitor/2.
function_clause: no function clause matchingInvoking function with arguments that don't match any head clause.Check argument types, arity, and guard conditions.

References

More from this repository10