Fix

From Hainrixz/claude-db · View interactive version

Fix is an AI agent skill from the GitHub repository Hainrixz/claude-db. Opt-in writer (the /claude-db:fix command). Applies the safe, reversible schema/migration changes from an audit — adding indexes, NOT NULL/CHECK/UNIQUE constraints, missing FKs, type corrections, default/generated columns — as expand-contract migrations. Dry-run preview by default; writes only after

How to use this skill

Skill file

<!-- Copyright (c) 2026 Enrique Rocha (@soyenriquerocha) · tododeia.com · id er-f37b7121 -->

fix (opt-in writer)

disable-model-invocation: true means the model can never trigger this on its own — only the user running /claude-db:fix. Writes happen only through the db-migration-writer subagent (the one agent with Write/Edit) and only after explicit confirmation. Default is dry-run.

Fixability classes (from each finding's `fixable` field — see `schema/finding.schema.json`)

add a missing non-unique index / FK-supporting index; add a NOT NULL/CHECK/UNIQUE constraint via NOT VALID then VALIDATE; add a missing FK as NOT VALID then validate; add a default or generated column additively; widen an undersized integer key. Each ships with a clean down-migration.

Workflow

  1. Take the findings (from the last audit or a fresh one / a findings JSON). Filter to fixable: auto (+ proposed if the user opts in). Honor --category to scope.
  2. For each, build the exact migration (expand-contract steps where rewrite/lock risk exists), with a plain-language line before each diff explaining what it does and why — then the unified diff / migration file content. Resolve any required real inputs (backfill values, enum target set, FK target) by asking the user — never invent them.
  3. Dry-run (default): print every plain-language line + diff grouped by file/step. Write nothing. Summarize what fix (without --dry-run) would change, including lock level and reversibility per step.
  4. On explicit confirmation (and only then): delegate to db-migration-writer to apply. Per-change or batch confirmation is the user's choice.

Safety (hard rules)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.