elixir-otp-patterns

Apply OTP patterns to build concurrent Elixir applications with GenServer, Supervisor, and Task.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill elixir-otp-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: elixir-otp-patterns
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-elixir/skills/elixir-otp-patterns
Command: npx skills add https://github.com/TheBushidoCollective/han --skill elixir-otp-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

OTP patterns like GenServer, Supervisor, and Task enable concurrent, fault-tolerant Elixir apps.

Core Features & Use Cases

  • GenServer basics and advanced patterns
  • Supervisor strategies and dynamic supervision
  • Agents, Tasks, and dynamic workers

Quick Start

Create a simple GenServer counter and a Supervisor tree to manage it.

Frequently Asked Questions about elixir-otp-patterns

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

FAQPage Schema
How do I build fault-tolerant concurrent applications in Elixir?

Use OTP patterns like GenServer, Supervisor, and Task to build fault-tolerant concurrent applications. GenServer manages state and handles messages, Supervisor monitors and restarts workers on failure, and Task handles asynchronous workloads. Together they create self-healing systems that isolate failures and maintain reliability.

What is a GenServer and how do I implement one?

GenServer is an Elixir abstraction for building stateful, message-driven processes. Implement it by defining callbacks like init, handle_call, and handle_cast to manage initialization, synchronous requests, and asynchronous messages. GenServer enforces lifecycle patterns that prevent common concurrency bugs.

How do Supervisor strategies manage worker processes?

Supervisor strategies define restart policies when workers fail. One-for-one restarts only the failed worker; one-for-all restarts all children; rest-for-one restarts the failed worker and those started after it. Choose based on dependencies between workers to contain failures appropriately.

When should I use Agent versus GenServer for state management?

Use Agent for simple, stateful data that needs get/update operations without complex message handling. Use GenServer when you need rich message handling, timeouts, or complex business logic alongside state. Agent is lighter; GenServer offers more control and observability.

How do I handle asynchronous work reliably with Task supervision?

Supervise Tasks through a Supervisor or DynamicSupervisor to ensure failed async work doesn't crash your application. Task-based workers are monitored and restarted on failure, letting you pipeline async workloads safely within your OTP tree.

What happens if a GenServer callback times out or crashes?

GenServer enforces timeout handling through the timeout option in callbacks. If a process crashes, its Supervisor detects the failure and applies the configured restart strategy—typically restarting the process to recover. Errors in callbacks are contained and logged.