Skip to content
Back to skills

Elixir Phoenix

ASecurity

Elixir and Phoenix development guidelines with critical language-specific gotchas. Use when writing Elixir code, Phoenix applications, or Mix tasks. Prevents common mistakes with list access, variable rebinding, struct access, and OTP patterns that cause subtle bugs or compilation errors.

  • 666 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 8, 2026
developmentgoexpress

Works with

  • cli

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill elixir-phoenix --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Elixir Phoenix?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Elixir Phoenix
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-elixir-phoenix/badge)](https://www.skillsdirectory.com/skills/majiayu000-elixir-phoenix)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: elixir-phoenix
description: Elixir and Phoenix development guidelines with critical language-specific gotchas. Use when writing Elixir code, Phoenix applications, or Mix tasks. Prevents common mistakes with list access, variable rebinding, struct access, and OTP patterns that cause subtle bugs or compilation errors.
---

# Elixir/Phoenix Guidelines

## Critical Elixir Gotchas

### List Access

Lists do NOT support index-based access syntax. Never use `list[i]`.

```elixir
# ❌ INVALID - will not compile
mylist = ["blue", "green"]
mylist[0]

# ✅ CORRECT
Enum.at(mylist, 0)
```

### Block Expression Rebinding

Variables are immutable but can be rebound. Block expressions (`if`, `case`, `cond`) must bind results externally:

```elixir
# ❌ INVALID - rebinding inside block has no effect outside
if connected?(socket) do
  socket = assign(socket, :val, val)
end

# ✅ CORRECT - bind the block result
socket =
  if connected?(socket) do
    assign(socket, :val, val)
  end
```

### Struct Access

Never use map access syntax on structs—they don't implement Access behaviour:

```elixir
# ❌ INVALID
changeset[:field]

# ✅ CORRECT
Ecto.Changeset.get_field(changeset, :field)
my_struct.field
```

### Module Nesting

Never nest multiple modules in the same file—causes cyclic dependencies and compilation errors.

## Naming Conventions

- Predicate functions: end with `?`, not `is_` prefix
  - `valid?` not `is_valid`
  - Reserve `is_thing` for guards only
- Avoid `String.to_atom/1` on user input (memory leak risk)

## OTP Patterns

Primitives like `DynamicSupervisor` and `Registry` require names in child specs:

```elixir
# In supervision tree
{DynamicSupervisor, name: MyApp.MyDynamicSup}

# Then use the name
DynamicSupervisor.start_child(MyApp.MyDynamicSup, child_spec)
```

## Concurrency

Use `Task.async_stream/3` for concurrent enumeration with back-pressure:

```elixir
collection
|> Task.async_stream(&process/1, timeout: :infinity)
|> Enum.to_list()
```

## Date/Time

Use standard library (`Time`, `Date`, `DateTime`, `Calendar`). Only add `date_time_parser` for parsing if needed.

## Mix Guidelines

- Read task docs first: `mix help task_name`
- Debug test failures: `mix test test/my_test.exs` or `mix test --failed`
- Avoid `mix deps.clean --all` unless absolutely necessary

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.