otp-patterns

Provide reusable GenServer, Supervisor, and Application patterns for Elixir applications.

1|1|Updated Jan 3, 2026
One-click install
npx skills add https://github.com/layeddie/ai-rules --skill otp-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: otp-patterns
Source: https://github.com/layeddie/ai-rules/tree/main/skills/otp-patterns
Command: npx skills add https://github.com/layeddie/ai-rules --skill otp-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Streamline building reliable Elixir processes by providing reusable OTP patterns for GenServer, Supervisors, and Applications, helping teams standardize architectures and reduce boilerplate.

Core Features & Use Cases

  • GenServer pattern templates for stateful servers with clear client/server APIs.
  • Supervisor patterns including One-for-One and Dynamic Supervisor to improve fault tolerance and scalability.
  • Guidelines and anti-patterns to prevent common OTP pitfalls and ensure robust design.
  • Practical, copy-ready examples you can adapt to real Elixir projects.

Quick Start

Provide a simple Elixir module scaffold by selecting GenServer or one of the Supervisor templates from this skill and adapt it to your project.

Frequently Asked Questions about otp-patterns

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

FAQPage Schema
How do I structure a GenServer in Elixir with clear client and server APIs?

GenServer patterns in Elixir separate client API functions from server callback implementations to manage stateful process lifecycles and reduce boilerplate. This approach ensures clear process communication and standard callback handling.

What is the best way to set up Elixir Supervisor trees for fault tolerance?

Setting up Elixir Supervisor trees requires choosing One-for-One or Dynamic Supervisor strategies to manage process lifecycles and restart behaviors. This establishes fault tolerance by isolating failures and automatically restarting crashed processes within the supervision tree.

When do I need a Dynamic Supervisor instead of a standard Supervisor in Elixir?

A Dynamic Supervisor is needed in Elixir when your application requires starting and managing an unknown number of processes at runtime. Unlike standard Supervisors with static children, Dynamic Supervisors allow scalable process management for varying workloads.

What are common OTP anti-patterns to avoid when building Elixir applications?

Common OTP anti-patterns in Elixir include linking processes outside supervision trees, blocking GenServer callbacks with heavy computations, and mishandling state. Following standard Application and Supervisor guidelines prevents these pitfalls and ensures robust fault-tolerant design.

Can I use these OTP supervision patterns in large Elixir codebases?

Yes, these OTP supervision patterns apply across both small and large Elixir codebases. They provide reusable architecture templates for GenServer and Application lifecycles that standardize service design and improve fault tolerance at any scale.

Why does my Elixir GenServer crash without restarting under its Supervisor?

An Elixir GenServer failing to restart under its Supervisor usually indicates incorrect supervision tree wiring or a restart strategy mismatch. Verifying standard Supervisor patterns and child specifications ensures proper fault tolerance and automatic process recovery.