techdebt
The techdebt command scans Elixir/Phoenix codebases to identify technical debt issues including unreachable code, missing typespecs, oversized modules, untested code, duplicated logic, and deprecated patterns. Use this command when reviewing code quality, planning refactoring work, or establishing baseline metrics for a project's maintainability.
git clone --depth 1 https://github.com/oliver-kriska/claude-elixir-phoenix /tmp/techdebt && cp -r /tmp/techdebt/plugins/elixir-phoenix/skills/techdebt ~/.claude/skills/techdebtSKILL.md
# Technical Debt Detection Find and eliminate duplicate code patterns, anti-patterns, and refactoring opportunities in Elixir/Phoenix projects. ## Iron Laws - Never Violate These 1. **Search before refactoring** - Understand full scope of duplication before extracting 2. **Three strikes rule** - Extract shared code only after 3+ duplications 3. **Prefer composition** - Use behaviours and protocols over inheritance-style abstractions 4. **Test coverage first** - Ensure tests exist before refactoring duplicated code ## Analysis Checklist ### 1. Run Credo for Automated Detection Run `mix credo --strict`. Focus on: - Design issues (duplication, complexity) - Consistency issues (naming, patterns) - Refactoring opportunities ### 2. Find Duplicate Ecto Query Patterns Use Grep to search for repeated Repo calls (`Repo.get!`, `Repo.get`, `Repo.one`) in `lib/**/*.ex`. Use Grep to find duplicate query patterns (`from.*in.*where`) in `lib/**/*.ex`. ### 3. Find Duplicate Validation Logic Use Grep with `output_mode: "count"` to count `def changeset` occurrences in `lib/**/*.ex`. Use Grep to find repeated validations (`validate_required`, `validate_format`) in `lib/**/*.ex`. ### 4. Find Copy-Pasted Controller Actions Use Grep to find similar action patterns (`def create`, `def update`, `def delete`) in `lib/*_web/**/*.ex`. ## Common Duplication Patterns | Pattern | Symptom | Solution | |---------|---------|----------| | Repeated queries | Same `Repo.get` in multiple contexts | Create shared query module | | Duplicate validations | Same `validate_*` calls | Extract to shared changeset | | Similar controllers | Copy-pasted CRUD actions | Use Phoenix generators consistently | | Repeated transforms | Same `Enum.map` patterns | Extract to domain module | ## Reporting Format For each duplication found, report: 1. **Location**: File paths and line numbers 2. **Pattern**: What code is duplicated 3. **Extraction**: Suggested shared function/module 4. **Effort**: Low/Medium/High to fix ## Usage Run `/phx:techdebt` to analyze the codebase and generate a prioritized report of technical debt with specific remediation steps.
Ash Framework — resources, actions, policies, aggregates, calculations,
Compatibility alias for the Elixir/Phoenix plugin's LiveView assigns audit. Invoke explicitly with /lv:assigns.
Inspect LiveView socket assigns for memory bloat — missing temporary_assigns, unused assigns, unbounded lists needing streams, memory estimates. Use when LiveView memory grows or you need to add temporary_assigns.
Project health audit and health check — architecture, performance, tests, dependencies, code quality. Use when assessing overall project health, before releases, or after refactors.
Analyze Phoenix context boundaries and module coupling via mix xref. Use when checking cross-context calls, validating dependencies, before splitting modules, or reviewing architecture.
Brainstorm Elixir/Phoenix features — explore ideas, compare approaches, gather requirements. Use when vague idea, not sure how to approach, or want to discuss before plan.
Interactive briefing of a plan file — explains reasoning, schema decisions, component choices. Use when developers need to understand a plan before approving.
Summarize and review what changed while you were away. Use after a weekend, vacation, or flight to check missed PRs, git commits, Linear tickets, and meetings — one prioritized brief, not a firehose.