-
Database
Enforce discipline on JSON fields
Audits schemaless JSON columns for structure drift and locks down validation, indexing, and size limits.
Free Prompt
Audit my JSON/JSONB columns and schemaless documents for structure drift. Find every column or field that stores arbitrary JSON and check what's actually been written into it.
For each: sample the stored values and report the shape variations found (missing keys, type drift like string-or-number, renamed fields across versions); define the expected shape and validate it at write time going forward, either with database-level validation or a single shared validation function; add size limits so a JSON field can't grow into a megabyte blob that slows every row read; and check whether anything queries into the JSON, because queried keys may need to become real columns or get a proper index. Report any data already stored in the wrong shape and write a cleanup migration.
Don't delete variant data you can't interpret; report it. Don't convert JSON fields to columns wholesale; only where querying justifies it. Keep the fix proportional: validate at write, index what you query, cap the size.
Deliver: the drift report per JSON field, the validators added, the cleanup migration for existing bad rows, any indexes added, and verification: attempt writes with wrong shapes and confirm rejection.
What This Does / How This Helps
Tames the JSON columns that vibe-coded apps lean on, where every code version writes a slightly different shape until reads break in confusing ways. JSON fields are convenient and then they aren't: a key gets renamed, old rows keep the old key, and six months later half your rows fail a parse in code that assumes the new shape. Structure drift is silent until it isn't. The fix keeps the flexibility where it's genuine and adds a floor: validated writes, size caps, and indexes where you actually query inside the JSON.
Want to skip doing this by hand?
Fortivibe audits your app for all of the areas these prompts cover (and more).