bunqueue-dev
Skill569 starsChanged 4 months agoMITView on GitHub
Internal skill for contributing to bunqueue - architecture, testing, code conventions, and development workflow
- Commits and pushes
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- sdk/CLAUDE.mdCLAUDE.md
- bunqueueSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 62
Run tests in fresh isolated OrbStack Machines on the Mac's native architecture.
- Distinctive: line 80
All product suites and the sandbox must pass.
- Distinctive: line 84
NEVER fix a bug directly. Always:
- Distinctive: line 85
Write a test that reproduces the bug
- Very specific: line 93
Update changelog in docs/src/content/docs/changelog.md
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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
bunqueue Development Guide
You are working on bunqueue, a high-performance job queue for Bun with SQLite persistence.
Architecture
bunqueue uses a sharded priority queue architecture:
- Shards: Auto-detected from CPU cores (power of 2, max 64). Jobs are assigned via
fnv1aHash(queue) & SHARD_MASK - Persistence: SQLite in WAL mode with a 10ms WriteBuffer for batching writes
- Transport: TCP (msgpack) on port 6789, HTTP on port 6790
- Two modes: Embedded (in-process) and TCP (client-server)
Request Flow
- PUSH: Client -> TcpPool -> TcpServer -> QueueManager -> Shard -> PriorityQueue -> WriteBuffer -> SQLite
- PULL: Client -> TcpServer -> QueueManager -> Shard -> PriorityQueue.pop()
- ACK: Client -> TcpServer -> AckBatcher -> Shard.complete() -> jobResults (LRU)
- FAIL: Client -> TcpServer -> Shard.fail() -> retry (backoff) OR -> DLQ
Directory Structure
src/
cli/ # CLI interface
client/ # SDK (Queue, Worker, FlowProducer, Bunqueue)
queue/ # Queue with DLQ, stall detection
worker/ # Worker with heartbeat, ack batching
tcp/ # Connection pool, reconnection
workflow/ # Workflow Engine (Workflow DSL, Engine, Executor, Store)
domain/ # Pure business logic
queue/ # Shard, PriorityQueue, DlqShard, UniqueKeyManager
application/ # Use cases and managers
operations/ # push, pull, ack, query, queueControl
infrastructure/ # Persistence, server, scheduler, backup
shared/ # Utilities (hash, lock, lru, skipList, minHeap)Workflow Engine
Located in src/client/workflow/. Pure consumer layer on bunqueue (no core modifications).
- workflow.ts — Fluent DSL:
.step(),.branch(),.path(),.waitFor() - engine.ts — Public facade: register, start, signal, getExecution, close
- executor.ts — Core logic: step execution, branching, compensation, signals
- store.ts — SQLite persistence for execution state (workflow_executions table)
- types.ts — StepContext, Execution, StepJobData, EngineOptions, etc.
- Export:
import { Workflow, Engine } from 'bunqueue/workflow'
Code Conventions
- MAX 300 lines per file - split if larger
- One concern per file (Single Responsibility)
- Export only what's needed
- Lock hierarchy:
jobIndex->completedJobs->shards[N]->processingShards[N]
Testing (MANDATORY before any commit)
Run tests in fresh isolated OrbStack Machines on the Mac's native architecture.
The canonical gate is Ubuntu 24.04 (4 CPUs, request 16 GiB memory, 32 GiB disk);
every release also uses Debian 13 on the same native architecture. On Apple
Silicon use arm64; GitHub Actions provides the independent native amd64
gate. A Rosetta-translated amd64 Machine is diagnostic only. Create Machines
with --isolated --isolate-network, never mount host paths or forward
credentials, transfer only a sanitized worktree snapshot, pin Bun to the CI
version, record effective cgroup limits, and delete each Machine after copying
its logs. Direct macOS-host runs are diagnostic only. Machine runs supplement
the mandatory Docker sandbox and never replace it.
bun test --parallel=4 # Unit tests (four isolated file workers)
bun scripts/tcp/run-all-tests.ts # TCP integration tests (~50 suites)
bun scripts/embedded/run-all-tests.ts # Embedded integration tests (~35 suites)
bun run test:sandbox # Additional container isolation gateAll product suites and the sandbox must pass. No exceptions.
Bug Fixing Process
NEVER fix a bug directly. Always:
- Write a test that reproduces the bug
- Launch subagents to fix the bug
- Prove the fix with a passing test
Publishing
After every commit:
- Bump version in
package.json - Update changelog in
docs/src/content/docs/changelog.md git push origin mainbun publish
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.

