/jstack:eng-concurrencyfrom jstack
Use when a change touches queues, background jobs, webhooks, retries, cron, sync, locks, approvals or anything that can run twice, late, in parallel or not at all. Commit point, idempotency key, one retry owner.
Ships in jstack. 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.
A distributed step can fail after it did its work and before it said so, and nobody can tell those apart from outside. The recipe: at-least-once delivery, idempotent effects, state you can reconcile, and success recorded only after the effect is durable. Every queue, webhook or long job names its commit point, its idempotency key and the one layer that retries.
/preflight): answer the questions for the task's tier (S: MUST, M: + SHOULD, L: all + a pre-mortem). An answer that needs a number gets a number or "unknown, measure first". Copy the budgets that apply into the pre-flight with how each is measured./unslop): the static red flags run in tools/unslop/scan.mjs; the review agent reads the diff for the eyes ones. A red flag is a hypothesis until a confirm recipe produces evidence that a second agent reproduces.checks.json in this folder (triggers, questions, budgets, rules, verify). Projects tune it in .jstack/unslop.json (rule modes, waivers, extra questions and rules).MUST (asked at every tier)
conc.q.commit-point What is the commit point? Name the line after which the work is durable. Is any done/seen/200 written before it? (answer as: text; prevents: silent-loss)conc.q.idempotency-key What makes two of these the same, and which database constraint enforces it? (answer as: text; prevents: duplicates)SHOULD (tier M and L)
conc.q.time-limit Where does this run, and what is its hard time limit? If the worst case is over it, it needs a queue or workflow with a status, not the request. (answer as: number; prevents: killed-mid-way)conc.q.retry-owner Who retries, how many times, with what backoff and budget? Exactly one layer. Which errors are not retryable? (answer as: table; prevents: retry-amplification)conc.q.twice-at-once If this runs twice at the same moment, or crashes halfway and restarts, what does the user see? (answer as: text; prevents: duplicates, stuck-state)conc.q.lease What proves the owner of a RUNNING row is alive (lease or heartbeat), and what moves it out when it is not? (answer as: text; prevents: stuck-state)DEEP (tier L, with the pre-mortem)
conc.q.ids-not-positions Do long-lived references point at ids or at positions and copies? What version check stops a stale writer? (answer as: text; prevents: skip-or-rerun)conc.q.state-exits Draw the state machine, including approved, replaced and cancelled. What is every state's exit? (answer as: diagram; prevents: orphan-intent)conc.q.typed-outcome Does every tool or endpoint result say changed / unchanged / rejected / failed in a typed field, not only in prose? (answer as: schema; prevents: no-op-read-as-done)conc.q.shared-resources Which shared resources (git refs, worktree, ports, build slot, DB rows, cache keys) does this touch that another agent or instance also touches? Pre-mortem: it ran twice and lost one; why? (answer as: list; prevents: clobbered-shared-state)Defaults with their source. The project file .jstack/budgets.json wins; null means the project sets it the first time a task touches it (pre-flight turns that into a measure-first task).
| key | default | unit | how measured | source |
|---|---|---|---|---|
conc.duplicates_per_10k | 0 | count | duplicate-effect query: GROUP BY idempotency key HAVING count(*) > 1 | Stripe idempotency keys (2017); IETF Idempotency-Key draft |
conc.stuck_running_rows | 0 | count | RUNNING rows whose heartbeat is older than 2 leases | Gray & Cheriton, Leases, SOSP 1989 |
conc.attempts_per_request | 3 | count | attempts per logical request from logs (retry ratio under 10% per client) | Google SRE book ch. 21 (2016) |
A red flag is a hypothesis. /unslop turns it into a finding only with evidence (see Confirm recipes).
| id | what it looks like | why it is slop | detector | severity |
|---|---|---|---|---|
conc.empty-catch | Swallowed error (empty catch, or .catch that returns nothing) | The failure disappears: the caller marks the item done and the sender never retries. | static conc.empty-catch (regex) | high |
conc.except-pass | Swallowed error in Python (except: pass) | Same as an empty catch: the error is gone and the work looks done. | static conc.except-pass (regex) | high |
conc.retry-no-jitter | Retry loop in a file with no backoff or jitter | Fixed or zero delay retries in lockstep (thundering herd) and multiply load at every layer. | static conc.retry-no-jitter (regex) | medium |
conc.status-before-work | Status set to DONE/SEEN/200 before the awaited work | Success recorded before the effect is durable: a crash in between loses the item. | review agent (eyes) | high |
conc.check-then-insert | findFirst/SELECT then create on the same key with no unique constraint or upsert | Two concurrent runs both see nothing and both insert. | review agent (eyes) | high |
conc.unawaited-promise | Fire-and-forget promise (void call, .then without return/catch) | The work can die silently and nobody records an outcome. | eslint, else eyes | medium |
conc.running-without-lease | RUNNING/PROCESSING state with no heartbeat or lease column | No reaper is possible, so a killed worker leaves the row RUNNING forever. | review agent (eyes) | medium |
conc.position-cursor | Persisted array index or position used as a cursor | An insert before the cursor makes the next step skip or repeat. | review agent (eyes) | medium |
conc.timing-in-comment | Timing constants related only by a comment | Someone edits one value and the 'must stay below' relation breaks silently. | review agent (eyes) | low |
conc.prose-outcome | Tool or endpoint returns prose ('ok', 'kept as is') with no typed outcome | The caller (often a model) reads a no-op as success. | review agent (eyes) | medium |
conc.timeout-mismatch | Caller timeout shorter than the work it waits for (the caller gives up while the callee keeps going) | The caller reports failure while the effect still lands, and its retry runs the work twice. | review agent (eyes) | high |
conc.second-writer | Background result written into a conversation, document or session the user is acting in, with no owner or ordering check | Two writers interleave: the background answer lands in the middle of what the user is doing. | review agent (eyes) | medium |
conc.temporary-state-flip | Status flipped to a temporary value for the length of a job and restored from a snapshot in finally | Two overlapping jobs snapshot each other's temporary value, a killed job never restores, and the restore overwrites changes made meanwhile by the user or another path. | review agent (eyes) | medium |
conc.poll-by-time | Waiter takes the newest result row after its start time instead of the row its own request produced | A concurrent or leftover job's result is returned (and sometimes deleted) as this run's. | review agent (eyes) | medium |
conc.write-after-await | Row read, then a slow network or model call awaited, then written by id with no version or updated_at predicate | An edit landing during the await is silently overwritten by data validated against the old snapshot. | review agent (eyes) | medium |
conc.once-caches-failure | Once/dedupe wrapper caches every resolved value while the wrapped call returns failures as values | An outage turned into { ok: false } is replayed for the cache lifetime and the retry never reaches the dependency. | review agent (eyes) | medium |
conc.empty-catch: failing-test: make the awaited call throw; assert the item is retried, failed or dead-lettered, never marked done Fix direction: rethrow, or record the failure and let the single retry owner decide. Known false positives: best-effort cleanup with a comment naming why loss is acceptable.conc.except-pass: failing-test: raise inside the try; assert the outcome is a recorded failure Fix direction: re-raise, or log with context and record a failed state.conc.retry-no-jitter: failing-test: dependency returns 503 for 30 s under fake timers; assert attempts <= 1 + budget and delays grow Fix direction: capped exponential backoff with full jitter, at one layer only.conc.status-before-work: failing-test: throw after the status write; assert the item is not left DONEconc.check-then-insert: failing-test: 3 concurrent calls via Promise.all; assert exactly one rowconc.unawaited-promise: repro-script: kill the process mid-run; count started vs finished recordsconc.running-without-lease: failing-test: kill the worker after the side effect; assert retried or failed within lease + intervalconc.position-cursor: failing-test: complete step k, insert a step before k, advance; assert no skip and no repeatconc.timing-in-comment: failing-test: assert HEARTBEAT_MS * 3 <= STALE_AFTER_MSconc.prose-outcome: repro-script: run the no-op path; show the reply cannot be told apart from successconc.timeout-mismatch: failing-test: make the callee take the caller timeout + 5 s; the caller reports failure while the effect lands, or a retry runs it twice Fix direction: caller timeout above the callee timeout, or hand off to a job with a status.conc.second-writer: failing-test: a user action and a background result arrive in the same tick; assert one ordered outcome and nothing overwrittenconc.temporary-state-flip: failing-test: run two overlapping jobs, or kill one mid-run, or change the status during the job; the final status is wrong Fix direction: keep the in-progress marker in its own column or lease with an expiry, restore with compare-and-set on the value you wrote, and give stuck markers a reaper.conc.poll-by-time: failing-test: insert a matching row from another job during the wait; the waiter returns it Fix direction: correlate by job id or idempotency key carried from the request to the result.conc.write-after-await: failing-test: change the row inside the awaited stub; the final write overwrites it Fix direction: conditional write (where version = read version) and retry or refuse on conflict.conc.once-caches-failure: failing-test: wrapped call returns a failure result, then success; the second call must run Fix direction: cache only success results, or make the callee throw on failure.Run in this order after the change; each line is a pass criterion.
conc.v.dup-delivery 3 concurrent deliveries of one payload -> exactly 1 effect (test; test runner + Promise.all)conc.v.idempotence run(op); run(op) leaves the state equal to run(op) over generated inputs (test; fast-check / Hypothesis)conc.v.kill-mid-step kill the worker after the side effect -> row retried or failed within lease + interval, never stuck (test; test harness + process kill)conc.v.fault-after-commit throw after the commit-point candidate -> item retried or dead-lettered, never marked done (test; test doubles)conc.v.retry-storm dependency 503 for 30 s -> attempts <= 1 + budget, delays growing with jitter (test; fake timers + call counter)conc.v.stuck-and-dup-queries stuck-row, duplicate-effect and orphan-intent queries return 0 (measure; SQL)conc.v.state-liveness every non-terminal state has an exit (enum-driven test) (test; unit test / TLA+ for critical flows)Loaded by tools/unslop/classify.mjs when the task says "queue", "background", "job", "webhook", "retry", "retries", "schedule", "cron", "sync", "duplicate", "duplicates", "concurrent", or touches **/queue*/**, **/jobs/**, **/workers/**, **/webhook*/**, **/cron/**, **/*retry*, **/*worker*, **/*scheduler*.
| tool | how to run it | what number to read | valid only when | trap |
|---|---|---|---|---|
| duplicate-delivery test | Promise.all of 3 identical deliveries in the test runner | exactly 1 effect | real database constraint, not a mock | testing the check-then-insert with no concurrency |
| fault injection | make the awaited call throw after the commit-point candidate | item retried, failed or dead-lettered, never marked done | the real state transition code | asserting only that an error was logged |
| fake timers + call counter | dependency returns 503 for 30 s | attempts <= 1 + budget, delays grow with jitter | one retry layer configured | retries inside retries |
| stuck-row and conservation queries | SQL: RUNNING with stale heartbeat; in = done + failed + pending | 0 stuck; the equation holds | run daily, alert on drift | no lease column, so nothing can be reaped |
| symptom | measure | cause | fix |
|---|---|---|---|
| Work silently lost | fault-inject after the side effect | done/seen written before the work | record success after the effect; one retry owner |
| Duplicates under load | concurrent deliveries in a test | no idempotency key or unique constraint | natural key + unique index + upsert |
| Rows stuck in RUNNING | stale-heartbeat query | worker killed mid-step, no lease | lease or heartbeat + reaper on read |
Dated sources with their verification tags are in SOURCES.md. Claims tagged unverified there are not stated as fact here.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jayjayholic/jstack --plugin jstack31 skills in this plugin
/domain-modelingBuild and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR./eng-agent-disciplineUse for every coding-agent task, and when writing briefs, reports, READY messages, docs or handoffs. Quote the ask, stay in owned files, cite sources for claims, verify yourself before claiming done, report with evidence./eng-ci-gitUse when a change touches CI, build, typecheck, merges and rebases, branches and worktrees, release trains, exported signatures or renames. Gate the merged tree, find every caller, resolve conflicts by reading them.