Data — is it sound?
Brief 19

Schema Review

Missing indexes, absent constraints, JSON blobs hiding structure — with a migration plan sequenced safest-first.

SCHEMA.md4 phases8 lenses~2.7k chars

Free & open · no signup · read-only — it ends by asking · nothing leaves your machine

What it does

You are working inside this repo. Mission: review the data model against how the code actually queries it — find the missing indexes, absent constraints, and structural smells — and produce a migration plan sequenced safest-first.

Read-only pass. Your only write is the report file.

What it looks for

8 lenses it looks through

Phase 2 sweeps the codebase through every one of these, citing file and line for each finding.

1

Missing indexes

real query patterns scanning unindexed columns; foreign keys without indexes

2

Absent constraints

uniqueness, FKs, and NOT NULL enforced only in app code; the database allowing states the app considers impossible

3

Accidental nullability

columns nullable by default that the code always assumes present

4

Blob smell

JSON columns hiding fields the code filters or joins on

5

Naming drift

inconsistent casing, singular/plural, ambiguous names

6

Half-applied patterns

soft-delete on some tables, cascades on some FKs; the inconsistency is the bug

7

Orphan risk

deletes that strand child rows; cleanup that depends on app code running

8

Migration hazards

pending changes that would lock large tables; irreversible migrations

The deliverable

What lands in your repo

One structured report at the repo root — or in reports/, if you keep one — the same shape every time, ready for a teammate — or the optional Studio — to act on.

SCHEMA.md
1
Schema snapshot
tables, sizes/growth, relationships in brief
2
Findings
each: issue · symptom it causes · evidence (query in code + schema gap) · fix migration sketch · risk
3
Index plan
tied to the actual hot queries, not speculative
4
Migration sequence
ordered, each step safe and reversible where possible; backfill notes
5
First migration
written out
One file. Evidence-backed. It ends by asking before touching anything.
How it works

What it makes the agent do

Every Goal Prompt follows the same four steps, so results are consistent and repeatable — no matter which one you run.

1
Phase 1

Extract schema and query patterns

Reconstruct the schema from migrations, models, or the ORM definitions.

2
Phase 2

Audit through 8 lenses

Missing indexes — real query patterns scanning unindexed columns.

3
Phase 3

Curate

Every finding names the symptom it will cause.

4
Phase 4

Report

Create SCHEMA.md at repo root.

Get started

Three ways to run this Goal Prompt

01 · COPY

Paste it in

Copy it and paste it into your agent inside the repo you want checked.

02 · INSTALL

As a slash command

Install the goal plugin once — two commands — then just type /goal:schema-review.

1/plugin marketplace add GhostlyGawd/goal-prompts
2/plugin install goal@goal-prompts

Or install only this Goal Prompt as /goal-schema-review:

curl -fsSL https://goal-prompts.vercel.app/install | BRIEF=19 sh
03 · AGENT

From an agent (MCP)

Let an agent fetch it mid-conversation, or pull the raw Goal Prompt by URL.

https://goal-prompts.vercel.app/raw/19.md
Transparency

The exact prompt

Nothing hidden — this is the whole Goal Prompt, verbatim. Read it in a minute, edit it, or copy it as-is.

Read the full brief (2,722 characters)
# Goal: Schema Review

You are working inside this repo. Mission: review the data model against how the code actually queries it — find the missing indexes, absent constraints, and structural smells — and produce a migration plan sequenced safest-first.

Read-only pass. Your only write is the report file.

## Phase 1 — Extract schema and query patterns
- Reconstruct the schema from migrations, models, or the ORM definitions.
- Map the top query patterns from the code: which lookups, joins, and filters actually run, and how often (hot paths).
- Note table growth: which tables grow with users, with events, without bound?

## Phase 2 — Audit through 8 lenses
1. **Missing indexes** — real query patterns scanning unindexed columns; foreign keys without indexes
2. **Absent constraints** — uniqueness, FKs, and NOT NULL enforced only in app code; the database allowing states the app considers impossible
3. **Accidental nullability** — columns nullable by default that the code always assumes present
4. **Blob smell** — JSON columns hiding fields the code filters or joins on
5. **Naming drift** — inconsistent casing, singular/plural, ambiguous names
6. **Half-applied patterns** — soft-delete on some tables, cascades on some FKs; the inconsistency is the bug
7. **Orphan risk** — deletes that strand child rows; cleanup that depends on app code running
8. **Migration hazards** — pending changes that would lock large tables; irreversible migrations

## Phase 3 — Curate
- Every finding names the symptom it will cause: slow query, corrupt state, painful migration later
- Sequence fixes by risk: additive (indexes, constraints on clean data) → backfills → destructive

## Phase 4 — Report
Create `SCHEMA.md` at repo root:
1. **Schema snapshot** — tables, sizes/growth, relationships in brief
2. **Findings** — each: issue · symptom it causes · evidence (query in code + schema gap) · fix migration sketch · risk
3. **Index plan** — tied to the actual hot queries, not speculative
4. **Migration sequence** — ordered, each step safe and reversible where possible; backfill notes
5. **First migration** — written out

Start the report with today's date. If `SCHEMA.md` already exists from a previous run, read it first and lead with what changed since.

## Rules
- Index for queries that exist, not queries you imagine
- The database should enforce what the app assumes
- No database schema in this repo? Say so in a one-paragraph null report and stop — a null result is a valid finding.
- If a `reports/` directory exists at the repo root, write the report there instead of the root.
- Before asking, present the top findings as a ranked list in plain words
- Report only — end by asking which migrations to write

House rules for this Goal Prompt

  • Index for queries that exist, not queries you imagine
  • The database should enforce what the app assumes
  • No database schema in this repo? Say so in a one-paragraph null report and stop — a null result is a valid finding.
  • If a reports/ directory exists at the repo root, write the report there instead of the root.
  • Before asking, present the top findings as a ranked list in plain words
  • Report only — end by asking which migrations to write
Keep exploring

More Data briefs