Guide for structuring and reviewing Erlang/OTP applications with `application`, `supervisor`, and `gen_server` behaviours, supervision trees, child specs, restart strategies, and crash/restart semantics. Use when designing, implementing, reviewing, or debugging Erlang services that should follow OTP principles such as process isolation, let-it-crash failure handling, and supervisor-managed recovery.
Use this skill to design or review Erlang systems as OTP applications rather than ad hoc process collections. Prefer small isolated processes, explicit supervision trees, and failure handling that crashes fast on unexpected errors and lets supervisors restore healthy state.
Model the system in this order:
application callback module: start the top-level supervisor only.gen_serverRead references/structure.md when deciding how to break a service into supervisors, workers, registries, or helper modules.
Assume unexpected errors should crash the current process. Do not bury faults behind catch-all error handling unless the failure is expected and part of the module contract.
Use supervisors to recover:
one_for_one when children are largely independent.rest_for_one when later children depend on earlier ones.one_for_all only when the whole sibling group must restart together.permanent, transient, and temporary child restart modes to express process intent.Read references/failure-model.md when deciding how processes should fail, restart, shut down, or escalate errors.
Prefer:
gen_server for stateful request/response services, resource ownership, and serialized access to mutable process state.supervisor for restart policy and child lifecycle management.Avoid:
gen_server that owns unrelated responsibilities.{error, Reason} for programmer bugs.Use the starter template in assets/rebar3-otp-template for new services. It provides:
rebar.config.app.srcgen_server workerTo materialize a copy with your application name, run:
python3 scripts/scaffold_rebar3_otp_app.py my_app /tmp/my_app
The script copies the template and rewrites myapp placeholders in file names and file contents.
When using this skill for implementation or review: