Agent skill

Code Quality

by j-morgan6 in 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.

MITAuto-check passedDevelopment

Install Code Quality

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

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

GitHub CLI
$ gh skill install j-morgan6/elixir-phoenix-guide code-quality --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/code-quality .claude/skills/code-quality && 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
code-quality
GitHub stars
166
Token cost
~1.4k tokens
SKILL.md length
413 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

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

  • Works in 7 steps: Duplicated functions must be extracted —… → Functions must stay below ABC complexity… → Unused private functions must be removed… → …
  • Refactoring for duplication
  • SKILL.md covers RULES — Follow these with no…, What Gets Detected, Running Analysis and Testing
  • Calls bash

What it does

Code Quality is an agent skill from j-morgan6/elixir-phoenix-guide. Use when refactoring for duplication, complexity, or dead code — includes the plugin's on-demand analysis scripts.

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

It sits in Development, covering Code quality and Refactoring. The licence is MIT.

When your agent uses it

  • Refactoring for duplication
  • Dead code — includes the plugins on-demand analysis scripts

Example prompts

  • “/code-quality”

Workflow steps

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

  1. Duplicated functions must be extracted — when 2+ modules share >70% identical function implementations, create a shared module
  2. Functions must stay below ABC complexity 30 — break complex functions into smaller helpers with single responsibilities
  3. Unused private functions must be removed — dead code increases maintenance burden and confusion
  4. Duplicated templates must become components — when 2+ HEEx files share >40% identical markup, extract to a function component
  5. Run full analysis before major refactors — use run_analysis.sh to establish a baseline before and after
  6. Address duplication before complexity — extracting shared code often reduces complexity as a side effect
  7. Prefer composition over inheritance — extract shared functions into modules imported/used where needed, not into base modules

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

    Shell commands in SKILL.md call:

    • bash

    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

Code Quality loads about 1.4k tokens when it runs. Until then it costs about 32 tokens; SKILL.md has 413 words of instructions outside code blocks.

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

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). 413 words, ~1,373 tokens.

Download SKILL.mdSave it as .claude/skills/code-quality/SKILL.md (or your agent's skills folder).
name
code-quality
description
Use when refactoring for duplication, complexity, or dead code — includes the plugin's on-demand analysis scripts.
file_patterns
**/*.ex, **/*.heex
auto_suggest
true

Code Quality Automation

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.

RULES — Follow these with no exceptions

  1. Duplicated functions must be extracted — when 2+ modules share >70% identical function implementations, create a shared module
  2. Functions must stay below ABC complexity 30 — break complex functions into smaller helpers with single responsibilities
  3. Unused private functions must be removed — dead code increases maintenance burden and confusion
  4. Duplicated templates must become components — when 2+ HEEx files share >40% identical markup, extract to a function component
  5. Run full analysis before major refactors — use run_analysis.sh to establish a baseline before and after
  6. Address duplication before complexity — extracting shared code often reduces complexity as a side effect
  7. Prefer composition over inheritance — extract shared functions into modules imported/used where needed, not into base modules

What Gets Detected

Code Duplication

Detects 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:

elixir
# 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]
ABC Complexity

Measures function complexity using the ABC metric (Assignments, Branches, Conditions).

  • A (Assignments): = operators
  • B (Branches): case, cond, if, unless, with, -> clauses
  • C (Conditions): &&, ||, and, or, ==, !=, >, <, >=, <=, when guards

ABC = 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:

elixir
# 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
Show full SKILL.md (171 more words)Show less
Unused Private Functions

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.

Template Duplication

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:

elixir
# 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

Running Analysis

Automatic (via hooks)

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 checks
On-Demand (full project)

Run a complete analysis from a checkout of this repo:

bash
bash scripts/run_analysis.sh

Or target specific checks:

bash
# Single file analysis
elixir scripts/code_quality.exs all lib/app_web/live/my_live.ex

# Specific check
elixir scripts/code_quality.exs complexity lib/app_web/live/my_live.ex
elixir scripts/code_quality.exs duplication lib/app_web/live/my_live.ex
elixir scripts/code_quality.exs unused lib/app_web/live/my_live.ex

# Scan entire lib/ directory
elixir scripts/code_quality.exs scan lib/

When installed as a plugin, the scripts live inside the plugin install directory rather than at a fixed path in the project — run the commands above from a checkout of this repo instead.


Testing

For testing guidance, see testing-essentials. When writing tests for refactored shared modules, ensure:

  • Original test coverage is maintained
  • New shared module has its own test file
  • All callers still pass their tests after extraction

© 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/code-quality of j-morgan6/elixir-phoenix-guide.

Open the folder on GitHubat commit cdfddac

Compare with similar skills

Code Quality 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.

Code Quality compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Code Quality this skillj-morgan6/elixir-phoenix-guide166—~1.4kAutomated safety check: PassMIT
Systematic Code Refactoringluongnv89/claude-howto42k—~3kAutomated safety check: PassMIT
Ponytail Lazy Developer ModeDietrichGebert/ponytail158k—~871Automated safety check: PassMIT
Dignified Python Standardsdocling-project/docling69k—~1.5kAutomated safety check: PassApache-2.0
Clean Code GuardamElnagdy/guard-skills1.3k2 repos~4.3kAutomated safety check: PassMIT
Code Refactoring Workflowluongnv89/claude-howto42k—~3.1kAutomated safety check: PassMIT

Similar skills

  • Systematic Code Refactoring

    luongnv89/claude-howto

    Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.

    42k GitHub stars~3k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • Ponytail Lazy Developer Mode

    DietrichGebert/ponytail

    Makes the agent pick the laziest solution that works: skip unneeded work, reuse what exists, prefer the standard library and platform features, and keep diffs small.

    158k GitHub stars~871 tokensUpdated today
    DevelopmentAuto-check passed
  • Dignified Python Standards

    docling-project/docling

    Applies opinionated production Python conventions chosen by the project's Python version: modern type syntax, pathlib, explicit checks and interface guidance.

    69k GitHub stars~1.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Clean Code Guard

    amElnagdy/guard-skills

    Reviews generated or changed production code against Clean Code, SOLID, DRY, KISS, YAGNI and LLM-specific failure modes before it ships, in any language.

    1.3k GitHub starsUsed in 2 repos~4.3k tokens
    DevelopmentAuto-check passed
  • Code Refactoring Workflow

    luongnv89/claude-howto

    Guides systematic, test-backed refactoring in the style of Martin Fowler, moving through research, planning and small incremental changes with your approval at each phase.

    42k GitHub stars~3.1k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • A code-change gate for the iPolloWork repository: search and reuse first, keep one source of truth, justify every new file or dependency, and audit the change.

    6.8k GitHub stars~2.7k tokensUpdated today
    DevelopmentAuto-check passed

More from j-morgan6/elixir-phoenix-guide

All 19 skills in this repo
  • 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
  • Oban Essentials

    j-morgan6/elixir-phoenix-guide

    A skill your agent uses when writing background jobs with Oban — worker options, return contracts, idempotency, uniqueness, Oban.Testing.

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

Categories

Questions about Code Quality

What does Code Quality do?

A skill your agent uses when refactoring for duplication, complexity, or dead code — includes the plugin's on-demand analysis scripts. Code Quality is an agent skill from j-morgan6/elixir-phoenix-guide. Use when refactoring for duplication, complexity, or dead code — includes the plugin's on-demand analysis scripts.

When should I use Code Quality?

Code Quality fits situations like: refactoring for duplication; dead code — includes the plugins on-demand analysis scripts.

How do I install Code Quality in Claude Code?

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

How do I install Code Quality in Codex?

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

Can I use Code Quality 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 code-quality -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-quality, .gemini/skills/code-quality, .github/skills/code-quality and .opencode/skills/code-quality in your project.

What does Code Quality need to run?

Going by SKILL.md and its folder, Code Quality needs the command-line tools its instructions call (bash).

Does Code Quality 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 Code Quality 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 Code Quality use?

Code Quality 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 Code Quality use?

About 1.4k tokens (SKILL.md is roughly 5.5k 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 Code Quality?

Skills that share tags, products or a category with Code Quality: Systematic Code Refactoring (luongnv89/claude-howto, 42k stars), Ponytail Lazy Developer Mode (DietrichGebert/ponytail, 158k stars), Dignified Python Standards (docling-project/docling, 69k stars) and Clean Code Guard (amElnagdy/guard-skills, 1.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Code Quality?

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.