Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

relational-database-design

Helps a coding agent design, review and change relational database schemas without the usual accidents. Nothing in it is tied to one agent: the skill follows the Agent Skills format, the scripts are plain Bash, and the repository carries a manifest for each plugin system.

What is in it

Part What it does Works in
Skill skills/relational-database-design The method: establish facts, size the work, design from defaults that each carry a reason, verify by running, hand back in a fixed format. Twelve reference files load on demand. Any agent that reads SKILL.md
Script scripts/pg_audit.sh Read-only audit of a PostgreSQL schema. Reports mechanical defects so the agent does not have to remember to look. Anywhere with Bash and psql
Script scripts/scratch_pg.sh Starts and deletes a throwaway PostgreSQL so DDL and migrations can be run before they are proposed. Anywhere with Bash and Docker or PostgreSQL
Hook hooks/guard_destructive.py Checks a command before it runs and stops data-destroying ones for the user. Wired automatically in Claude Code. Other agents: see docs/hooks.md.

The scripts live inside the skill folder, so the skill is complete on its own.

Install

Replace OWNER/REPO with this repository.

Agent How
Claude Code /plugin install relational-database-design --marketplace OWNER/REPO (2.1.275 or later). Earlier: /plugin marketplace add OWNER/REPO, then /plugin install relational-database-design@simon-tulett-plugins.
GitHub Copilot CLI copilot plugin marketplace add OWNER/REPO, then copilot plugin install relational-database-design@simon-tulett-plugins.
Gemini CLI gemini extensions install https://github.com/OWNER/REPO
Codex, Cursor, VS Code, Kiro and other Agent Plugins clients Add the repository through the agent's plugin manager. They read the root plugin.json.
Any agent that reads SKILL.md npx skills add OWNER/REPO installs the skill alone.

A private repository needs git credentials for it on the machine doing the install.

If a plugin is also turned on for a claude.ai account, Claude Code receives it a second time as relational-database-design@synced. Keep one of the two enabled.

Which file each agent reads

File Read by
plugin.json Agent Plugins 1.0 clients: Codex, Cursor, GitHub Copilot, VS Code, Kiro, ChatGPT
.claude-plugin/plugin.json, .claude-plugin/marketplace.json Claude Code. Copilot CLI also reads the marketplace file.
.codex-plugin/plugin.json Codex
gemini-extension.json Gemini CLI
hooks/claude-code.json Claude Code only, through its manifest

There is deliberately no hooks/hooks.json. Several agents load that path automatically, each expecting its own format, and some block every command when a hook errors.

Requirements

  • python3 (3.8 or later) for the hook. Without it the hook does nothing.
  • psql for the audit.
  • Docker, or a local PostgreSQL install, for the scratch database.
  • macOS or Linux. The scripts are Bash and are not written for Windows.

The hook

It stops, for the user's decision:

  • DROP of a table, schema or database; TRUNCATE; ALTER TABLE ... DROP COLUMN; DELETE or UPDATE with no WHERE (or WHERE 1=1)
  • reset-style commands from Prisma, Drizzle, Rails, Django, Alembic, Laravel, Flyway, Liquibase, Supabase and others
  • deleting volumes, databases, branches, backups or clusters through Docker, Railway, Neon, Supabase, PlanetScale, Fly, Heroku, AWS, Google Cloud, Azure, kubectl, Terraform or a raw API call
  • switching off a protection: row-level security, triggers, foreign-key checks, or setting Prisma's AI consent override

It reads .sql files named in the command, and lets through SQL aimed only at the scratch database that scratch_pg.sh started.

Where the agent can pause a command for approval (Claude Code, Copilot CLI) the hook asks. Where it cannot (Codex, Gemini CLI, and Cursor by default) the hook blocks, and the user runs the command themselves if they want it run.

What it cannot see. It reads command text. SQL that a migration tool applies from files the command does not name (prisma migrate deploy, flyway migrate, alembic upgrade head), SQL built inside a program, and anything run through a tool the hook is not attached to passes unchecked. Treat it as a tripwire for mistakes. The control that holds is a database role that cannot do the damage: give agents a read-only role, and keep credentials with drop or delete rights out of the repository.

The audit

skills/relational-database-design/scripts/pg_audit.sh postgresql://user@host:5432/dbname

fix findings are almost always defects: a foreign key with no index, an invalid or redundant index, a table with no primary key, a constraint left NOT VALID, a foreign key whose type differs from its target, a row-level security policy of true, the money type. review findings are legitimate in some designs: cascading deletes, nullable columns in unique indexes, row-level security that is not forced, timestamp without time zone, 32-bit keys, names that need quoting.

It runs in a READ ONLY transaction and reads system catalogs only.

The scratch database

skills/relational-database-design/scripts/scratch_pg.sh start --version 16
skills/relational-database-design/scripts/scratch_pg.sh stop

Listens on 127.0.0.1 port 54329 by default. State lives in /tmp/rdd-scratch (override with RDD_SCRATCH_DIR, for both the script and the hook).

Tests

python3 tests/test_guard.py      # hook: 78 commands, every agent's event format, manifests, the hook command itself
bash tests/test_scripts.sh       # starts a scratch database, runs the audit on a defect fixture and a clean schema

What has and has not been tested

  • Tested: the hook's decisions and its replies in each agent's documented event format; the scripts on PostgreSQL 16 with local binaries, as root and as an ordinary user; the Claude Code manifests with claude plugin validate, and a marketplace install into Claude Code.
  • Not tested: loading in Codex, Cursor, Copilot CLI, Gemini CLI, VS Code or Kiro; the hook inside a live session of any agent; the Docker path of scratch_pg.sh; PostgreSQL versions other than 16.

skills/relational-database-design/evals/ holds three behaviour tests for the skill, in the layout claude plugin eval reads.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages