/ratchet-backend:postgres-partitioning-uuid-v7from ratchet-backend
Use when writing or reviewing a partitioned table, a retention or partition migration, a query against a partitioned table, or a decision on whether to partition. Design PostgreSQL partitioning and partition pruning around UUIDv7 keys.
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.
For schema names, references, and canonical table shapes, read postgres-schema-design.
Partition only after lifecycle, retention, and query predicates show that it helps.
Age-based retention of time-ordered rows uses UUIDv7 range partitions and drops whole partitions. Every history or audit table has a retention window, even one of years.
A pointer from a live row into a partitioned table never blocks a partition drop. An FK into a
partition blocks DROP, and blocks DETACH (also CONCURRENTLY) while any row references it,
whatever its ON DELETE action, so CASCADE and SET NULL do not help. Prefer, best first: no
pointer (state on the live row, or an indexed latest lookup bounded at the retention cutoff, which
fits only a parent that cannot outlive the window and a reader that tolerates changes sorting out
of commit order; see history retention);
the FK kept and the retirement step clearing the pointers into a partition before it detaches
it, then dropping any FK on that partition itself (it survives the detach and does not catch a
new reference, so writers are held off, and earlier writers drained, from before the cleanup
until the drop) and the table;
a pointer with no FK that readers tolerate going missing, with the reason stated.
Never RESTRICT into history that will be dropped. See
retiring a partition.
A row under legal hold is copied out before its partition drops; it never stays behind to
block the drop. Copy it to a hold table, or, where readers must keep reading the parent and
nothing may delete rows, to a fresh partition of the same range that replaces the old one.
Never to DEFAULT, which spans every range and empties only by DELETE. See
retiring a partition. A bounded DELETE sweep is for a table too small or too short-lived
to be worth partitioning, and the table COMMENT states that reason.
Treat a UUIDv7 as time ordered. Where the meaning matters, keep an explicit business timestamp.
Partition time-ordered data by RANGE on the UUIDv7 id, with a default partition. HASH
spreads every time window across all partitions, so nothing prunes and nothing can be dropped.
Prune with id bounds generated from time (id >= min_uuidv7($time)). Extracting a timestamp
from the id in a predicate hides the key from the planner.
Align the partition key, primary key, indexes, constraints, and query predicates so partition pruning is observable.
Add a parent lower bound to a read of a RANGE (id) child table by its parent's UUIDv7 id
(id >= min_uuidv7(parent time - skew)) only when both hold: every writer sets the parent column
at insert, to a parent that already exists, and never re-points it to a newer parent; and nothing
mints child ids from a historical time (imports, backfills, seeds). Counterexample: articles
clustered into a story created later are older than their parent, and the bound silently drops
them. See parent lower bound.
A statement that must read every partition declares that, with a reason, on the statement. Do not use a table-wide exemption: it also silences every future query on that table. See cross-partition reads.
Plan creation, retention, migration, and verification as one deployable lifecycle. Include rollback and independent-reader compatibility.
Read partition lifecycle before a schema or retention migration.
A consuming repository owns partition intervals, migration tooling, retention policy, and deploy sequencing.
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.