Design mistakes are the expensive ones: a v1 API without pagination, a migration that locks a 40-million-row table at noon. AI's best design-stage role is not drafting — it is attacking.
Tier: Core · Workflow area: Feature development
This playbook is a two-move pattern: draft the artifact (yourself or with AI), then have AI adversarially critique it against a domain checklist before any human review. It works identically for API contracts and DB schema/migration designs.
Skip it for additive changes to internal-only endpoints with one consumer you control.
CREATE TABLE/ALTER TABLE DDL plus migration steps.Draft with explicit context. Paste the artifact plus facts the attacker needs:
Context: Postgres 15, orders table ~40M rows, ~600 writes/min peak,
API consumed by 3 internal services + 1 mobile app we cannot force-upgrade.
Draft artifact: [OpenAPI for GET/POST /v2/orders + ALTER TABLE orders
ADD COLUMN fulfillment_status text NOT NULL DEFAULT 'pending';]
Run the API attack. One prompt, checklist-driven:
Attack this API design as a hostile senior reviewer. For each finding:
the flaw, a concrete failure scenario, and the minimal fix.
Checklist: pagination (what happens at 100k orders?), filtering/sort
stability, idempotency of POST (mobile retries!), error taxonomy
(structured codes vs free text), versioning and additive-change policy,
nullable-vs-optional semantics, timestamps and timezones, rate-limit
headers, breaking-change risk for the mobile client we cannot upgrade.
Rank findings by blast radius. Do not restate the design.
Run the migration attack. Same pattern, different checklist:
Attack this migration for Postgres 15 at 40M rows / 600 writes-min.
Checklist: lock type and duration of each statement (which ones take
ACCESS EXCLUSIVE?), table rewrite risk of NOT NULL DEFAULT on this PG
version, backfill strategy (batch size, throttling, resumability),
index creation (CONCURRENTLY? invalid-index cleanup?), deploy ordering
vs old app code still running, rollback plan per step, replication lag.
For each: how I would detect the problem in staging before prod.
Adjudicate the findings. For each finding, mark: accept (fix the design), reject with reason (write the reason down — it becomes review documentation), or verify (you are unsure; test it). Never accept fixes wholesale — attackers over-flag by design.
Verify the load-bearing claims. Lock behavior and rewrite claims are version-specific and models get them wrong across versions. Check the two or three decisions that matter against the official docs or an empty-table experiment (BEGIN; ALTER ...; SELECT mode FROM pg_locks ...; ROLLBACK;).
Attach the record. Bring the attack findings and your adjudications to human design review. Humans now spend their time on the judgment calls, not on re-finding the missing pagination.
Database lock and rewrite behavior differs by engine and version — treat every such claim as a hypothesis to verify, not a fact, no matter how confidently stated.
Schema and API shapes are often exactly what NDAs protect. Sanitize before pasting: rename tables/fields to neutral equivalents (orders → records, keep types and cardinalities honest — the attack quality depends on structure, not names), strip real hostnames and internal service names, and keep a local mapping note. Or run the whole attack on a client-approved enterprise tenant or a local model — attack checklists work well even on mid-size local models because the prompt itself carries the expertise.