erlang-otp-behaviors

Document OTP patterns for gen_server, gen_statem, and supervisors in Erlang.

4|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/GeneralReasoning/env-skillsbench --skill erlang-otp-behaviors-generalreasoning
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: erlang-otp-behaviors
Source: https://github.com/GeneralReasoning/env-skillsbench/tree/main/fix-erlang-ssh-cve/environment/skills/erlang-otp-behaviors
Command: npx skills add https://github.com/GeneralReasoning/env-skillsbench --skill erlang-otp-behaviors-generalreasoning

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Erlang developers often struggle to implement reliable, scalable processes. This skill documents and exemplifies OTP patterns like gen_server, gen_statem, supervisors, and related patterns to help teams build fault-tolerant systems.

Core Features & Use Cases

  • Gen_server: stateful servers with client-server interfaces and callbacks.
  • Gen_statem: complex state machines with explicit transitions.
  • Supervisors: fault-tolerant process trees and automatic recovery.
  • General OTP packaging and application behavior for production reliability.

Use cases include building a stateful service, a managed event processor, or a fault-tolerant subsystem within a larger Erlang application.

Quick Start

Instantiate a gen_server example and call increment to observe the internal state update.

Frequently Asked Questions about erlang-otp-behaviors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a stateful server using gen_server in Erlang?

A gen_server implements a stateful server by defining callback modules for handling client-server requests and maintaining internal state. This OTP pattern provides standardized API usage, lifecycle management, and reliable stateful services for Erlang production systems.

How does a supervisor provide fault tolerance for Erlang processes?

An Erlang supervisor provides fault tolerance by building process trees and automatically recovering crashed child processes. This OTP behavior ensures system reliability by restarting failed processes according to configured supervision strategies within production applications.

When should I use gen_statem instead of gen_server for complex state machines?

Use gen_statem for complex state machines requiring explicit state transitions beyond simple gen_server callback models. This OTP behavior handles intricate event processing and defined state changes, making it suited for managed event processors and complex stateful logic.

What are the best practices for packaging Erlang OTP applications for production?

Best practices for OTP application packaging involve using application behavior to structure systems into supervised process trees. This ensures production reliability through standardized lifecycle callbacks, fault-tolerant subsystems, and proper application behavior implementation for Erlang applications.

Do I need to understand OTP behaviors to build fault-tolerant Erlang apps?

Understanding OTP behaviors like gen_server, gen_statem, and supervisors is essential for building fault-tolerant Erlang apps. These patterns provide the lifecycle callbacks, automatic recovery, and process isolation required to implement robust, scalable production systems.