ecto-guidelines

Standardize Ecto schemas, changesets, and migrations for Elixir Phoenix projects.

1|1|Updated Feb 8, 2026
One-click install
npx skills add https://github.com/code0100fun/botfiles --skill ecto-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ecto-guidelines
Source: https://github.com/code0100fun/botfiles/tree/main/plugins/elixir-phoenix/skills/ecto-guidelines
Command: npx skills add https://github.com/code0100fun/botfiles --skill ecto-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides clear, battle-tested guidelines for using Ecto effectively in Elixir projects, reducing runtime errors and inconsistencies.

Core Features & Use Cases

  • Preloading associations in queries to avoid N+1 issues and improve performance.
  • Correct schema field types and definitions to align with database columns and types.
  • Changeset validation patterns and secure handling of programmatic fields to prevent mass-assignment risks.
  • Safe access to changeset data using Ecto.Changeset.get_field and avoiding map-style access on changesets.
  • Migration best practices and generation conventions to ensure proper timestamps and naming.

Quick Start

Audit a sample module against these guidelines and adjust preloading, field handling, and changeset patterns accordingly.

Frequently Asked Questions about ecto-guidelines

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

FAQPage Schema
How do I prevent N+1 query issues when preloading associations in Ecto?

To prevent N+1 query issues in Ecto, preload associations directly within your database queries. Following standard Ecto preloading guidelines ensures efficient data retrieval and improves overall Phoenix application performance.

What is the safest way to access changeset data in Elixir to avoid runtime errors?

The safest way to access changeset data in Elixir is using Ecto.Changeset.get_field. Standard Ecto guidelines advise against map-style access on changesets to ensure secure data handling and prevent runtime errors.

How do I prevent mass-assignment risks during changeset validation in Phoenix?

Prevent mass-assignment risks in Phoenix by applying secure changeset validation patterns and carefully handling programmatic fields. Standardized Ecto guidelines ensure programmatic fields are protected from mass-assignment risks during changeset validation.

What are the best practices for Ecto migration generation and schema definitions?

Best practices for Ecto migrations include following specific generation conventions for naming and ensuring proper timestamps. Standardized Ecto guidelines align schema field types and definitions with database columns to maintain consistent database interactions.

Does this Ecto guidelines skill work with complex associations in Phoenix projects?

Yes, these Ecto guidelines work with complex associations in Phoenix projects. The guidelines specifically apply to Elixir Phoenix projects relying on Ecto for data modeling, validation, and migrations, including complex associations and security considerations.