cc-changelog
CONTRIBUTOR TOOL - Track CC changelog, extract new versions since last check, analyze impact on plugin (breaking changes, opportunities, deprecations). Run…
Debug Ecto constraint violations - trace triggers, check migrations, find duplicate data. Use when seeing unique_constraint, foreign_key_constraint, or check_constraint errors.
$ npx -y skills add oliver-kriska/claude-elixir-phoenix --skill ecto-constraint-debug --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/ecto-constraint-debugContext preview
The summary Claude sees to decide when to auto-load this skill.
Debug Ecto constraint violations - trace triggers, check migrations, find duplicate data. Use when seeing unique_constraint, foreign_key_constraint, or check_constraint errors.
name: ecto-constraint-debug description: Debug Ecto constraint violations - trace triggers, check migrations, find duplicate data. Use when seeing unique_constraint, foreign_key_constraint, or check_constraint errors. effort: medium
> **Ash projects**: Ash surfaces DB constraints through its own error DSL. Use the `ash-framework` skill — `mix usage_rules.search_docs "constraint" -p ash_postgres`.
Systematic approach to diagnosing constraint violations. Load when you see `Ecto.ConstraintError`, `unique_constraint`, `foreign_key_constraint`, or constraint-related changeset errors.
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
Extract from the error message:
Use Grep 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?
Use Grep to find constraint handling in changesets (`unique_constraint`, `foreign_key_constraint`, `check_constraint`) in `lib/`.
Find ALL callers that insert/update this schema:
Use Grep to find all insert/update paths (`Repo.insert`, `Repo.update`, `Repo.insert_all`, `cast_assoc`) in `lib/`.
| 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 |
See `${CLAUDE_SKILL_DIR}/references/constraint-patterns.md` for detailed fix patterns.
**Unique violation** → Upsert: `Repo.insert(changeset, on_conflict: :replace_all, conflict_target: [:field])`
**Foreign key violation** → Check: Does the referenced record exist? Was it deleted concurrently?
**Check constraint** → Validate: Does the value satisfy the constraint condition?
Docs: phxagents.dev -- install guides per runtime, the runtime compatibility matrix, all 26 Iron Laws, and a browsable skill and agent catalog. Claude Code is great.
Repo: oliver-kriska/claude-elixir-phoenix
CONTRIBUTOR TOOL - Track CC changelog, extract new versions since last check, analyze impact on plugin (breaking changes, opportunities, deprecations). Run…
Run an A/B codex review experiment — holistic codex review vs 3 focused dimension passes (security, ecto, liveview) on the branch diff, classify findings,…
CONTRIBUTOR TOOL - Validate plugin against latest Claude Code documentation. Catches breaking changes, deprecations, discovers new features. Run before…
Guide plugin development workflow — editing skills, agents, hooks, or eval framework in this repo. Use when modifying files in plugins/elixir-phoenix/,…
Generate X/Twitter release promotion posts with ASCII tables and CodeSnap rendering. Use when writing release posts, promotion tweets, plugin announcements, or…
CONTRIBUTOR TOOL - Cut a plugin release: bump plugin.json version, finalize CHANGELOG, update README if needed, gate on make ci, commit, tag vX.Y.Z, and create…