elixir-antipatterns

Identify and correct Elixir and Phoenix anti-patterns in code review.

2|Updated Aug 2, 2023
One-click install
npx skills add https://github.com/ic-facet/gestion-programas-asignatura --skill elixir-antipatterns-ic-facet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: elixir-antipatterns
Source: https://github.com/ic-facet/gestion-programas-asignatura/tree/main/.cursor/skills/elixir-antipatterns
Command: npx skills add https://github.com/ic-facet/gestion-programas-asignatura --skill elixir-antipatterns-ic-facet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers avoid common pitfalls in Elixir and Phoenix development, leading to more robust, maintainable, and performant applications.

Core Features & Use Cases

  • Error Handling: Enforces the use of tagged tuples ({:ok, value} | {:error, reason}) over exceptions or nil for predictable error management.
  • Code Structure: Guides developers on separating concerns between LiveViews and contexts, and managing the complexity of with statements.
  • Performance: Highlights and provides solutions for common performance issues like N+1 queries and missing database indexes.
  • Testing: Emphasizes the importance of assertions in tests for verifying expected behavior.
  • Use Case: During a code review for a new Phoenix feature, this Skill can be invoked to identify and correct anti-patterns related to error handling and database query efficiency before they are merged.

Quick Start

Review the provided Elixir code for common anti-patterns.

Frequently Asked Questions about elixir-antipatterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix Ecto N+1 queries in my Phoenix application?

Fix Ecto N+1 queries by identifying missing database indexes and refactoring data loading strategies. This Skill highlights common Elixir performance anti-patterns and provides targeted solutions to optimize database query efficiency during code reviews.

What is the best way to handle errors in Elixir without using exceptions?

The best way to handle errors in Elixir is by using tagged tuples like `{:ok, value} | {:error, reason}` instead of exceptions or `nil`. This Skill enforces predictable error management by identifying improper error handling patterns for refactoring.

How do I separate LiveView logic from business contexts in Elixir?

Separate LiveView logic from business contexts by reviewing your code structure for architectural anti-patterns. This Skill guides developers on properly dividing concerns between LiveViews and contexts to manage complexity and improve maintainability.

Can I use this to review complex `with` statements in my Elixir code?

Yes, you can use this to review complex `with` statements. The Skill identifies code structure anti-patterns and guides developers on managing the complexity of nested `with` statements for more robust Elixir applications.

Why should I use assertion-based testing in Elixir applications?

Assertion-based testing verifies expected behavior by ensuring tests actually validate outcomes rather than just running code. This Skill emphasizes the importance of assertions during code review to correct testing anti-patterns and improve application robustness.