/loopdatabasehigh riskintermediatesafety C · 55Forward Futurepre-dates current gate · under review

Clean production data to spec

Remove disallowed records, sharpen the classification logic, and verify the remaining dataset against an explicit definition.

prompt
→ Claude
Review production records, remove anything that does not meet the allowed definition, improve the classification logic, and verify the remaining data.
claude-code · codex

Use this when

Use this when a production dataset contains records that no longer match a product, policy, taxonomy, or quality definition and the classifier allowed them through.

How it runs

  1. Write the allowed definition as explicit inclusion, exclusion, and edge-case rules before changing data.
  2. Audit production records, preserve a recoverable record of proposed removals, and separate clear violations from uncertain cases.
  3. Remove confirmed invalid records through the approved production path and improve the classifier with regression examples.
  4. Rerun classification tests and audit the remaining production data until every sampled and queried record meets the definition.

Done when

Every remaining record meets the allowed definition. Representative classification tests and a post-cleanup audit prove the retained data is valid.

Why it works

Fixing both the existing records and the classifier closes the immediate data problem and reduces recurrence. Explicit rules and regression examples make future cleanup decisions reviewable.

Implementation note

Follow access, retention, privacy, and audit requirements. Use backups or reversible operations where appropriate, and do not delete uncertain records without review.

Source: Forward Future

More database loops

Apply database migrations cleanly

/goalnew

Run migrations, fix schema or SQL errors, and repeat until prisma migrate status reports clean, capped at 6 turns.

prompt
→ Claude
/goal all database migrations apply cleanly — run them, fix schema or SQL errors, repeat until `npx prisma migrate status` is clean; stop after 6 turns
databasemedium risk

N+1 query hunt

/goalloopreponew

Instrument the test suite with query logging, find endpoints issuing N+1 queries, and fix them with eager loading or batching until the hot paths are clean.

prompt
→ Claude
/goal no endpoint in the integration test suite issues more than 10 SQL queries per request — enable query logging in the test environment, find the worst N+1 offender, fix it with eager loading or a batched query, verify the count dropped and tests still pass, then move to the next; stop after 12 turns
databasemedium risk