Agent skill

Otp Essentials

by j-morgan6 in j-morgan6/elixir-phoenix-guide

A skill your agent uses when writing GenServer, Supervisor, Task, Agent, or Registry code — init/handlecontinue, call vs cast, supervision strategies, process naming.

MITAuto-check passed

Install Otp Essentials

skills CLI
$ npx skills add j-morgan6/elixir-phoenix-guide --skill otp-essentials -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install j-morgan6/elixir-phoenix-guide otp-essentials --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/j-morgan6/elixir-phoenix-guide.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/otp-essentials .claude/skills/otp-essentials && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
otp-essentials
GitHub stars
166
Token cost
~2.6k tokens
SKILL.md length
311 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when writing GenServer, Supervisor, Task, Agent, or Registry code — init/handlecontinue, call vs cast, supervision strategies, process naming.

  • Works in 7 steps: Always use @impl true before… → Keep init/1 fast — no blocking calls, no… → Use GenServer.call for request/response,… → …
  • Writing GenServer
  • SKILL.md covers RULES — Follow these with no…, GenServer, Supervisors and Tasks, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Otp Essentials is an agent skill from j-morgan6/elixir-phoenix-guide. Use when writing GenServer, Supervisor, Task, Agent, or Registry code — init/handlecontinue, call vs cast, supervision strategies, process naming.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The licence is MIT.

When your agent uses it

  • Writing GenServer
  • Registry code — init/handlecontinue
  • Supervision strategies

Example prompts

  • “/otp-essentials”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Always use @impl true before GenServer/Agent callbacks (init, handle_call, handle_cast, handle_info, terminate)
  2. Keep init/1 fast — no blocking calls, no DB queries; use handle_continue for expensive setup
  3. Use GenServer.call for request/response, GenServer.cast for fire-and-forget — never cast when you need a result
  4. Always define a public API wrapping GenServer calls — callers should never use GenServer.call(pid, ...) directly
  5. Use Task.async/Task.await with bounded timeouts — never Task.async without a corresponding Task.await or Task.yield
  6. Name processes via Registry, not atoms — atom table is finite and never garbage collected
  7. Supervisors own process lifecycle — never start unsupervised long-running processes

What it can do on your machine

Read from SKILL.md and the folder at commit cdfddac. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are elixir).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Otp Essentials loads about 2.6k tokens when it runs. Until then it costs about 41 tokens; SKILL.md has 311 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~41
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from j-morgan6/elixir-phoenix-guide at commit cdfddac, republished under its MIT licence (© j-morgan6). 311 words, ~2,650 tokens.

Download SKILL.mdSave it as .claude/skills/otp-essentials/SKILL.md (or your agent's skills folder).
name
otp-essentials
description
Use when writing GenServer, Supervisor, Task, Agent, or Registry code — init/handle_continue, call vs cast, supervision strategies, process naming.
file_patterns
**/application.ex, **/*_server.ex, **/*_supervisor.ex, **/workers/**/*.ex
auto_suggest
true

OTP Essentials

RULES — Follow these with no exceptions

  1. Always use @impl true before GenServer/Agent callbacks (init, handle_call, handle_cast, handle_info, terminate)
  2. Keep init/1 fast — no blocking calls, no DB queries; use handle_continue for expensive setup
  3. Use GenServer.call for request/response, GenServer.cast for fire-and-forget — never cast when you need a result
  4. Always define a public API wrapping GenServer calls — callers should never use GenServer.call(pid, ...) directly
  5. Use Task.async/Task.await with bounded timeouts — never Task.async without a corresponding Task.await or Task.yield
  6. Name processes via Registry, not atoms — atom table is finite and never garbage collected
  7. 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.

elixir
# Bad — leaks GenServer implementation to callers
GenServer.call(MyApp.Cache, {:get, key})

# Good — public API hides the GenServer
defmodule MyApp.Cache do
  use GenServer

  # --- Public API ---

  def start_link(opts) do
    name = Keyword.get(opts, :name, __MODULE__)
    GenServer.start_link(__MODULE__, opts, name: name)
  end

  def get(key, server \\ __MODULE__) do
    GenServer.call(server, {:get, key})
  end

  def put(key, value, server \\ __MODULE__) do
    GenServer.cast(server, {:put, key, value})
  end

  # --- Callbacks ---

  @impl true
  def init(_opts) do
    {:ok, %{}}
  end

  @impl true
  def handle_call({:get, key}, _from, state) do
    {:reply, Map.get(state, key), state}
  end

  @impl true
  def handle_cast({:put, key, value}, state) do
    {:noreply, Map.put(state, key, value)}
  end
end
Fast Init with handle_continue

Never block in init/1. Use handle_continue for expensive setup.

elixir
# Bad — blocks the supervisor while loading data
@impl true
def init(opts) do
  data = MyApp.Repo.all(MyApp.Item)  # Blocks!
  {:ok, %{items: data}}
end

# Good — returns immediately, loads data asynchronously
@impl true
def init(opts) do
  {:ok, %{items: []}, {:continue, :load_data}}
end

@impl true
def handle_continue(:load_data, state) do
  data = MyApp.Repo.all(MyApp.Item)
  {:noreply, %{state | items: data}}
end
call vs cast
elixir
# call — synchronous, caller waits for reply (use for reads, queries)
def get_count(server \\ __MODULE__) do
  GenServer.call(server, :get_count)
end

@impl true
def handle_call(:get_count, _from, state) do
  {:reply, state.count, state}
end

# cast — asynchronous, fire-and-forget (use for writes, side effects)
def increment(server \\ __MODULE__) do
  GenServer.cast(server, :increment)
end

@impl true
def handle_cast(:increment, state) do
  {:noreply, %{state | count: state.count + 1}}
end
handle_info for External Messages

Use handle_info for messages not sent via call/cast — timers, monitors, PubSub, etc.

elixir
@impl true
def init(_opts) do
  Process.send_after(self(), :tick, 1_000)
  {:ok, %{count: 0}}
end

@impl true
def handle_info(:tick, state) do
  Process.send_after(self(), :tick, 1_000)
  {:noreply, %{state | count: state.count + 1}}
end
Error Handling in Callbacks

Handle expected errors gracefully — reply with {:error, reason} and keep the state. Let unexpected errors crash so the supervisor restarts the process.

elixir
# Expected failure — reply with an error tuple, log it, keep serving
@impl true
def handle_call(:risky_operation, _from, state) do
  case perform_operation() do
    {:ok, result} ->
      {:reply, {:ok, result}, update_state(state, result)}

    {:error, reason} ->
      Logger.error("Operation failed: #{inspect(reason)}")
      {:reply, {:error, reason}, state}
  end
end

# Unexpected failure — let it crash
@impl true
def handle_cast(:dangerous_work, state) do
  # If this raises, the supervisor restarts the process with clean state
  result = dangerous_function!()
  {:noreply, Map.put(state, :result, result)}
end

Supervisors

Supervision Strategies
elixir
# one_for_one — restart only the failed child (most common)
children = [
  {MyApp.Cache, []},
  {MyApp.Worker, []}
]
Supervisor.start_link(children, strategy: :one_for_one)

# one_for_all — restart ALL children when one fails
# Use when children depend on each other's state
Supervisor.start_link(children, strategy: :one_for_all)

# rest_for_one — restart failed child and all children started AFTER it
# Use when later children depend on earlier ones
Supervisor.start_link(children, strategy: :rest_for_one)
Application Supervision Tree
elixir
defmodule MyApp.Application do
  use Application

  @impl true
  def start(_type, _args) do
    children = [
      MyApp.Repo,
      {Phoenix.PubSub, name: MyApp.PubSub},
      MyApp.Cache,
      MyAppWeb.Endpoint
    ]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end
DynamicSupervisor for Runtime Children

Use when you need to start processes on demand, not at boot.

elixir
defmodule MyApp.RoomSupervisor do
  use DynamicSupervisor

  def start_link(init_arg) do
    DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
  end

  @impl true
  def init(_init_arg) do
    DynamicSupervisor.init(strategy: :one_for_one)
  end

  def start_room(room_id) do
    spec = {MyApp.Room, room_id: room_id}
    DynamicSupervisor.start_child(__MODULE__, spec)
  end

  def stop_room(pid) do
    DynamicSupervisor.terminate_child(__MODULE__, pid)
  end
end

Tasks

async/await for Concurrent Work
elixir
# Parallel fetch with bounded timeout
task1 = Task.async(fn -> fetch_user_profile(user_id) end)
task2 = Task.async(fn -> fetch_user_posts(user_id) end)

profile = Task.await(task1, 5_000)
posts = Task.await(task2, 5_000)
async_stream for Batch Processing
elixir
# Process items concurrently with bounded concurrency
user_ids
|> Task.async_stream(&fetch_user/1, max_concurrency: 4, timeout: 10_000)
|> Enum.map(fn {:ok, result} -> result end)
Supervised Tasks (fire-and-forget)

Start tasks under a Task.Supervisor for clean shutdown and observability. Note: Task.Supervisor.start_child/2 defaults to restart: :temporary — crashed tasks are not restarted. Pass restart: :transient if you want restarts on abnormal exit.

elixir
# Add to your supervision tree
{Task.Supervisor, name: MyApp.TaskSupervisor}

# Start a supervised task — not restarted by default (restart: :temporary)
Task.Supervisor.start_child(MyApp.TaskSupervisor, fn ->
  send_welcome_email(user)
end)

# Restart on crash — pass restart: :transient
Task.Supervisor.start_child(
  MyApp.TaskSupervisor,
  fn -> send_welcome_email(user) end,
  restart: :transient
)

Agent

Use Agent for simple state when GenServer is overkill. If you need handle_info, timeouts, or complex logic, use GenServer instead.

elixir
defmodule MyApp.Counter do
  use Agent

  def start_link(initial_value) do
    Agent.start_link(fn -> initial_value end, name: __MODULE__)
  end

  def value do
    Agent.get(__MODULE__, & &1)
  end

  def increment do
    Agent.update(__MODULE__, &(&1 + 1))
  end
end

Process Naming

Registry (preferred)
elixir
# In application supervision tree
{Registry, keys: :unique, name: MyApp.Registry}

# In GenServer start_link
def start_link(room_id) do
  GenServer.start_link(__MODULE__, room_id,
    name: {:via, Registry, {MyApp.Registry, {:room, room_id}}}
  )
end

# Lookup
def get_room(room_id) do
  case Registry.lookup(MyApp.Registry, {:room, room_id}) do
    [{pid, _}] -> {:ok, pid}
    [] -> {:error, :not_found}
  end
end
Atoms (only for singletons)
elixir
# OK — single global process
GenServer.start_link(__MODULE__, opts, name: __MODULE__)

# Bad — dynamic atom creation from user input
GenServer.start_link(__MODULE__, opts, name: String.to_atom("room_#{room_id}"))

Process Linking vs Monitoring

elixir
# Link — bidirectional, crash propagates (use in supervisors)
Process.link(pid)

# Monitor — unidirectional, receive :DOWN message (use for observation)
ref = Process.monitor(pid)

@impl true
def handle_info({:DOWN, _ref, :process, pid, reason}, state) do
  # Handle monitored process dying
  {:noreply, cleanup(state, pid)}
end

ETS for Shared Read-Heavy State

When many processes need to read the same data and writes are infrequent:

elixir
# Create table in a GenServer (owner process)
@impl true
def init(_opts) do
  table = :ets.new(:my_cache, [:named_table, :set, :public, read_concurrency: true])
  {:ok, %{table: table}}
end

# Any process can read
:ets.lookup(:my_cache, key)

# Only owner should write (or use :public carefully)
:ets.insert(:my_cache, {key, value})

Common Anti-Patterns

elixir
# Bad — bottleneck GenServer (all requests go through one process)
def get_user(id), do: GenServer.call(UserServer, {:get, id})
# Fix: Use ETS, a database, or partition work across multiple processes

# Bad — god process (one GenServer doing everything)
# Fix: Split into focused processes, each with one responsibility

# Bad — unmonitored Task.async
Task.async(fn -> do_work() end)
# no await or yield — caller loses track of work
# Fix: Always await, or use Task.Supervisor.start_child for fire-and-forget

# Bad — blocking the caller unnecessarily
def send_email(user) do
  GenServer.call(EmailServer, {:send, user})  # Waits for email to send
end
# Fix: Use cast if caller doesn't need the result
def send_email(user) do
  GenServer.cast(EmailServer, {:send, user})
end

Testing

elixir
# Start GenServer in test
test "get and put values" do
  start_supervised!({MyApp.Cache, name: :test_cache})

  assert MyApp.Cache.get(:key, :test_cache) == nil
  MyApp.Cache.put(:key, "value", :test_cache)
  assert MyApp.Cache.get(:key, :test_cache) == "value"
end

# Test with Task
test "concurrent fetch" do
  task = Task.async(fn -> MyApp.fetch_data() end)
  assert {:ok, data} = Task.await(task, 5_000)
end

See testing-essentials skill for comprehensive testing patterns.

© j-morgan6, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/otp-essentials of j-morgan6/elixir-phoenix-guide.

Open the folder on GitHubat commit cdfddac

Compare with similar skills

Otp Essentials next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Otp Essentials compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Otp Essentials this skillj-morgan6/elixir-phoenix-guide166—~2.6kAutomated safety check: PassMIT
Erlang Otp Behaviorsbenchflow-ai/skillsbench1.8k1 repos~4.5kAutomated safety check: PassApache-2.0
Essentialstrycompai/comp2k—~583Automated safety check: PassAGPL-3.0
Supervisor Review Queueanthropics/claude-for-legal9.6k3 repos~1.1kAutomated safety check: PassApache-2.0
Elixir OTP Concurrencygeorgeguimaraes/elixir-agent-tools184—~1.2kAutomated safety check: PassApache-2.0
Childcare EssentialsLeoYeAI/openclaw-master-skills2.2k—~6.4kAutomated safety check: PassMIT

Similar skills

  • Erlang Otp Behaviors

    benchflow-ai/skillsbench

    A skill your agent uses when oTP behaviors including genserver for stateful processes, genstatem for state machines, supervisors for fault tolerance, genevent for event handling, and building…

    1.8k GitHub starsUsed in 1 repo~4.5k tokens
    Auto-check passed
  • Essentials

    trycompai/comp

    Critical rules that must always be followed. An agent skill from trycompai/comp.

    2k GitHub stars~583 tokensUpdated yesterday
    Frontend & DesignAuto-check passed
  • Supervisor Review Queue

    anthropics/claude-for-legal

    Official

    Holds student work in a queue for a legal clinic professor to approve, edit-then-approve or return before anything reaches clients or courts.

    9.6k GitHub starsUsed in 3 repos~1.1k tokens
    Legal & ComplianceAuto-check passed
  • Elixir OTP Concurrency

    georgeguimaraes/elixir-agent-tools

    Guides choices among GenServer, Supervisor, Task, Registry, ETS and Broadway when designing or debugging Elixir concurrency, state and fault recovery.

    184 GitHub stars~1.2k tokensUpdated 19 days ago
    Backend & APIsAuto-check passed
  • Childcare Essentials

    LeoYeAI/openclaw-master-skills

    Practical physical childcare skills for ages 0-5. An agent skill from LeoYeAI/openclaw-master-skills.

    2.2k GitHub stars~6.4k tokensUpdated 2 mo ago
    Auto-check passed
  • Cao Supervisor Protocols

    awslabs/cli-agent-orchestrator

    Official

    Supervisor-side orchestration patterns for assign, handoff, and idle inbox delivery in CAO

    1.4k GitHub stars~1.2k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from j-morgan6/elixir-phoenix-guide

All 19 skills in this repo
  • Code Quality

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when refactoring for duplication, complexity, or dead code — includes the plugin's on-demand analysis scripts.

    166 GitHub stars~1.4k tokensUpdated 3 mo ago
    Auto-check passed
  • Deployment Gotchas

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when preparing releases or deployment config — runtime.exs vs compile-time config, release migrations, PHXHOST/PHXSERVER, assets, health checks.

    166 GitHub stars~2.6k tokensUpdated 3 mo ago
    Auto-check passed
  • Ecto Changeset Patterns

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when a resource needs multiple changesets (registration vs update), conditional validation, field transforms, or uniqueness validation — changeset composition.

    166 GitHub stars~2.1k tokensUpdated 3 mo ago
    Auto-check passed
  • Ecto Essentials

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when defining schemas, writing queries, or creating migrations — schema design, Repo usage, indexes, query composition.

    166 GitHub stars~2.2k tokensUpdated 3 mo ago
    Auto-check passed
  • Ecto Nested Associations

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when a form or operation manages parent and child records together — castassoc/castembed, onreplace, Ecto.Multi across tables, FK cascade design.

    166 GitHub stars~2.2k tokensUpdated 3 mo ago
    Auto-check passed
  • Elixir Essentials

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when writing or refactoring core Elixir — pattern matching, case/cond/with, pipes, {:ok, }/{:error, } contracts.

    166 GitHub stars~2.2k tokensUpdated 3 mo ago
    Auto-check passed

Questions about Otp Essentials

What does Otp Essentials do?

A skill your agent uses when writing GenServer, Supervisor, Task, Agent, or Registry code — init/handlecontinue, call vs cast, supervision strategies, process naming. Otp Essentials is an agent skill from j-morgan6/elixir-phoenix-guide. Use when writing GenServer, Supervisor, Task, Agent, or Registry code — init/handlecontinue, call vs cast, supervision strategies, process naming.

When should I use Otp Essentials?

Otp Essentials fits situations like: writing GenServer; registry code — init/handlecontinue; supervision strategies.

How do I install Otp Essentials in Claude Code?

Run `npx skills add j-morgan6/elixir-phoenix-guide --skill otp-essentials -a claude-code`. Or copy the skill folder (skills/otp-essentials in j-morgan6/elixir-phoenix-guide) into .claude/skills/otp-essentials in your project. Claude Code loads it when a task matches its description.

How do I install Otp Essentials in Codex?

Run `npx skills add j-morgan6/elixir-phoenix-guide --skill otp-essentials -a codex`. Or copy the skill folder (skills/otp-essentials in j-morgan6/elixir-phoenix-guide) into .agents/skills/otp-essentials in your project. Codex loads it when a task matches its description.

Can I use Otp Essentials in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add j-morgan6/elixir-phoenix-guide --skill otp-essentials -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/otp-essentials, .gemini/skills/otp-essentials, .github/skills/otp-essentials and .opencode/skills/otp-essentials in your project.

What does Otp Essentials need to run?

SKILL.md names no scripts, command-line tools or credentials: Otp Essentials is instructions for the agent only.

Does Otp Essentials access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Otp Essentials safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Otp Essentials use?

Otp Essentials is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Otp Essentials use?

About 2.6k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Otp Essentials?

Skills that share tags, products or a category with Otp Essentials: Erlang Otp Behaviors (benchflow-ai/skillsbench, 1.8k stars), Essentials (trycompai/comp, 2k stars), Supervisor Review Queue (anthropics/claude-for-legal, 9.6k stars) and Elixir OTP Concurrency (georgeguimaraes/elixir-agent-tools, 184 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Otp Essentials?

j-morgan6 (a GitHub user) maintains it in j-morgan6/elixir-phoenix-guide, which has 166 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on July 6, 2026.

Source: j-morgan6/elixir-phoenix-guide on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.