/ratchet-backend:postgres-schema-designfrom ratchet-backend
Use when writing or reviewing a migration, a table, column, foreign key, or trigger, or before adding a table, trigger, counter, lease, cursor, or history table. Designs PostgreSQL tables, names, keys, relations, history, retention, and work-item and cursor tables, and picks the simplest design that is correct.
Ships in ratchet-backend. 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.
Read every applicable AGENTS.md first. Repository-local policy overrides these defaults.
Every table, trigger, lock, counter, and lease is something the next change has to keep correct. Before adding one, take the first rung that is correct, and name in the change the simpler rung you rejected and why:
WHERE guard, ON CONFLICT)LIMIT cap + 1)ratchet-workflows:change-review), then answer it on the rung the design is already on.CHECK; see relations.latest_*_id pointer to its history. Current state
is read from the newest history row only when the parent cannot outlive the history window;
otherwise it stays on the live row. A history table has a retention window, even one of years,
and a pointer into it never blocks dropping an old partition; see
history retention.CREATE OR REPLACE or CREATE INDEX IF NOT EXISTS for it elsewhere makes the definition in
force depend on which ran last; a migration that changes it says what it replaces.DEFAULT partition is not partitioned. Record the evidence
for partitioning and who owns retention, or keep an ordinary table.CHECK or a
foreign key uses is read on every write and stays.archived_at) to a boolean or a status column: it says when, and
null says not yet. A final result lives on the row that owns it, not on a row that merely
refers to it.ON CONFLICT DO UPDATE assigns
constants, never col = col + 1 or a volatile value.ON DELETE on every foreign key.
Index the referencing column. NOT NULL is written inline and needs no name. A generated name is not in the migration's text, so a later
migration that drops or alters the constraint has to guess it. See
naming.For row locks, advisory locks, and caps, use postgres-locking. For query shape, read performance patterns. For partition lifecycle, use UUIDv7 partitioning. For how jobs choose, cap, and resume over work-item and cursor tables, read bounded iteration. A consuming repository owns lifecycle, retention windows, migration strategy, and enforcement configuration.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub jongleberry/ratchet-stack --plugin ratchet-backend18 skills in this plugin
/bounded-iterationUse when writing or reviewing a sweep, scheduled job, reconciler, cleanup, dispatcher, backfill, or export - any loop that reads rows. Covers bounding the rows each run reads, sweeps that re-select their own writes, and effects that repeat on every run./error-handlingUse when writing or reviewing code that throws, catches, or matches an error, turns a failure into a response, or reports errors to a tracker such as Sentry, including a review of a diff that does. Covers one defined list of error codes, matching on type or code instead of message, details as attributes on the error, and reporting only errors someone can act on./event-handlersUse when writing or reviewing code that acts on an event or a state change - a serverless function, a queue consumer, a scheduled task, or a deploy or config hook - and above all one that sleeps or waits before it acts. React to the change instead of waiting a fixed time, de-duplicate by reading current state, and defer work the target is not ready for without losing it./expand-contract-migrationsUse when renaming or dropping a column or table, changing a column type, making a column NOT NULL, renaming an API or event field, splitting or merging tables, or changing a config shape that running code reads. Change a shape in separate deploys so old and new code never disagree./feature-rolloutUse when adding or reviewing a feature flag, a flag's default, rollout or rollback steps, or a change that adds a table, migration, service, or write path. Ship new behavior behind a flag that starts off, treat deploying and enabling as separate steps, and add no table or service that no entry point reaches./glide-mqUse when writing or reviewing a queue producer, worker, dispatcher, scheduler, or flow, choosing which queue or lane a job belongs in, deciding what a job payload carries, or handling a request that waits on a job's result. Design glide-mq queues, jobs, lanes, concurrency, rate limits, and replay safety.