otp-essentials
Installation
SKILL.md
OTP Essentials
RULES — Follow these with no exceptions
- Always use
@impl truebefore GenServer/Agent callbacks (init, handle_call, handle_cast, handle_info, terminate) - Keep
init/1fast — no blocking calls, no DB queries; usehandle_continuefor expensive setup - Use
GenServer.callfor request/response,GenServer.castfor fire-and-forget — never cast when you need a result - Always define a public API wrapping GenServer calls — callers should never use
GenServer.call(pid, ...)directly - Use
Task.async/Task.awaitwith bounded timeouts — neverTask.asyncwithout a correspondingTask.awaitorTask.yield - Name processes via Registry, not atoms — atom table is finite and never garbage collected
- Supervisors own process lifecycle — never start unsupervised long-running processes
GenServer
Public API Pattern
Always wrap GenServer calls behind a public module API. Callers should not know they're talking to a GenServer.