elixir-phoenix-ecto-constraint-debug

elixir-phoenix-ecto-constraint-debug is a skill for Claude Code, Codex from ccarvalho-eng/codex-elixir-phoenix. It costs 25 tokens per session (680 once invoked), scanned A, a copy of ecto-constraint-debug, MIT.

A debugging guide for Ecto constraint errors. Ecto is the Elixir library commonly used to map application data to a database; constraints are database rules such as unique values and valid references between tables.

In plain words
What is it for?
Use it when an Ecto constraint error occurs, including unique, foreign-key, or changeset constraint failures. It helps identify the failed constraint, inspect migrations, and find every code path that writes the affected data.
Why use it?
It helps trace whether the failure comes from a database migration, an unexpected insert path, or simultaneous requests trying to write the same data. This avoids relying only on surface-level validation messages.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ccarvalho-eng/codex-elixir-phoenix/elixir-phoenix-ecto-constraint-debug
Any agent
npx skills add ccarvalho-eng/codex-elixir-phoenix --skill elixir-phoenix-ecto-constraint-debug
Clone the repo
git clone --depth 1 https://github.com/ccarvalho-eng/codex-elixir-phoenix

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for elixir-phoenix-ecto-constraint-debug

README.md
[![agentmods](https://agentmods.dev/badge/skills/ccarvalho-eng/codex-elixir-phoenix/elixir-phoenix-ecto-constraint-debug.svg)](https://agentmods.dev/skills/ccarvalho-eng/codex-elixir-phoenix/elixir-phoenix-ecto-constraint-debug)
Your own site
<a href="https://agentmods.dev/skills/ccarvalho-eng/codex-elixir-phoenix/elixir-phoenix-ecto-constraint-debug"><img src="https://agentmods.dev/badge/skills/ccarvalho-eng/codex-elixir-phoenix/elixir-phoenix-ecto-constraint-debug.svg" alt="Measured on agentmods" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 680 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 86% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00025 $0.00680
Opus 5 $0.00013 $0.00340
Sonnet 5 $0.00005 $0.00136
Haiku 4.5 $0.00003 $0.00068

Measured 4d ago against content hash 2fec8befb9c3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

elixir-phoenix-ecto-constraint-debug scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

86% identical to ecto-constraint-debug — 19 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/elixir-phoenix-ecto-constraint-debug/SKILL.md · 70 lines

How it starts

The opening of the file, as written. The whole thing — 70 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Ecto Constraint Debugging

Systematic approach to diagnosing constraint violations. Load when you see Ecto.ConstraintError, unique_constraint, foreign_key_constraint, or constraint-related changeset errors.

Iron Laws

  1. READ THE CONSTRAINT NAME — The constraint name (e.g., links_url_index) tells you exactly which index/constraint failed. Parse it from the error message first
  2. CHECK MIGRATION BEFORE CODE — Verify the constraint definition in priv/repo/migrations/ matches what the schema expects
  3. TRACE ALL INSERT PATHS — Find every code path that inserts into the constrained table. The bug is often in a path you didn't consider
  4. RACE CONDITION UNTIL PROVEN OTHERWISE — If validation passes but constraint fails, assume concurrent inserts until you prove a single-request cause

Step-by-Step Debugging

Step 1: Parse the Error

Extract from the error message:

  • Constraint name (e.g., users_email_index)
  • Table name (e.g., users)
  • Operation (insert, update, or delete)
  • Conflicting values (if available in logs)

Step 2: Find the Migration

Use rg to search for the constraint name in priv/repo/migrations/. Also check for create unique_index, create index, add constraint.

Verify: Does the migration constraint match the schema's unique_constraint/3 or foreign_key_constraint/3 call?

Step 3: Find the Schema

Use rg to find constraint handling in changesets (unique_constraint, foreign_key_constraint, check_constraint) in lib/.

Step 4: Trace Insert Paths

Find ALL callers that insert/update this schema:

Use rg to find all insert/update paths (Repo.insert, Repo.update, Repo.insert_all, cast_assoc) in lib/.

Step 5: Identify the Cause

Symptom Likely Cause Fix Pattern
Same user triggers twice Race condition (double-click, retry) Upsert with on_conflict
Multiple parents share child cast_assoc doesn't dedup across changesets Dedup before building changesets
Concurrent API requests Missing transaction isolation Wrap in Repo.transaction or use upsert
Migration added constraint to existing data Data violates new constraint Backfill or clean data first

Read the full file on GitHub · 70 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 70 lines · 25 tokens per session scan A 2fec8befb9c3

Subscribe to this mod's changes

elixir-phoenix-ecto-constraint-debug is a skill published in the GitHub repository ccarvalho-eng/codex-elixir-phoenix (11 stars, last pushed 4mo ago), licensed MIT. It adds 25 tokens to every session and 680 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 86% identical to ecto-constraint-debug, differing in 19 lines, and is treated as a copy.

Related

Other skills, from other repositories

opik-backend

Java backend patterns for Opik. Use when working in apps/opik-backend, designing APIs, database operations, or services.

comet-ml/opik · 31 tokens

vellum-migration-checklist

Validate Vellum Assistant database and workspace migrations. Use when adding, editing, reviewing, or testing migrations, release-note migrations, persisted schemas, workspace file formats, or data backfills.

vellum-ai/vellum-assistant · 45 tokens

db-migrations

Use for database rollout strategy, Drizzle migrations, online index creation, data backfills, migration regeneration, sequence conflicts after rebase, idempotent SQL review, or migration renames.

lobehub/lobehub · 42 tokens

drizzle

LobeHub Drizzle ORM schema and query style. Use for pgTable schemas, indexes, joins, inferred types, db.select/db.query, schema fields, foreign keys, junction tables, or postgres query patterns.

lobehub/lobehub · 46 tokens

web-sqli

SQL injection detection→exploitation→proof for web apps and APIs. Use when a parameter reaches a DB query, when input triggers a SQL error / boolean or time differential, or during VULN-ASSESSMENT/EXPLOITATION on a web target. Triggers - sql syntax error, ORA-/MySQL/psql/SQLite error string, ' or 1=1, order by…

s0ld13rr/pentestcode · 100 tokens

svc-database

Database RCE paths — UDF, xpcmdshell, COPY TO PROGRAM, Redis key write. Use when a database service is found. Triggers - MySQL 3306, PostgreSQL 5432, MSSQL 1433, Redis 6379, MongoDB 27017.

s0ld13rr/pentestcode · 64 tokens