From elixir-phoenix-guide
Detects code duplication (>70% similarity), ABC complexity (>30), unused private functions, and duplicated HEEx templates in Elixir projects. Invoke for analysis or refactoring.
npx claudepluginhub j-morgan6/elixir-phoenix-guide --plugin elixir-phoenix-guideThis skill uses the workspace's default tool permissions.
Automated detection of code quality issues in Elixir projects. These checks run automatically via hooks when files are written, and can be run on-demand for full project analysis.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Automated detection of code quality issues in Elixir projects. These checks run automatically via hooks when files are written, and can be run on-demand for full project analysis.
run_analysis.sh to establish a baseline before and afterDetects when the same function appears in multiple modules with >70% body similarity.
How it works: AST-based analysis parses function bodies and compares them using trigram similarity. Functions with the same name, arity, and similar bodies are flagged.
Example output:
Duplication Detected
Function `format_time/1` (85% similar)
lib/app_web/live/cycle_time.ex:45
lib/app_web/live/lead_time.ex:52
Suggestion: Extract to a shared module
How to fix:
# Create: lib/app_web/live/helpers.ex
defmodule AppWeb.Live.Helpers do
def format_time(%Decimal{} = seconds) do
seconds |> Decimal.to_float() |> format_time()
end
def format_time(seconds) when is_number(seconds) do
# shared formatting logic
end
end
# In each LiveView:
import AppWeb.Live.Helpers, only: [format_time: 1]
Measures function complexity using the ABC metric (Assignments, Branches, Conditions).
= operatorscase, cond, if, unless, with, -> clauses&&, ||, and, or, ==, !=, >, <, >=, <=, when guardsABC = sqrt(A² + B² + C²) — threshold is 30.
Example output:
High Complexity Detected
Function `calculate_trend_line/1` — ABC complexity 41 (threshold: 30)
lib/app_web/live/helpers.ex:45
Suggestion: Break into smaller functions with single responsibilities
How to fix:
# Before: one large function (complexity 41)
def calculate_trend_line(data) do
# 50 lines of assignments, branches, conditions
end
# After: composed smaller functions (complexity <20 each)
def calculate_trend_line(data) do
sums = calculate_regression_sums(data)
slope = calculate_slope(sums)
intercept = calculate_intercept(sums, slope)
build_trend_points(data, slope, intercept)
end
Detects defp functions that are defined but never called within the module.
Example output:
Unused Private Functions
`old_format_date` defined at line 123 but never called
Suggestion: Remove if no longer needed
Common after refactoring — when you extract code to a shared module, the original private functions may become dead code.
Detects when HEEx templates in the same directory share >40% identical markup.
Example output:
Template Duplication Detected
86 identical lines (72%) between:
cycle_time.html.heex
lead_time.html.heex
Suggestion: Extract shared markup to a function component
How to fix:
# Create a function component for the shared markup
defmodule AppWeb.Live.Components do
use Phoenix.Component
def metric_filters(assigns) do
~H"""
<div class="filters">
<!-- shared filter markup -->
</div>
"""
end
end
Code quality checks run automatically when files are written or edited:
.ex/.exs files trigger duplication, complexity, and unused function checks.heex files trigger template duplication checksRun a complete analysis from the project root:
bash ~/.claude/scripts/elixir-phoenix-guide/run_analysis.sh
Or target specific checks:
# Single file analysis
elixir ~/.claude/scripts/elixir-phoenix-guide/code_quality.exs all lib/app_web/live/my_live.ex
# Specific check
elixir ~/.claude/scripts/elixir-phoenix-guide/code_quality.exs complexity lib/app_web/live/my_live.ex
elixir ~/.claude/scripts/elixir-phoenix-guide/code_quality.exs duplication lib/app_web/live/my_live.ex
elixir ~/.claude/scripts/elixir-phoenix-guide/code_quality.exs unused lib/app_web/live/my_live.ex
# Scan entire lib/ directory
elixir ~/.claude/scripts/elixir-phoenix-guide/code_quality.exs scan lib/
For testing guidance, see testing-essentials. When writing tests for refactored shared modules, ensure: