bunqueue-fixing-bugs
Skill601 starsChanged 17 days agoMITView on GitHub
Runs the bunqueue reproduce-first bug workflow. Use when a bug, regression, crash, wrong result, data loss, hang or flaky behavior is reported in bunqueue (server, client, workflow engine, CLI, MCP, SDKs), when a GitHub issue describes a defect, or when a skeptic, model-campaign or CI finding needs a fix. Covers the regression test that fails first, subagents that prove the fix, docs and changelog in the same change, the gates, and skeptic rounds until PASS. Not for features without a defect, or for only running the gates (bunqueue-running-gates).
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/bunqueue/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- sdk/CLAUDE.mdCLAUDE.md
- bunqueue-devSkill
- bunqueue-releasingSkill
- bunqueue-running-gatesSkill
- bunqueue-running-machine-gatesSkill
- bunqueue-working-autonomouslySkill
- bunqueue-working-sessionsSkill
- bunqueueSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Start the session first (bunqueue-working-sessions): one work item, in-progress, with its branch.
- Very specific: line 22
Write the regression test before touching runtime code.
- Distinctive: line 28
Run it on the unfixed code and read the failure:
- Very specific: line 38
Follow the test hygiene of docs/testing.md: fresh server, port: 0, unique queue names and temporary SQLite paths, closed clients, polling …
- Distinctive: line 49
When the cause is unclear, let two or three subagents try different hypotheses in parallel and choose by evidence: the regression test, the …
- Distinctive: line 52
Never weaken or rewrite the reproducing test to make it pass.
- Distinctive: line 54
Keep the fix compatible: change the broken behavior only.
- Very specific: line 68
Run bun run test:model first when the change touches anything on its trigger list in CLAUDE.md.
- Very specific: line 86
Follow bunqueue-running-gates: bun run test:sandbox after any code change (about 9 minutes.
- Very specific: line 108
After the last fix, the gate evidence must describe the final staged tree.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Fixing a bunqueue bug
The rules this procedure serves live in CLAUDE.md and AGENTS.md: reproduce before fixing, gates before a commit, the skeptic before every commit and push, docs and changelog in the same change, and nothing is committed or pushed without the user's explicit request. This skill is the order of work and the traps found in real sessions.
Start the session first (bunqueue-working-sessions): one work item, in-progress,
with its branch.
1. Reproduce: the test comes first
- Write the regression test before touching runtime code. Name it after the issue or
symptom:
test/repro-issue-<n>-<topic>.test.ts; a model-campaign finding becomestest/repro-model-<topic>.test.ts. - Drive the public or real persistence path (Queue/Worker over TCP or embedded, a real SQLite file) and assert both the returned result and every counter or state the bug corrupts. A unit test of a private helper passes even when the wiring is broken.
Run it on the unfixed code and read the failure:
BUNQUEUE_EMBEDDED=1 bun test test/repro-issue-<n>-<topic>.test.tsIt must fail on the assertion that describes the bug. A typo, a missing import, a timeout, a port clash or a setup error is a failure for the wrong reason and proves nothing; fix the test until the failure message names the bug. Keep that output: the Definition of Done asks for a test that failed before the fix.
- Follow the test hygiene of docs/testing.md:
fresh server,
port: 0, unique queue names and temporary SQLite paths, closed clients, polling with a deadline instead of fixed sleeps.
2. Fix with subagents, judged by the test
- Brief each subagent like a peer: the failing test path and its output, the files that
are likely involved, what is ruled out, and the constraints (scope, 300 lines per
file, the lock hierarchy, no
awaitinside a shard critical section). Ask for the smallest change that makes the test pass without editing the test. Templates for this brief and the skeptic's: references/briefs.md. - When the cause is unclear, let two or three subagents try different hypotheses in parallel and choose by evidence: the regression test, the neighbouring test files, and the model campaign when it applies.
- Never weaken or rewrite the reproducing test to make it pass. If the test itself was wrong, fix it and show again that it fails on the unfixed code.
- Keep the fix compatible: change the broken behavior only. Anything else a user could observe (a default, a signal, a log line, an error message) is a behavior change that needs its own decision and, at release time, an Upgrade notes entry.
3. Prove it
BUNQUEUE_EMBEDDED=1 bun test test/repro-issue-<n>-<topic>.test.ts # now passes
BUNQUEUE_EMBEDDED=1 bun test test/<neighbouring files>.test.ts # still pass
bun run typecheck
bun fmt --check --no-script src test
git diff --checkRun bun run test:model first when the change touches anything on its trigger list
in CLAUDE.md. Iterate in an isolated OrbStack
development Machine where you can; a macOS-host run is diagnostic only, and the gates
are the sandbox and the Machine gate (step 5).
4. Docs and changelog in the same change
- The module's
docs/features/<slug>.md, plus docs/data-model.md for a type, table, TCP command, endpoint, env var or default, and docs/architecture.md for a data-flow change. - An entry under the
## [Unreleased]heading of the changelog, in its### Bug fixessubsection (add the subsection if the section has none yet): the user-visible symptom, the cause, the fix, and any behavior change. Numbers only from real measurements.
5. Gates
Follow bunqueue-running-gates: bun run test:sandbox after any code change (about
9 minutes; run it in the background), bun run test:sandbox:sdk when sdk/ changed,
and the final Linux validation in a fresh Ubuntu 24.04 Machine
(bunqueue-running-machine-gates).
Record the gated tree with git write-tree and review summary.md, not just the exit
code.
6. Skeptic rounds until PASS
- Stage the complete change first: the skeptic reads
git diff --staged, so an unstaged hunk is invisible to it. - Invoke the
skepticsubagent (profiles.claude/agents/skeptic.mdand.codex/agents/skeptic.toml) with the bug, the reproducing test and its before/after output, the gate results and their artifact paths. FAIL: fix every concern, rerun what it touches (the gate too, if code changed), and invoke it again.CONDITIONAL: fix what you can; the rest needs the user's explicit confirmation.PASS: commit only if the user asked for a commit.- Expect more than one round. Past rounds found real defects every time: a server
started under
nohupthat a newSIGHUPhandler changed from "ignored" to "reloads", a Docker restart policy that treatsdocker kill -s HUPas a manual stop, a rebound unix socket that lost its mode and owner, and log lines that claimed more than had happened. Answer a concern with a test or a fix, not an argument. - After the last fix, the gate evidence must describe the final staged tree; prove any later delta (bunqueue-running-gates).
Gotchas
git stashis shared by every worktree of the repository; another session can pop your entry. Set work aside with a temporary commit instead.- A test that reads a new root-level file (a fixture, a config) passes on the host and
fails in the sandbox with
ENOENTunless Dockerfile.test copies it andDockerfile.test.dockerignoreallow-lists it.test/itself is copied. - To show that an edited reproducing test still fails on the old code, run it in a
temporary
git worktree add --detach <dir> HEADwith the test copied in andnode_modulessymlinked, thengit worktree remove <dir>; never revert files in the shared worktree. - Bun discovers test files in readdir order, which differs between macOS and Linux; a
leaked embedded manager or timer shows up as a failure in a different file. Close
every Queue, Worker and manager, and claim the singleton with
beforeAll(shutdownManager)in suites with a persistentdataPath. - A fix found while fixing something else is a new
not-starteditem infeature_list.json, not part of this change. - A host-only green run is diagnostic. The Linux sandbox has caught failures the macOS host passed (package layout, readdir order, missing files in the image).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

