/archlens-postgres:archlens-postgresfrom archlens-postgres
Document a project's PostgreSQL schema and rigorously review its logical and physical design in one pass — wrong cardinality, unenforced natural keys, junction tables that allow duplicates, tenant-isolation gaps, enum-ish columns with no CHECK, soft-delete/UNIQUE collisions, polymorphic references, and the places where the next feature will hurt. Use this whenever the user asks to review, audit, document, or sanity-check a database schema, data model, ERD, migrations, or "our tables"; when they ask whether a data model will scale or what an extension would break; or when a PR touches schema.sql / migrations and they want a design opinion, not just a syntax check. Also use it when asked to generate database documentation — the docs and the review come from the same run.
Ships in archlens-postgres. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Two halves, deliberately separated:
scripts/archlens.ts parses the DDL with the real
PostgreSQL parser, builds a model, joins it with human intent from
narratives.json, runs ~20 deterministic checks, and writes browsable
docs + schema.json + FINDINGS.md. It exits non-zero on errors, so it
can gate CI.schema.json and the findings, compare what the
narratives claim against what the schema allows, and reason about
extension scenarios the script cannot see. Output: REVIEW.md.The split matters. Anything the script can decide, the script decides, every
run, for free. Your job is the part that needs the domain story — and to
convert every judgment you make into an assertion in narratives.json so it
becomes a mechanical check next time (the "ratchet").
The script wants one PostgreSQL DDL file. Find or produce it:
| Source | How |
|---|---|
schema.sql / db/schema.sql | use directly |
Flyway migrations V*.sql | cat $(ls db/migration/V*.sql | sort -V) > /tmp/schema.sql — DROP/ALTER of columns are applied in order |
| Liquibase | liquibase updateSQL > /tmp/schema.sql |
| Prisma / Drizzle / Django / SQLAlchemy | generate the SQL with the ORM's own tool (prisma migrate diff --to-schema-datamodel --script, drizzle-kit generate, manage.py sqlmigrate) |
| Live database | pg_dump --schema-only --no-owner --no-privileges $DB > /tmp/schema.sql (best: this is the truth) |
Non-PostgreSQL DDL (Oracle, MySQL) will not parse. Say so rather than
guessing; pg_dump from a Postgres-compatible replica is the workaround.
narratives.jsonThis file is where intent lives. Without it the script still documents and still finds the physical problems, but cardinality, tenant scoping and natural keys can only be checked against a claim. If the file is missing:
-- PHASE 3 — GitHub integration).assertions from those blurbs and from the code — see
examples/narratives.json for the shape. The important ones:
tenant_table/tenant_column/require_rls, global_tables,
singleton_tables, cardinality (parent, child, expect 1:1|1:N, and a one-sentence why
the docs print beside the relationship — set require_relationship_notes: true to be told
about every foreign key that still has none; add columns when a table has two foreign keys
to the same parent, so each gets its own sentence),
natural_keys, exclusive_arcs.# ${CLAUDE_PLUGIN_ROOT} is the folder this SKILL.md lives in. Its one dependency is installed
# with the plugin; if node_modules is missing there, run `npm ci` in that folder first.
node ${CLAUDE_PLUGIN_ROOT}/scripts/archlens.ts /tmp/schema.sql --narratives narratives.json --out docs/database
Read the summary it prints, then docs/database/FINDINGS.md. Open
docs/database/schema.json for the model (tables → columns, fks with
inferred cardinality, indexed, unique, nullable; referenced_by;
rls_enabled; findings). Do not re-parse the SQL yourself.
Work through references/review-checklist.md. It is organised as questions
the script cannot answer. Anchor every observation to a table or column
name and to the narrative sentence it contradicts. If you can't point at
either, it isn't a finding, it's a preference — leave it out.
Specifically produce:
fks[].cardinality and
fks[].unique. The script only checks the pairs listed in
assertions.cardinality; you check the rest of the prose.blast-radius finding) is high; adding a
CHECK to an empty column is near zero.docs/database/REVIEW.mdUse this structure:
# Schema review — <database title> — <date>
## Verdict (3 sentences: is this model sound, what is the one structural risk)
## What this schema is (2 paragraphs, from the narratives + hub tables)
## Mechanical findings (counts by severity, the five that matter most, link to FINDINGS.md)
## Cardinality: claimed vs enforced (table: relationship · narrative says · schema enforces · gap)
## Where the next change will hurt (3–5 scenarios as above)
## Recommended changes, ranked (each: change · why · fix SQL or migration outline · cost)
## Assertions added to narratives.json (the ratchet — list them)
Every judgment finding that can be phrased as data goes into
narratives.json under assertions (a cardinality pair, a natural key, an
exclusive arc, a singleton). Re-run the script; those findings now appear
in FINDINGS.md mechanically and will fail CI if regressed. The review
gets shorter every time; the linter gets stronger.
--fail-on error on any change to the DDL path.PostToolUse on Write|Edit matching the schema file
→ run the script, surface new findings in the session.docs/database/ so the docs and the review live next to the code.domain-coverage, primary-key, fk-index, fk-nullable, fk-on-delete,
cardinality (asserted pairs), natural-key (asserted), junction-uniqueness,
undocumented-enum, soft-delete-unique, polymorphic-reference,
exclusive-arc, timestamp-tz, money-float, tenant-derivable,
tenant-unscoped, rls-missing, rls-no-policy, orphan-table,
singleton-table, undocumented-relationship (only with require_relationship_notes), fk-cycle, blast-radius, wide-table.
Each finding carries detail (what the schema allows and why it hurts),
suggestion, and where possible fix_sql. Quote them; don't paraphrase
them into something weaker.
Write for the engineer who has to defend the change to a reviewer. Every finding: what is allowed today → the concrete bad thing that follows → the smallest fix. No "consider", no "best practice says". If something is fine, say it is fine and why — a review that only lists problems is not trusted.
README.md (opens in a new tab)examples/narratives.json (opens in a new tab)examples/out/FINDINGS.md (opens in a new tab)examples/out/README.md (opens in a new tab)examples/out/REVIEW.md (opens in a new tab)examples/out/domains/approvals.md (opens in a new tab)examples/out/domains/approvals.svg (opens in a new tab)examples/out/domains/auth.md (opens in a new tab)examples/out/domains/auth.svg (opens in a new tab)examples/out/domains/billing.md (opens in a new tab)examples/out/domains/billing.svg (opens in a new tab)examples/out/domains/github.md (opens in a new tab)examples/out/domains/github.svg (opens in a new tab)examples/out/domains/permission.md (opens in a new tab)examples/out/domains/permission.svg (opens in a new tab)examples/out/domains/tenant.md (opens in a new tab)examples/out/domains/tenant.svg (opens in a new tab)examples/out/erd.svg (opens in a new tab)examples/out/index.html (opens in a new tab)examples/out/schema-3d.html (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (greenstevester/archlens-postgres) — no native marketplace selected
npx claudepluginhub p/greenstevester-db-architecture-reviewer2 plugins in one repository ship this exact skill · first indexed Sep 5, 2026