sql-backfill-pipeline-scaffoldlisted
Install: claude install-skill justinmchoi/ai-toolkit
# SQL Backfill Pipeline Scaffold
Use when recovering a corrupted value requires walking a chain across two or
more systems (e.g. a local DB → a join key into another system's log table →
the original value extracted from a logged JSON response), and the mutation
will eventually be handed to someone else (a DBA, another team) to run against
production.
## Inputs
Ask for, or infer from the conversation, before scaffolding:
1. What was corrupted, and the chain of systems/DBs needed to recover the
correct value (name each system and the join key between consecutive
hops).
2. Roughly how many rows are affected. This determines which mutate shape to
generate — see "Verify/mutate split" below. If unknown, ask; do not
default to the small-batch shape silently.
3. Who runs the final mutation — you, in this session, or a hand-off to
someone else. A hand-off raises the bar on self-guarding.
## Scaffold shape
```
docs/
plan.md # what's corrupted, the recovery chain, current status
resume-prompt.md # "paste into a fresh session" prompt with a living status section
phases/
phase1-<name>.sql # RUN AGAINST: <DB> banner comment at the top of every phase file
phase2-<name>.sql
...
scripts/
batch-ids.py # --table/--column flags; one generalized helper, not one per phase
command-steps.md # file -> DB target -> input -> output, plus exact shell commands
```
- Every `phaseN` SQL file starts with a `-- RUN AGAIN