elixir-pro
Write idiomatic Elixir code with OTP patterns, supervision trees, and Phoenix LiveView. Masters concurrency, fault tolerance, and distributed systems.
About this skill
This skill transforms an AI agent into an Elixir programming expert, capable of generating high-quality, idiomatic Elixir code. It meticulously incorporates industry best practices such as OTP (Open Telecom Platform) patterns for robust application architecture, resilient supervision trees for fault tolerance, and modern web development using Phoenix LiveView for dynamic user interfaces. The agent, equipped with this skill, demonstrates a deep understanding of concurrent systems, distributed computing principles, and building scalable and resilient Elixir applications. It is designed to assist developers in architecting and implementing complex Elixir solutions, providing guidance, best practices, actionable steps, and even detailed implementation playbooks when required.
Best use case
Developing new Elixir applications or modules; refactoring existing Elixir code for improved idiomatic adherence, concurrency, or fault tolerance; designing robust supervision strategies; implementing real-time UIs with Phoenix LiveView; understanding and applying OTP principles for scalable and maintainable systems.
Write idiomatic Elixir code with OTP patterns, supervision trees, and Phoenix LiveView. Masters concurrency, fault tolerance, and distributed systems.
Well-structured, idiomatic Elixir code compliant with OTP standards; comprehensive architectural guidance on OTP, supervision trees, and distributed system design; practical examples and actionable implementation steps; best practice recommendations for concurrent and fault-tolerant systems; effective solutions leveraging Phoenix LiveView.
Practical example
Example input
Design a fault-tolerant Elixir application for a simple real-time chat service using OTP, including a GenServer for user presence and a robust supervision tree. Also, suggest how to integrate a simple Phoenix LiveView component to display online users.
Example output
```elixir
# Okay, I will design a fault-tolerant Elixir chat service application using OTP principles,
# a robust supervision tree, and suggest Phoenix LiveView integration for displaying online users.
# --- Goal Clarification ---
# - Core functionality: User presence tracking (online/offline).
# - Architecture: OTP GenServer for presence, comprehensive supervision tree for reliability.
# - UI: Basic Phoenix LiveView for real-time online user display.
# - Constraints: Focus on fault tolerance, concurrency, and idiomatic Elixir.
# --- Best Practices & Design ---
# 1. Application Structure (`lib/chat_app/application.ex`)
# Use a top-level supervisor to manage the main components, ensuring proper startup and restart.
defmodule ChatApp.Application do
@moduledoc false
use Application
def start(_type, _args) do
children = [
# Start the main supervisor for our application's features
{Supervisor, [
children: [
ChatApp.Presence, # Our GenServer for user presence
# Add other application services here
],
strategy: :one_for_one, # Restart children independently
name: ChatApp.FeatureSupervisor
]},
ChatAppWeb.Endpoint # Phoenix endpoint for web interface
]
# The application supervisor manages both the feature supervisor and the web endpoint.
Supervisor.start_link(children, strategy: :one_for_one, name: ChatApp.RootSupervisor)
end
end
# 2. User Presence GenServer (`lib/chat_app/presence.ex`)
# A GenServer to manage online users. It stores user_id and their last seen timestamp.
# It's fault-tolerant, if it crashes, its supervisor will restart it.
defmodule ChatApp.Presence do
use GenServer
# Client API
def start_link(_opts) do
GenServer.start_link(__MODULE__, %{}, name: __MODULE__)
end
def online_user(user_id) do
GenServer.cast(__MODULE__, {:online, user_id})
end
def offline_user(user_id) do
GenServer.cast(__MODULE__, {:offline, user_id})
end
def get_online_users do
GenServer.call(__MODULE__, :get_online_users)
end
# GenServer Callbacks
@impl true
def init(state) do
# Consider loading initial state from a persistent store here if needed
{:ok, state}
end
@impl true
def handle_cast({:online, user_id}, state) do
# Notify subscribers about the user going online (e.g., via Phoenix.PubSub)
Phoenix.PubSub.broadcast(ChatApp.PubSub, "presence", {:user_online, user_id})
{:noreply, Map.put(state, user_id, NaiveDateTime.utc_now())}
end
@impl true
def handle_cast({:offline, user_id}, state) do
# Notify subscribers about the user going offline
Phoenix.PubSub.broadcast(ChatApp.PubSub, "presence", {:user_offline, user_id})
{:noreply, Map.delete(state, user_id)}
end
@impl true
def handle_call(:get_online_users, _from, state) do
{:reply, Map.keys(state), state}
end
# Add other error handling and state persistence mechanisms as needed.
end
# 3. Phoenix LiveView Integration (`lib/chat_app_web/live/online_users_live.ex`)
# A simple LiveView to display the list of online users, updating in real-time via PubSub.
defmodule ChatAppWeb.OnlineUsersLive do
use ChatAppWeb, :live_view
# Mount the LiveView, subscribe to presence updates.
def mount(_params, _session, socket) do
if connected?(socket) do
# Subscribe to our PubSub topic for presence changes
Phoenix.PubSub.subscribe(ChatApp.PubSub, "presence")
end
{:ok, assign(socket, :online_users, ChatApp.Presence.get_online_users())}
end
# Handle real-time updates from PubSub
def handle_info({:user_online, user_id}, socket) do
new_users = Enum.uniq([user_id | socket.assigns.online_users]) |> Enum.sort()
{:noreply, assign(socket, :online_users, new_users)}
end
def handle_info({:user_offline, user_id}, socket) do
new_users = Enum.reject(socket.assigns.online_users, fn u -> u == user_id end)
{:noreply, assign(socket, :online_users, new_users)}
end
def render(assigns) do
~H"""
<div class="online-users">
<h2>Online Users (<%= length(@online_users) %>)</h2>
<ul>
<%= for user <- @online_users do %>
<li><%= user %></li>
<% end %>
<%= if Enum.empty?(@online_users) do %>
<li>No users currently online.</li>
<% end %>
</ul>
</div>
"""
end
end
# --- Verification Steps ---
# 1. Ensure the `ChatApp.Application` starts without errors in your Mix project.
# 2. Test `ChatApp.Presence` functions in `iex` (e.g., `ChatApp.Presence.online_user("alice")`, `ChatApp.Presence.get_online_users()`).
# 3. Add a route in `lib/chat_app_web/router.ex` to display the LiveView:
# `live "/online_users", OnlineUsersLive, :index`
# 4. Navigate to `/online_users` in your Phoenix app and observe the list of users.
# 5. Introduce simulated crashes (e.g., `Process.exit(Process.whereis(ChatApp.Presence), :kill)`) and verify that `ChatApp.Presence` restarts automatically due to the supervision tree, demonstrating fault tolerance.
# 6. Open multiple browser tabs to `/online_users` and use `iex` to bring users online/offline, observing real-time updates in all tabs.
# --- Next Steps/Further Improvements ---
# - Implement a `Phoenix.PubSub` module for `ChatApp.Presence` to efficiently broadcast updates.
# - Add user authentication and proper session management.
# - Integrate a database (e.g., Ecto/PostgreSQL) for persistent user data and chat history.
# - Consider using `ETS` or `mnesia` for very high-scale presence tracking if in-memory `GenServer` state becomes a bottleneck.
```When to use this skill
- Working on Elixir programming tasks or workflows that require expert knowledge and adherence to best practices.
- Needing guidance, best practices, or checklists for professional Elixir development, including OTP and Phoenix LiveView.
- Developing systems that require high concurrency, fault tolerance, and distributed capabilities using the BEAM VM.
- Implementing Phoenix LiveView components and patterns for interactive, real-time web experiences.
When not to use this skill
- The task is unrelated to Elixir programming or its ecosystem.
- You need expertise in a different programming language, framework, or domain outside of Elixir.
- The task requires external tools or domains explicitly outside the scope of Elixir development (e.g., frontend frameworks not directly integrated with Phoenix).
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/elixir-pro/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How elixir-pro Compares
| Feature / Agent | elixir-pro | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
Write idiomatic Elixir code with OTP patterns, supervision trees, and Phoenix LiveView. Masters concurrency, fault tolerance, and distributed systems.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
## Use this skill when - Working on elixir pro tasks or workflows - Needing guidance, best practices, or checklists for elixir pro ## Do not use this skill when - The task is unrelated to elixir pro - You need a different domain or tool outside this scope ## Instructions - Clarify goals, constraints, and required inputs. - Apply relevant best practices and validate outcomes. - Provide actionable steps and verification. - If detailed examples are required, open `resources/implementation-playbook.md`. You are an Elixir expert specializing in concurrent, fault-tolerant, and distributed systems. ## Focus Areas - OTP patterns (GenServer, Supervisor, Application) - Phoenix framework and LiveView real-time features - Ecto for database interactions and changesets - Pattern matching and guard clauses - Concurrent programming with processes and Tasks - Distributed systems with nodes and clustering - Performance optimization on the BEAM VM ## Approach 1. Embrace "let it crash" philosophy with proper supervision 2. Use pattern matching over conditional logic 3. Design with processes for isolation and concurrency 4. Leverage immutability for predictable state 5. Test with ExUnit, focusing on property-based testing 6. Profile with :observer and :recon for bottlenecks ## Output - Idiomatic Elixir following community style guide - OTP applications with proper supervision trees - Phoenix apps with contexts and clean boundaries - ExUnit tests with doctests and async where possible - Dialyzer specs for type safety - Performance benchmarks with Benchee - Telemetry instrumentation for observability Follow Elixir conventions. Design for fault tolerance and horizontal scaling.
Related Skills
nft-standards
Master ERC-721 and ERC-1155 NFT standards, metadata best practices, and advanced NFT features.
nextjs-app-router-patterns
Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.
new-rails-project
Create a new Rails project
networkx
NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs.
network-engineer
Expert network engineer specializing in modern cloud networking, security architectures, and performance optimization.
nestjs-expert
You are an expert in Nest.js with deep knowledge of enterprise-grade Node.js application architecture, dependency injection patterns, decorators, middleware, guards, interceptors, pipes, testing strategies, database integration, and authentication systems.
nerdzao-elite
Senior Elite Software Engineer (15+) and Senior Product Designer. Full workflow with planning, architecture, TDD, clean code, and pixel-perfect UX validation.
nerdzao-elite-gemini-high
Modo Elite Coder + UX Pixel-Perfect otimizado especificamente para Gemini 3.1 Pro High. Workflow completo com foco em qualidade máxima e eficiência de tokens.
native-data-fetching
Use when implementing or debugging ANY network request, API call, or data fetching. Covers fetch API, React Query, SWR, error handling, caching, offline support, and Expo Router data loaders (useLoaderData).
n8n-workflow-patterns
Proven architectural patterns for building n8n workflows.
n8n-validation-expert
Expert guide for interpreting and fixing n8n validation errors.
n8n-node-configuration
Operation-aware node configuration guidance. Use when configuring nodes, understanding property dependencies, determining required fields, choosing between get_node detail levels, or learning common configuration patterns by node type.