Joser

Joser

Sharing My Claude Code Plugin for Elixir Development

Claude Code Plugin for Elixir: Custom Skills and Hooks for Better Code

Quality

I’ve been experimenting with Claude Code for Elixir development and built a
custom plugin to improve code quality. To test whether it actually makes a
difference, I built the same Phoenix LiveView application twice once with
minimal configuration and once with the full plugin.

The Experiment

I created an image gallery application with Phoenix LiveView featuring:

  • Image uploads with progress tracking
  • Folder organization
  • Tab-based navigation
  • Responsive TailwindCSS UI
  • Local file storage with PostgreSQL metadata

Build 1 (Baseline): Minimal configuration, just project guidelines and
specs
Build 2 (Plugin): Custom skills, hooks, agent docs, and comprehensive
project documentation

What’s in the Plugin?

4 Custom Skills:

  • Elixir patterns (pattern matching, pipe operators, with statements)
  • Phoenix LiveView (lifecycle, uploads, streams)
  • Ecto database (schemas, changesets, queries)
  • Error handling (tagged tuples, error patterns)

5 Validation Hooks:

  • Warn on nested if/else (prefer pattern matching)
  • Block hardcoded config values (require Application.get_env/2)
  • Warn on Enum.map |> Enum.filter chains
  • Block missing @impl true on callbacks
  • Warn on string concatenation in loops

Agent Documentation:

  • Project structure and context boundaries
  • LiveView implementation checklists
  • Ecto conventions and best practices
  • Testing guides

The Results

Metric Build 1 (Baseline) Build 2 (Plugin)
Lines of Code ~550 ~2,000+ (with tests)
Automated Tests 0 46 tests
Test Coverage Manual only 28/28 context tests passing
Credo Score Not run Excellent (7 minor issues)
Convention Adherence Good Excellent

Where the Plugin Excelled

1. Comprehensive Testing
Build 2 included 46 automated tests covering all context operations, edge
cases, and error handling from the start.

2. Better Code Quality
Consistent pattern matching, proper pipe operator usage, tagged tuples for
error handling, and @impl true on all callbacks.

3. Idiomatic Elixir
The plugin encouraged idiomatic patterns throughout:

# Pattern matching over if/else
def process({:ok, result}), do: transform(result)
def process({:error, reason}), do: handle_error(reason)

# with statements for multi-step operations
def create_image_with_folder(attrs, folder_id) do
  with {:ok, folder} <- get_folder(folder_id),
       {:ok, image} <- create_image(attrs) do
    {:ok, %{image: image, folder: folder}}
  end
end

Important Limitation

Both builds required manual testing to catch functional issues. The plugin
helps write better code with proper patterns and conventions, but it cannot
replace human validation of feature functionality.

The Verdict

The plugin produces higher-quality, more maintainable code with better test
coverage. If you're building Elixir applications professionally, the
investment is worth it.

Try It Yourself

The plugin configuration is available on GitHub:

https://github.com/j-morgan6/elixir-claude-optimization

The package includes:
- Skills for Elixir patterns, LiveView, Ecto, and error handling
- Hooks that enforce conventions and warn about anti-patterns
- Agent documentation for project structure and testing
- Sample CLAUDE.md for project setup

This is a one time investment that's reusable across all your Elixir projects.
 I'd love to hear your thoughts or experiences with AI-assisted Elixir
development!

Most Liked

Joser

Joser

v2.3.0 adds five new skills and six security hooks.

The plugin now covers 19 skills across security, deployment, channels, telemetry, and JSON APIs alongside the existing LiveView, Ecto, and OTP coverage. The new security hooks run as you write code, blocking SQL injection, atom exhaustion, and open redirects, and warning on raw/1 usage, sensitive data in logs, and timing-unsafe comparisons.

New skills:

  • security-essentials - 7 rules: atom exhaustion, SQL injection, XSS, open redirects, sensitive logging, timing attacks, dependency auditing
  • deployment-gotchas - 7 rules: runtime.exs, release migrations, PHX_HOST/PHX_SERVER, asset deployment, secrets, health endpoints, log levels
  • phoenix-channels-essentials - 6 rules: socket auth, topic authorization, handle_in/push/broadcast, Presence, testing
  • telemetry-essentials - 6 rules: structured logging, handler attachment, Ecto telemetry events, LiveDashboard, metadata tagging
  • phoenix-json-api - 7 rules: :api pipeline, FallbackController, pagination, URL versioning, Bearer token auth, json/2

New security hooks:

  • atom-from-user-input (Blocking) - String.to_atom/1 on user input
  • unparameterized-sql-fragment (Blocking) - String interpolation in Ecto fragment
  • unsafe-redirect (Blocking) - Redirect to user-controlled URLs
  • raw-html-warning (Warning) - raw/1 usage
  • sensitive-logging (Warning) - password/token/secret in Logger calls
  • timing-unsafe-compare (Warning) - == with tokens/secrets

Plugin at a glance:

  • 19 skills: Elixir, LiveView, Ecto, OTP, uploads, testing, auth, nested associations, changesets, PubSub, code quality, security, deployment, channels, telemetry, JSON API, authorization, auth customization, LiveView auth
  • 27 hooks: real-time blocking and warnings
  • 4 agent docs: detailed reference for complex tasks

GitHub: GitHub - j-morgan6/elixir-phoenix-guide · GitHub

Joser

Joser

v1.3.0 adds one thing: a testing-essentials skill.

The plugin now has 5 skills. The new one activates before any _test.exs file and enforces 8 testing rules covering DataCase/ConnCase setup, fixture patterns, LiveView and
context test skeletons, and a light TDD workflow.

All 4 existing skills now route to testing-essentials when you’re working on test files. The testing-guide.md agent doc was refactored into a deep reference so there’s no
duplication between it and the skill.

Plugin at a glance:

  • 5 skills: Elixir, LiveView, Ecto, uploads, testing
  • 10 hooks: real-time blocking/warnings for @impl, hardcoded paths, nested if/else, etc.
  • 4 agent docs: detailed reference for complex tasks

Install / update:

/plugin marketplace add j-morgan6/elixir-phoenix-guide
/plugin

Already installed? Open /plugin and update from the menu.

GitHub: GitHub - j-morgan6/elixir-phoenix-guide · GitHub

Where Next?

Popular in AI / LLMs Top

DaAnalyst
Note: Not a strictly Elixir question but relates to us as well. A year or so ago I asked Grok (or ChatGPT, can’t remember) what would ha...
New
New
New
Cheezy
I am using Claude Remote Control for the first time this morning. AMAZING! I’m running one remote session on my iPad while running anothe...
New
DaAnalyst
Claude is really good. It has definitely become an indispensable part of my toolkit. Maybe even the most indispensable after the OS itsel...
New
DaAnalyst
Exactly. A bit off topic, but I think the issue with the machines is they don’t bear any consequences. And even if they did one day, the...
New
NickGnd
Hey :waving_hand: Tidewave has just been announced by José Valim :fire: Watch Tidewave transform Claude Desktop into an agent by runni...
New
dogweather
First, the downsides. I periodically fire the AI. :smiling_face_with_tear: ^^ This was earlier today in Cursor AI, working with “Clau...
New
nickurban
Cursor Cloud Agents are quite good at writing Elixir now, but only with a custom configuration. It took me a while to get this working p...
New
DaAnalyst
Just saw a link to this on Zerohedge: It’s not AI. It’s a controlled lab-grown HI (Human Intelligence) currently at ~800K ...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31307 143
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement