{"id":"aaac286a-da44-426b-8450-b984d83cd34f","shortId":"XhcrKD","kind":"skill","title":"bun","tagline":"Use when using bun.lockb, bunfig.toml, bun install, Bun workspaces, Bun test, Bun runtime APIs, JS or TS scripts run with Bun, bundling, or Node compatibility checks for Bun.","description":"# Bun Skill\n\n<workflow>\n\n## Core Capabilities\n\n### 1. Runtime\n\nBun is a drop-in replacement for Node.js, focused on speed.\n\n- **HTTP Server**: `Bun.serve()` is faster than Node's `http` module.\n- **File I/O**: `Bun.file()` and `Bun.write()` are optimized.\n- **TypeScript**: Native support (no transpilation step needed for dev).\n\n### 2. Task & Test Runner\n\n- **Run Scripts**: `bun run script.ts` replaces `ts-node`.\n- **Test**: `bun test` is a Jest-compatible, ultra-fast test runner.\n\n<example>\n\n    ```bash\n    bun test --watch\n    ```\n\n</example>\n\n- **Package Manager**: `bun install` is significantly faster than npm/yarn.\n\n## High Performance & Integration Patterns (Vertebra)\n\nThis section details how to integrate Bun into high-performance, polyglot systems.\n\n### 1. Inter-Process Communication (IPC)\n\nWhen integrating with Rust/Python backends:\n\n- **Shared Memory (ShmRing)**: For latency < 10us, avoid piping JSON over stdout/stdin. Use shared memory ring buffers.\n  - *Pattern*: Pointers/offsets only passed over socket; data stays in shared memory.\n- **Unix Domain Sockets (UDS)**: Use `Bun.connect()` and `Bun.listen()` with abstract namespaces (Linux) or file paths (macOS) if Shm not available.\n- **Serialization**:\n  - Avoid `JSON.stringify` on hot paths.\n  - Use **Msgspec** (via bindings) or **Apache Arrow** (via `apache-arrow` js package) for zero-copy structure sharing.\n\n### 2. Native Bindings (FFI vs N-API)\n\n- **N-API (`napi-rs`)**: Preferred for stability and complex logic. It maps Rust Structs to JS Classes easily.\n- **Bun FFI (`bun:ffi`)**: faster for simple C function calls but harder to maintain for complex objects.\n  - *Recommendation*: Use `napi-rs` for business logic, `bun:ffi` only for ultra-thin C wrappers.\n\n### 3. Performance Gotchas\n\n- **Buffer Copying**: Be careful with `Buffer` vs `Uint8Array`. Node compatibility layers might copy. Use `Uint8Array` natively where possible.\n- **Streams**: `Bun.serve()` relies on `ReadableStream`. Buffering the entire request body (`await req.text()`) defeats the purpose of streaming; process chunks if possible.\n- **Garbage Collection**: In tight loops, avoid allocating objects. Re-use objects or use typed arrays to keep pressure off the GC.\n\n## Best Practices\n\n- **Linting**: Use **Biome** (`bunx @biomejs/biome`) for instant linting/formatting.\n- **Globals**: Use `Bun.env`, `Bun.sleep`, but generally avoid Node.js globals unless necessary for library compatibility.\n- **Lockfile**: Commit `bun.lockb` for deterministic builds.\n\n</workflow>\n\n## Official References\n\n- <https://bun.sh/docs>\n- <https://bun.sh/docs/test>\n- <https://bun.sh/docs/install/lockfile>\n- <https://bun.sh/docs/runtime/ffi>\n- <https://bun.sh/docs/runtime/node-api>\n- <https://github.com/oven-sh/bun/releases>\n\n## Shared Styleguide Baseline\n\n- Use shared styleguides for generic language/framework rules to reduce duplication in this skill.\n- [General Principles](https://github.com/cofin/flow/blob/main/templates/styleguides/general.md)\n- [TypeScript](https://github.com/cofin/flow/blob/main/templates/styleguides/languages/typescript.md)\n- Keep this skill focused on tool-specific workflows, edge cases, and integration details.\n\n<guardrails>\n## Guardrails\n\nAdd guardrails instructions here.\n</guardrails>\n\n<validation>\n## Validation\n\nAdd validation instructions here.\n</validation>","tags":["bun","flow","cofin","agent-skills","ai-agents","beads","claude-code","codex","cursor","developer-tools","gemini-cli","opencode"],"capabilities":["skill","source-cofin","skill-bun","topic-agent-skills","topic-ai-agents","topic-beads","topic-claude-code","topic-codex","topic-cursor","topic-developer-tools","topic-gemini-cli","topic-opencode","topic-plugin","topic-slash-commands","topic-spec-driven-development"],"categories":["flow"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/cofin/flow/bun","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add cofin/flow","source_repo":"https://github.com/cofin/flow","install_from":"skills.sh"}},"qualityScore":"0.455","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 11 github stars · SKILL.md body (3,341 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:07:35.543Z","embedding":null,"createdAt":"2026-04-23T13:03:57.979Z","updatedAt":"2026-05-18T19:07:35.543Z","lastSeenAt":"2026-05-18T19:07:35.543Z","tsv":"'/cofin/flow/blob/main/templates/styleguides/general.md)':410 '/cofin/flow/blob/main/templates/styleguides/languages/typescript.md)':414 '/docs':374 '/docs/install/lockfile':380 '/docs/runtime/ffi':383 '/docs/runtime/node-api':386 '/docs/test':377 '/oven-sh/bun/releases':389 '1':34,131 '10us':147 '2':74,214 '3':276 'abstract':178 'add':430,435 'alloc':324 'apach':200,204 'apache-arrow':203 'api':15,221,224 'array':333 'arrow':201,205 'avail':188 'avoid':148,190,323,356 'await':307 'backend':141 'baselin':392 'bash':100 'best':340 'bind':198,216 'biom':344 'biomejs/biome':346 'bodi':306 'buffer':157,279,284,302 'build':369 'bun':1,7,9,11,13,22,29,30,36,80,88,101,106,124,242,244,267 'bun.connect':174 'bun.env':352 'bun.file':60 'bun.listen':176 'bun.lockb':5,366 'bun.serve':50,298 'bun.sh':373,376,379,382,385 'bun.sh/docs':372 'bun.sh/docs/install/lockfile':378 'bun.sh/docs/runtime/ffi':381 'bun.sh/docs/runtime/node-api':384 'bun.sh/docs/test':375 'bun.sleep':353 'bun.write':62 'bundl':23 'bunfig.toml':6 'bunx':345 'busi':265 'c':249,274 'call':251 'capabl':33 'care':282 'case':425 'check':27 'chunk':315 'class':240 'collect':319 'commit':365 'communic':135 'compat':26,94,288,363 'complex':232,257 'copi':211,280,291 'core':32 'data':164 'defeat':309 'detail':120,428 'determinist':368 'dev':73 'domain':170 'drop':40 'drop-in':39 'duplic':402 'easili':241 'edg':424 'entir':304 'fast':97 'faster':52,110,246 'ffi':217,243,245,268 'file':58,182 'focus':45,418 'function':250 'garbag':318 'gc':339 'general':355,406 'generic':397 'github.com':388,409,413 'github.com/cofin/flow/blob/main/templates/styleguides/general.md)':408 'github.com/cofin/flow/blob/main/templates/styleguides/languages/typescript.md)':412 'github.com/oven-sh/bun/releases':387 'global':350,358 'gotcha':278 'guardrail':429,431 'harder':253 'high':113,127 'high-perform':126 'hot':193 'http':48,56 'i/o':59 'instal':8,107 'instant':348 'instruct':432,437 'integr':115,123,138,427 'inter':133 'inter-process':132 'ipc':136 'jest':93 'jest-compat':92 'js':16,206,239 'json':150 'json.stringify':191 'keep':335,415 'language/framework':398 'latenc':146 'layer':289 'librari':362 'lint':342 'linting/formatting':349 'linux':180 'lockfil':364 'logic':233,266 'loop':322 'maco':184 'maintain':255 'manag':105 'map':235 'memori':143,155,168 'might':290 'modul':57 'msgspec':196 'n':220,223 'n-api':219,222 'namespac':179 'napi':226,262 'napi-r':225,261 'nativ':66,215,294 'necessari':360 'need':71 'node':25,54,86,287 'node.js':44,357 'npm/yarn':112 'object':258,325,329 'offici':370 'optim':64 'packag':104,207 'pass':161 'path':183,194 'pattern':116,158 'perform':114,128,277 'pipe':149 'pointers/offsets':159 'polyglot':129 'possibl':296,317 'practic':341 'prefer':228 'pressur':336 'principl':407 'process':134,314 'purpos':311 're':327 're-us':326 'readablestream':301 'recommend':259 'reduc':401 'refer':371 'reli':299 'replac':42,83 'req.text':308 'request':305 'ring':156 'rs':227,263 'rule':399 'run':20,78,81 'runner':77,99 'runtim':14,35 'rust':236 'rust/python':140 'script':19,79 'script.ts':82 'section':119 'serial':189 'server':49 'share':142,154,167,213,390,394 'shm':186 'shmring':144 'signific':109 'simpl':248 'skill':31,405,417 'skill-bun' 'socket':163,171 'source-cofin' 'specif':422 'speed':47 'stabil':230 'stay':165 'stdout/stdin':152 'step':70 'stream':297,313 'struct':237 'structur':212 'styleguid':391,395 'support':67 'system':130 'task':75 'test':12,76,87,89,98,102 'thin':273 'tight':321 'tool':421 'tool-specif':420 'topic-agent-skills' 'topic-ai-agents' 'topic-beads' 'topic-claude-code' 'topic-codex' 'topic-cursor' 'topic-developer-tools' 'topic-gemini-cli' 'topic-opencode' 'topic-plugin' 'topic-slash-commands' 'topic-spec-driven-development' 'transpil':69 'ts':18,85 'ts-node':84 'type':332 'typescript':65,411 'ud':172 'uint8array':286,293 'ultra':96,272 'ultra-fast':95 'ultra-thin':271 'unix':169 'unless':359 'use':2,4,153,173,195,260,292,328,331,343,351,393 'valid':434,436 'vertebra':117 'via':197,202 'vs':218,285 'watch':103 'workflow':423 'workspac':10 'wrapper':275 'zero':210 'zero-copi':209","prices":[{"id":"0efead61-b671-4c83-9fab-360915c6f351","listingId":"aaac286a-da44-426b-8450-b984d83cd34f","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"cofin","category":"flow","install_from":"skills.sh"},"createdAt":"2026-04-23T13:03:57.979Z"}],"sources":[{"listingId":"aaac286a-da44-426b-8450-b984d83cd34f","source":"github","sourceId":"cofin/flow/bun","sourceUrl":"https://github.com/cofin/flow/tree/main/skills/bun","isPrimary":false,"firstSeenAt":"2026-04-23T13:03:57.979Z","lastSeenAt":"2026-05-18T19:07:35.543Z"}],"details":{"listingId":"aaac286a-da44-426b-8450-b984d83cd34f","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"cofin","slug":"bun","github":{"repo":"cofin/flow","stars":11,"topics":["agent-skills","ai-agents","beads","claude-code","codex","context-driven-development","cursor","developer-tools","gemini-cli","opencode","plugin","slash-commands","spec-driven-development","subagents","tdd","workflow"],"license":"apache-2.0","html_url":"https://github.com/cofin/flow","pushed_at":"2026-04-27T19:07:26Z","description":"Context-Driven Development toolkit for AI agents — spec-first planning, TDD workflow, and Beads integration.","skill_md_sha":"5c83e4c75b1b8ff0618ad60d5a783eddeab786bf","skill_md_path":"skills/bun/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/cofin/flow/tree/main/skills/bun"},"layout":"multi","source":"github","category":"flow","frontmatter":{"name":"bun","description":"Use when using bun.lockb, bunfig.toml, bun install, Bun workspaces, Bun test, Bun runtime APIs, JS or TS scripts run with Bun, bundling, or Node compatibility checks for Bun."},"skills_sh_url":"https://skills.sh/cofin/flow/bun"},"updatedAt":"2026-05-18T19:07:35.543Z"}}