Skip to content
Skills Library
Programming · Building & coding

erlang

/erlang

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

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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

Original author description

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

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 123 lines, 517 words
SKILL.md preview
---
name: erlang
description: 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

```erlang
-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:

```erlang
-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:

```erlang
-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:

```erlang
% 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:

```erlang
-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

| Error                                          | Cause                                                               | Solution                                                                          |
| :--------------------------------------------- | :------------------------------------------------------------------ | :-------------------------------------------------------------------------------- |
| `{badmatch, Value}`                            | Pattern matching failed on `=` or function argument.                | Verify return structure and provide clauses for all expected outcomes.            |
| `noproc: process not alive`                    | Sending 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 matching` | Invoking function with arguments that don't match any head clause.  | Check argument types, arity, and guard conditions.                                |

## References

- [Erlang.org](https://www.erlang.org/)

Versions

RepositoryScoreLicence
This page · G1Joshi/Agent-Skills100MIT
dkbnull/hello-skill86MIT

Database snapshot: 13.11.2026 · package version 8b516e177b18 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100erlang-distribution
    Use when erlang distributed systems including node connectivity, distributed processes, global name registration, distributed supervision, network partitions, and building fault-tolerant multi-node applications on the BEAM VM.
  • 95erlang-otp-behaviors
    Use when oTP behaviors including gen_server for stateful processes, gen_statem for state machines, supervisors for fault tolerance, gen_event for event handling, and building robust, production-ready Erlang applications with proven patterns.
  • 95elixir
    Use this skill when the user asks about Elixir build tools, Mix, OTP, Phoenix, Ecto, supervision trees, concurrency, testing, or production deployment. Focus on BEAM/Erlang VM, tooling, and ecosystem — not syntax.
  • 100erlang-actor-model-fault-tolerance
    Use this skill when designing distributed Erlang architectures adhering to the 'let it crash' philosophy and process supervision trees.
  • 90elixir-pro
    Write idiomatic Elixir code with OTP patterns, supervision trees, and Phoenix LiveView. Masters concurrency, fault tolerance, and distributed systems. Use for Elixir refactoring, OTP design, or complex BEAM optimizations.
  • 100otp
    Guide for OTP and Elixir concurrency. Use when implementing GenServers, designing supervision trees, or building fault-tolerant concurrent systems.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.