/ratchet-backend:glide-mqfrom ratchet-backend
Use 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.
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.
These rules are for runtime code. A test, or a one-off script on a throwaway queue, may wait for a job to finish, keep finished jobs to inspect them, and add a job with no options. A script that runs against a production queue follows every rule here.
Names below are the glide-mq API: the job option ordering: { key, concurrency }, the worker
option concurrency, lockDuration, limiter: { max, duration }, job.moveToDelayed(timestamp),
queue.addAndWait(), and job.waitUntilFinished(). Read
lease patterns for the lease shape,
job design for payloads, replay, schedulers, and flows, and the
transition matrix for a job that calls a provider and writes state.
Jobs a user is waiting on get their own queue. A lane protects a family's share of one worker pool; it does not protect latency when every slot is busy with background work. A separate queue has its own workers, so a backfill cannot delay a signup email.
A job whose work commits with, or is triggered by, a database transaction gets its own queue. An outbox relay and a payment or ledger write are examples. Slow or bulk jobs on a shared queue can hold every worker slot and delay them, and a stalled relay or ledger write leaves committed rows unpublished or unposted. A queue of its own lets you set its concurrency, retries, backoff, and rate limits for that work alone.
Never enqueue a job and wait for its result. No addAndWait, no waitUntilFinished, in a
request handler or in another job. The caller holds a connection and a request slot for as long
as the queue is backed up, and a deploy or timeout loses the result. Return the job or resource
id, write the outcome to a row, and let the client poll that resource.
// Rejected: the request lives as long as the queue is slow.
const report = await reports.addAndWait('build', { reportId })
// Accepted: 202 with an id; the client polls GET /reports/:id until status is final.
await reports.add('build', { reportId }, { jobId: reportId })
return reply.code(202).send({ id: reportId })
A queue is ephemeral; state lives in PostgreSQL. A job is a delivery attempt, not a
record. Finished jobs, completed and failed, are removed at once or kept for a short, bounded
window: removeOnComplete and removeOnFail are true, a small count, or an age, never
false and never a default that keeps everything. A failed job kept forever grows without
bound, holds its job id so a re-add is dropped, and hides state from anyone reading SQL.
Recover from rows, not from the queue. No code reads a job's state to learn whether work is done, and no reconciler scans failed jobs or a dead-letter queue for work to redo. The row says what is pending, done, or failed, and a sweep re-enqueues from it, so a failed job's side effect is settled or explicitly abandoned, not left half done.
What the row records depends on the work. Legal, privacy, and irreversible work (a takedown, an account deletion, a payment, a moderation action) keeps a row per attempt with status, error, time, and actor, which must survive a flush of the queue store. Work that can be recomputed (a feed, a count, a cache) keeps none; the next sweep picks up what was lost.
Share a queue by default; add one only when sharing cannot work. Put limits on the job, not
the queue: group ordering.concurrency, rateLimit, or tokenBucket, and per-job
lockDuration and timeout. A new queue is justified by a different worker class, a batch
worker, a limiter a group cannot express (a token bucket charged by actual usage), or a domain
that needs both a domain-wide cap and per-entity ordering keys, since a job has one key.
limiter is for an external rate limit only, such as a provider's requests per minute. It
pauses fetching for the whole worker, so using it to slow an internal family throttles every
job on that queue. Shape internal load with ordering.concurrency. Never throw
RateLimitError or call worker.rateLimit() from a worker shared by several families: it idles
all of them. Defer the one job with job.rateLimitGroup or job.moveToDelayed.
A job family outsiders can flood gets its own lane. Inbound webhooks, user-triggered imports, and anything a client can enqueue in bulk must not share an ordering key with ordinary work.
ordering. An ungrouped job in a shared queue competes for
every worker slot, so a flood of it starves other families. Give each job an
ordering.key prefixed with its domain name and an explicit ordering.concurrency.ordering.concurrency is a global cap; the worker concurrency is per process. The key's
cap holds across all workers and processes. The worker option only bounds one process's
active jobs. Never size lane caps to sum to the worker option. Take caps from runtime
configuration, and give batched families a low cap.priority. Jobs sharing an ordering key run in enqueue order whatever
their priority. Work that must not wait behind a flood, and dispatchers that rely on
priority, get their own lane.
Ordering keys are the orchestration layer; add none on top.ordering.concurrency cap. The caps
of every holding lane that can run in one process add up to less than that process's pool size,
and the connections left over are sized for the other jobs' load, since those jobs share them.
Jobs that borrow a connection per query share a small pool well. Do not clamp a whole worker's concurrency to the pool size;
that throttles every family to fix one. postgres-node-performance-tuning owns the pool rules.Read worker tuning for globalConcurrency, mixing ranked and
priority-0 jobs, and lockDuration. Read lease patterns for a job
moved to delayed and for lease mechanics.
removeOnComplete: true and removeOnFail: true on that job name; numeric retention keeps the
payload. A waiting or active job still holds it.add, scheduler, and flow node sets attempts, backoff, retention, and priority
explicitly. Throw UnrecoverableError for a failure a retry cannot fix. Honor an external 429
Retry-After by deferring the job without spending an attempt.Dispatchers, paged fan-out, and job-id deduplication follow bounded iteration. A lease for work that spans an external call replaces holding a PostgreSQL transaction or advisory lock open across it; see performance patterns.
A consuming repository owns queue names, lane keys, caps and their configuration source, the lease helper, 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./http-api-designUse when writing or reviewing an endpoint, route handler, service layer, or an edge or CDN worker in front of an API, choosing identifiers in URLs, storing tokens or one-time codes, or setting cache headers. Shape an HTTP API around resources, thin route handlers, user-facing identifiers, and one owner each for secret storage and cache headers.