[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72Y83J8GS7QY6QBPF2XTCHH":3,"skill-same:01M72Y83J8GS7QY6QBPF2XTCHH":89},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M72Y83J8GS7QY6QBPF2XTCHH","bun",null,"Bun runtime, package manager, bundler, and test runner.\nUse when running scripts with bun, managing packages, serving HTTP with Bun.serve,\nquerying databases with Bun.sql\u002Fbun:sqlite\u002FBun.redis, shell scripting with $,\nusing S3\u002Ffile I\u002FO, writing tests with bun:test, bundling or compiling to executable,\nor using any Bun-specific API (spawn, glob, semver, FFI, workers, plugins, HTMLRewriter).","marcioaltoe\u002Fskills","marcioaltoe","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1562865?v=4","01M72Y3750J2CG00P0H2AHDRSZ","Marcio Altoé","01M72Y37642F46H36R4E4S7BNA",0,"MIT","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002FSKILL.md",[],[],"2026-11-10 22:39:42",false,"---\nname: bun\ndescription: |\n  Bun runtime, package manager, bundler, and test runner.\n  Use when running scripts with bun, managing packages, serving HTTP with Bun.serve,\n  querying databases with Bun.sql\u002Fbun:sqlite\u002FBun.redis, shell scripting with $,\n  using S3\u002Ffile I\u002FO, writing tests with bun:test, bundling or compiling to executable,\n  or using any Bun-specific API (spawn, glob, semver, FFI, workers, plugins, HTMLRewriter).\n---\n\n# Bun\n\n## Quick Start\n\n```bash\n# Install\ncurl -fsSL https:\u002F\u002Fbun.sh\u002Finstall | bash\n\n# Init project\nbun init\n\n# Run TypeScript directly\nbun run index.ts\n\n# Watch mode (hard restart on change)\nbun --watch index.ts\n\n# Hot reload (preserves global state, no restart)\nbun --hot server.ts\n```\n\n## Package Management\n\n```bash\nbun install                    # install all deps\nbun add express                # add dependency\nbun add -d @types\u002Fnode         # add dev dependency\nbun remove lodash              # remove\nbun update                     # update all\nbun update --latest            # ignore semver ranges\nbunx prettier --write .        # execute package binary (npx equivalent)\nbun patch express              # patch a dependency in node_modules\n```\n\n### Workspaces\n\n```json\n\u002F\u002F root package.json\n{ \"workspaces\": [\"packages\u002F*\"] }\n\n\u002F\u002F child package.json\n{ \"dependencies\": { \"shared\": \"workspace:*\" } }\n```\n\n```bash\nbun install --filter \"pkg-*\"   # install filtered workspaces\n```\n\n### Environment Variables\n\n`.env` files auto-loaded in order: `.env` → `.env.$(NODE_ENV)` → `.env.local`\n\n```ts\nBun.env.API_KEY       \u002F\u002F Bun-native\nprocess.env.API_KEY   \u002F\u002F Node.js compat\nimport.meta.env.API_KEY\n```\n\n```bash\nbun --env-file=.env.staging run start\n```\n\n## HTTP Server\n\n```ts\nBun.serve({\n  port: 3000,\n  routes: {\n    \"\u002F\": new Response(\"Home\"),\n    \"\u002Fusers\u002F:id\": (req) => Response.json({ id: req.params.id }),\n    \"\u002Fapi\u002Fposts\": {\n      GET: () => Response.json([]),\n      POST: async (req) => Response.json(await req.json(), { status: 201 }),\n    },\n    \"\u002Fapi\u002F*\": Response.json({ error: \"Not found\" }, { status: 404 }),\n    \"\u002Ffavicon.ico\": Bun.file(\".\u002Ffavicon.ico\"),\n  },\n  fetch(req) {\n    return new Response(\"Not Found\", { status: 404 });\n  },\n});\n```\n\n### WebSocket Upgrade\n\n```ts\nBun.serve({\n  fetch(req, server) {\n    if (server.upgrade(req, { data: { userId: \"123\" } })) return;\n    return new Response(\"Not a WebSocket\", { status: 400 });\n  },\n  websocket: {\n    open(ws) { ws.subscribe(\"chat\"); },\n    message(ws, msg) { ws.publish(\"chat\", msg); },\n    close(ws) {},\n  },\n});\n```\n\n### Fullstack (HTML Imports)\n\n```ts\nimport homepage from \".\u002Findex.html\";\n\nBun.serve({\n  routes: { \"\u002F\": homepage },\n  development: true, \u002F\u002F enables HMR\n});\n```\n\nSee [references\u002Fhttp-server.md](references\u002Fhttp-server.md) for cookies, static routes, TLS, server lifecycle, metrics.\n\n## Databases\n\n### Bun.sql (Postgres \u002F MySQL \u002F SQLite)\n\n```ts\nimport { sql, SQL } from \"bun\";\n\n\u002F\u002F Auto-reads DATABASE_URL \u002F POSTGRES_URL \u002F MYSQL_URL\nconst users = await sql`SELECT * FROM users WHERE active = ${true}`;\n\n\u002F\u002F Explicit connection\nconst pg = new SQL(\"postgres:\u002F\u002Fuser:pass@localhost:5432\u002Fmydb\");\nconst mysql = new SQL(\"mysql:\u002F\u002Fuser:pass@localhost:3306\u002Fmydb\");\nconst sqlite = new SQL(\":memory:\");\n\n\u002F\u002F Insert with object helper\nconst [user] = await sql`INSERT INTO users ${sql({ name: \"Alice\", email: \"a@b.com\" })} RETURNING *`;\n\n\u002F\u002F Bulk insert\nawait sql`INSERT INTO users ${sql([user1, user2, user3])}`;\n\n\u002F\u002F Transactions\nawait sql.begin(async (tx) => {\n  const [u] = await tx`INSERT INTO users ${sql({ name: \"Bob\" })} RETURNING *`;\n  await tx`INSERT INTO accounts (user_id) VALUES (${u.id})`;\n});\n```\n\n### bun:sqlite (Sync, Embedded)\n\n```ts\nimport { Database } from \"bun:sqlite\";\n\nconst db = new Database(\"app.db\");\ndb.run(\"CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, val TEXT)\");\nconst row = db.query(\"SELECT * FROM kv WHERE key = ?\").get(\"foo\");\nconst all = db.query(\"SELECT * FROM kv\").all();\n\n\u002F\u002F Class mapping\nclass User { id!: number; name!: string; }\nconst users = db.query(\"SELECT * FROM users\").as(User).all();\n```\n\n### Bun.redis\n\n```ts\nimport { redis } from \"bun\";\n\nawait redis.set(\"key\", \"value\", { ex: 60 });\nconst val = await redis.get(\"key\");\nawait redis.del(\"key\");\nawait redis.hmset(\"user:1\", { name: \"Alice\", role: \"admin\" });\n```\n\nSee [references\u002Fdatabase.md](references\u002Fdatabase.md) for transactions, savepoints, MySQL\u002FSQLite specifics, Redis pub\u002Fsub, connection options.\n\n## Shell ($)\n\n```ts\nimport { $ } from \"bun\";\n\n\u002F\u002F Run and print to stdout\nawait $`echo \"Hello\"`;\n\n\u002F\u002F Capture output\nconst text = await $`ls -la`.text();\nconst data = await $`cat config.json`.json();\nfor await (const line of $`cat file.txt`.lines()) { }\n\n\u002F\u002F Pipes\nawait $`cat file.txt | grep \"pattern\" | wc -l`;\n\n\u002F\u002F Redirect from\u002Fto JS objects\nawait $`cat \u003C ${new Response(\"data\")} > ${Bun.file(\"out.txt\")}`;\n\n\u002F\u002F Error handling\nconst { exitCode } = await $`may-fail`.nothrow().quiet();\n\n\u002F\u002F Config\n$.cwd(\"\u002Ftmp\");\n$.env({ ...process.env, NODE_ENV: \"production\" });\n```\n\n**Security:** Interpolated variables are auto-escaped (no shell injection). Use `{ raw: str }` to bypass.\n\nSee [references\u002Fshell.md](references\u002Fshell.md) for builtins, command substitution, brace expansion.\n\n## File I\u002FO & S3\n\n```ts\n\u002F\u002F Read\nconst file = Bun.file(\"data.json\");\nconst json = await file.json();       \u002F\u002F also: .text(), .bytes(), .stream(), .arrayBuffer()\nconsole.log(file.size, file.type);    \u002F\u002F size in bytes, MIME type\n\n\u002F\u002F Write\nawait Bun.write(\"out.txt\", \"hello\");\nawait Bun.write(Bun.file(\"copy.bin\"), Bun.file(\"src.bin\")); \u002F\u002F copy file\n\n\u002F\u002F Incremental write\nconst writer = Bun.file(\"log.txt\").writer();\nwriter.write(\"line 1\\n\");\nwriter.write(\"line 2\\n\");\nwriter.end();\n\n\u002F\u002F S3\nimport { s3 } from \"bun\";\nconst obj = s3.file(\"data.json\");\nconst data = await obj.json();\nawait obj.write(JSON.stringify({ ok: true }));\nconst url = obj.presign({ expiresIn: 3600, method: \"PUT\" });\nawait obj.delete();\n\n\u002F\u002F s3:\u002F\u002F protocol\nconst res = await fetch(\"s3:\u002F\u002Fbucket\u002Ffile.txt\");\n\n\u002F\u002F Glob\nconst glob = new Bun.Glob(\"**\u002F*.ts\");\nfor await (const path of glob.scan(\".\")) console.log(path);\n```\n\nSee [references\u002Ffile-io.md](references\u002Ffile-io.md) for S3 credentials, multipart uploads, streams, hashing, semver.\n\n## Testing\n\n```ts\nimport { test, expect, describe, mock, spyOn, beforeEach } from \"bun:test\";\n\ndescribe(\"math\", () => {\n  test(\"adds\", () => expect(1 + 1).toBe(2));\n\n  test.each([\n    [1, 2, 3],\n    [4, 5, 9],\n  ])(\"%i + %i = %i\", (a, b, expected) => {\n    expect(a + b).toBe(expected);\n  });\n\n  test.skip(\"wip\", () => {});\n  test.todo(\"implement later\");\n});\n\n\u002F\u002F Mock functions\nconst fn = mock(() => 42);\nfn();\nexpect(fn).toHaveBeenCalled();\n\n\u002F\u002F Module mocking\nmock.module(\".\u002Fdb\", () => ({\n  query: mock(() => []),\n}));\n\n\u002F\u002F Spies\nconst spy = spyOn(console, \"log\");\nconsole.log(\"test\");\nexpect(spy).toHaveBeenCalledWith(\"test\");\n\n\u002F\u002F Snapshots\ntest(\"snap\", () => {\n  expect({ a: 1, b: \"hello\" }).toMatchSnapshot();\n});\n```\n\n```bash\nbun test                          # run all tests\nbun test --watch                  # watch mode\nbun test --coverage               # with coverage\nbun test --update-snapshots       # update snapshots\nbun test --bail                   # stop on first failure\nbun test --test-name-pattern \"add\" # filter by name\n```\n\nSee [references\u002Ftesting.md](references\u002Ftesting.md) for all matchers, lifecycle hooks, type testing, retry\u002Frepeats, DOM testing.\n\n## Bundler & Compile\n\n```ts\n\u002F\u002F Bundle for browser\nconst result = await Bun.build({\n  entrypoints: [\".\u002Fsrc\u002Findex.ts\"],\n  outdir: \".\u002Fdist\",\n  splitting: true,\n  minify: true,\n  sourcemap: \"linked\",\n  target: \"browser\", \u002F\u002F or \"bun\", \"node\"\n});\n\nif (!result.success) {\n  for (const log of result.logs) console.error(log);\n}\n```\n\n```bash\n# Compile to standalone executable\nbun build --compile --minify --sourcemap --bytecode .\u002Fapp.ts --outfile myapp\n\n# Cross-compile\nbun build --compile --target=bun-linux-x64 .\u002Fapp.ts --outfile myapp-linux\nbun build --compile --target=bun-darwin-arm64 .\u002Fapp.ts --outfile myapp-mac\n```\n\n```ts\n\u002F\u002F Embed files in executable\nimport icon from \".\u002Ficon.png\" with { type: \"file\" };\nimport db from \".\u002Fdata.db\" with { type: \"sqlite\", embed: \"true\" };\n```\n\nSee [references\u002Fbundler.md](references\u002Fbundler.md) for all build options, plugins, cross-compile targets, Windows options, Transpiler API.\n\n## Child Processes\n\n```ts\n\u002F\u002F Async\nconst proc = Bun.spawn([\"ls\", \"-la\"], {\n  cwd: \"\u002Ftmp\",\n  stdout: \"pipe\",\n});\nconst output = await new Response(proc.stdout).text();\nawait proc.exited;\n\n\u002F\u002F Sync\nconst { stdout, exitCode } = Bun.spawnSync([\"echo\", \"hi\"]);\n\n\u002F\u002F Timeout + abort\nconst ctrl = new AbortController();\nBun.spawn([\"sleep\", \"100\"], { signal: ctrl.signal, timeout: 5000 });\n\n\u002F\u002F IPC between bun processes\nconst child = Bun.spawn([\"bun\", \"worker.ts\"], {\n  ipc(msg) { console.log(\"from child:\", msg); },\n});\nchild.send({ type: \"start\" });\n```\n\n## Configuration (bunfig.toml)\n\n```toml\n# Common options\npreload = [\".\u002Fsetup.ts\"]\nlogLevel = \"warn\"\n\n[run]\nshell = \"bun\"                    # use Bun's shell instead of system shell\nbun = true                       # alias node to bun in scripts\n\n[test]\npreload = [\".\u002Ftest-setup.ts\"]\ncoverage = true\ncoverageThreshold = 0.8\nretry = 2\n\n[install]\nexact = true                     # pin exact versions\nfrozenLockfile = true            # CI: fail if lockfile out of date\nauto = \"fallback\"                # auto-install missing packages\n```\n\nSee [references\u002Fconfiguration.md](references\u002Fconfiguration.md) for full bunfig.toml reference.\n\n## Reference Index\n\n| Topic | Reference |\n|-------|-----------|\n| HTTP server, routing, WebSockets, cookies, fullstack | [references\u002Fhttp-server.md](references\u002Fhttp-server.md) |\n| Bun.sql, bun:sqlite, Bun.redis | [references\u002Fdatabase.md](references\u002Fdatabase.md) |\n| TCP, UDP, DNS, fetch | [references\u002Fnetworking.md](references\u002Fnetworking.md) |\n| Bun Shell ($) | [references\u002Fshell.md](references\u002Fshell.md) |\n| bun:test, mocking, snapshots, coverage | [references\u002Ftesting.md](references\u002Ftesting.md) |\n| Bun.build, compile to executable, plugins | [references\u002Fbundler.md](references\u002Fbundler.md) |\n| Bun.file, S3, Glob, streams, hashing, semver | [references\u002Ffile-io.md](references\u002Ffile-io.md) |\n| bunfig.toml full reference | [references\u002Fconfiguration.md](references\u002Fconfiguration.md) |\n| Workers, HTMLRewriter, FFI, C compiler, secrets, Node.js compat | [references\u002Fadvanced.md](references\u002Fadvanced.md) |\n","# Bun\n\n## Quick Start\n\n```bash\n# Install\ncurl -fsSL https:\u002F\u002Fbun.sh\u002Finstall | bash\n\n# Init project\nbun init\n\n# Run TypeScript directly\nbun run index.ts\n\n# Watch mode (hard restart on change)\nbun --watch index.ts\n\n# Hot reload (preserves global state, no restart)\nbun --hot server.ts\n```\n\n## Package Management\n\n```bash\nbun install                    # install all deps\nbun add express                # add dependency\nbun add -d @types\u002Fnode         # add dev dependency\nbun remove lodash              # remove\nbun update                     # update all\nbun update --latest            # ignore semver ranges\nbunx prettier --write .        # execute package binary (npx equivalent)\nbun patch express              # patch a dependency in node_modules\n```\n\n### Workspaces\n\n```json\n\u002F\u002F root package.json\n{ \"workspaces\": [\"packages\u002F*\"] }\n\n\u002F\u002F child package.json\n{ \"dependencies\": { \"shared\": \"workspace:*\" } }\n```\n\n```bash\nbun install --filter \"pkg-*\"   # install filtered workspaces\n```\n\n### Environment Variables\n\n`.env` files auto-loaded in order: `.env` → `.env.$(NODE_ENV)` → `.env.local`\n\n```ts\nBun.env.API_KEY       \u002F\u002F Bun-native\nprocess.env.API_KEY   \u002F\u002F Node.js compat\nimport.meta.env.API_KEY\n```\n\n```bash\nbun --env-file=.env.staging run start\n```\n\n## HTTP Server\n\n```ts\nBun.serve({\n  port: 3000,\n  routes: {\n    \"\u002F\": new Response(\"Home\"),\n    \"\u002Fusers\u002F:id\": (req) => Response.json({ id: req.params.id }),\n    \"\u002Fapi\u002Fposts\": {\n      GET: () => Response.json([]),\n      POST: async (req) => Response.json(await req.json(), { status: 201 }),\n    },\n    \"\u002Fapi\u002F*\": Response.json({ error: \"Not found\" }, { status: 404 }),\n    \"\u002Ffavicon.ico\": Bun.file(\".\u002Ffavicon.ico\"),\n  },\n  fetch(req) {\n    return new Response(\"Not Found\", { status: 404 });\n  },\n});\n```\n\n### WebSocket Upgrade\n\n```ts\nBun.serve({\n  fetch(req, server) {\n    if (server.upgrade(req, { data: { userId: \"123\" } })) return;\n    return new Response(\"Not a WebSocket\", { status: 400 });\n  },\n  websocket: {\n    open(ws) { ws.subscribe(\"chat\"); },\n    message(ws, msg) { ws.publish(\"chat\", msg); },\n    close(ws) {},\n  },\n});\n```\n\n### Fullstack (HTML Imports)\n\n```ts\nimport homepage from \".\u002Findex.html\";\n\nBun.serve({\n  routes: { \"\u002F\": homepage },\n  development: true, \u002F\u002F enables HMR\n});\n```\n\nSee [references\u002Fhttp-server.md](references\u002Fhttp-server.md) for cookies, static routes, TLS, server lifecycle, metrics.\n\n## Databases\n\n### Bun.sql (Postgres \u002F MySQL \u002F SQLite)\n\n```ts\nimport { sql, SQL } from \"bun\";\n\n\u002F\u002F Auto-reads DATABASE_URL \u002F POSTGRES_URL \u002F MYSQL_URL\nconst users = await sql`SELECT * FROM users WHERE active = ${true}`;\n\n\u002F\u002F Explicit connection\nconst pg = new SQL(\"postgres:\u002F\u002Fuser:pass@localhost:5432\u002Fmydb\");\nconst mysql = new SQL(\"mysql:\u002F\u002Fuser:pass@localhost:3306\u002Fmydb\");\nconst sqlite = new SQL(\":memory:\");\n\n\u002F\u002F Insert with object helper\nconst [user] = await sql`INSERT INTO users ${sql({ name: \"Alice\", email: \"a@b.com\" })} RETURNING *`;\n\n\u002F\u002F Bulk insert\nawait sql`INSERT INTO users ${sql([user1, user2, user3])}`;\n\n\u002F\u002F Transactions\nawait sql.begin(async (tx) => {\n  const [u] = await tx`INSERT INTO users ${sql({ name: \"Bob\" })} RETURNING *`;\n  await tx`INSERT INTO accounts (user_id) VALUES (${u.id})`;\n});\n```\n\n### bun:sqlite (Sync, Embedded)\n\n```ts\nimport { Database } from \"bun:sqlite\";\n\nconst db = new Database(\"app.db\");\ndb.run(\"CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, val TEXT)\");\nconst row = db.query(\"SELECT * FROM kv WHERE key = ?\").get(\"foo\");\nconst all = db.query(\"SELECT * FROM kv\").all();\n\n\u002F\u002F Class mapping\nclass User { id!: number; name!: string; }\nconst users = db.query(\"SELECT * FROM users\").as(User).all();\n```\n\n### Bun.redis\n\n```ts\nimport { redis } from \"bun\";\n\nawait redis.set(\"key\", \"value\", { ex: 60 });\nconst val = await redis.get(\"key\");\nawait redis.del(\"key\");\nawait redis.hmset(\"user:1\", { name: \"Alice\", role: \"admin\" });\n```\n\nSee [references\u002Fdatabase.md](references\u002Fdatabase.md) for transactions, savepoints, MySQL\u002FSQLite specifics, Redis pub\u002Fsub, connection options.\n\n## Shell ($)\n\n```ts\nimport { $ } from \"bun\";\n\n\u002F\u002F Run and print to stdout\nawait $`echo \"Hello\"`;\n\n\u002F\u002F Capture output\nconst text = await $`ls -la`.text();\nconst data = await $`cat config.json`.json();\nfor await (const line of $`cat file.txt`.lines()) { }\n\n\u002F\u002F Pipes\nawait $`cat file.txt | grep \"pattern\" | wc -l`;\n\n\u002F\u002F Redirect from\u002Fto JS objects\nawait $`cat \u003C ${new Response(\"data\")} > ${Bun.file(\"out.txt\")}`;\n\n\u002F\u002F Error handling\nconst { exitCode } = await $`may-fail`.nothrow().quiet();\n\n\u002F\u002F Config\n$.cwd(\"\u002Ftmp\");\n$.env({ ...process.env, NODE_ENV: \"production\" });\n```\n\n**Security:** Interpolated variables are auto-escaped (no shell injection). Use `{ raw: str }` to bypass.\n\nSee [references\u002Fshell.md](references\u002Fshell.md) for builtins, command substitution, brace expansion.\n\n## File I\u002FO & S3\n\n```ts\n\u002F\u002F Read\nconst file = Bun.file(\"data.json\");\nconst json = await file.json();       \u002F\u002F also: .text(), .bytes(), .stream(), .arrayBuffer()\nconsole.log(file.size, file.type);    \u002F\u002F size in bytes, MIME type\n\n\u002F\u002F Write\nawait Bun.write(\"out.txt\", \"hello\");\nawait Bun.write(Bun.file(\"copy.bin\"), Bun.file(\"src.bin\")); \u002F\u002F copy file\n\n\u002F\u002F Incremental write\nconst writer = Bun.file(\"log.txt\").writer();\nwriter.write(\"line 1\\n\");\nwriter.write(\"line 2\\n\");\nwriter.end();\n\n\u002F\u002F S3\nimport { s3 } from \"bun\";\nconst obj = s3.file(\"data.json\");\nconst data = await obj.json();\nawait obj.write(JSON.stringify({ ok: true }));\nconst url = obj.presign({ expiresIn: 3600, method: \"PUT\" });\nawait obj.delete();\n\n\u002F\u002F s3:\u002F\u002F protocol\nconst res = await fetch(\"s3:\u002F\u002Fbucket\u002Ffile.txt\");\n\n\u002F\u002F Glob\nconst glob = new Bun.Glob(\"**\u002F*.ts\");\nfor await (const path of glob.scan(\".\")) console.log(path);\n```\n\nSee [references\u002Ffile-io.md](references\u002Ffile-io.md) for S3 credentials, multipart uploads, streams, hashing, semver.\n\n## Testing\n\n```ts\nimport { test, expect, describe, mock, spyOn, beforeEach } from \"bun:test\";\n\ndescribe(\"math\", () => {\n  test(\"adds\", () => expect(1 + 1).toBe(2));\n\n  test.each([\n    [1, 2, 3],\n    [4, 5, 9],\n  ])(\"%i + %i = %i\", (a, b, expected) => {\n    expect(a + b).toBe(expected);\n  });\n\n  test.skip(\"wip\", () => {});\n  test.todo(\"implement later\");\n});\n\n\u002F\u002F Mock functions\nconst fn = mock(() => 42);\nfn();\nexpect(fn).toHaveBeenCalled();\n\n\u002F\u002F Module mocking\nmock.module(\".\u002Fdb\", () => ({\n  query: mock(() => []),\n}));\n\n\u002F\u002F Spies\nconst spy = spyOn(console, \"log\");\nconsole.log(\"test\");\nexpect(spy).toHaveBeenCalledWith(\"test\");\n\n\u002F\u002F Snapshots\ntest(\"snap\", () => {\n  expect({ a: 1, b: \"hello\" }).toMatchSnapshot();\n});\n```\n\n```bash\nbun test                          # run all tests\nbun test --watch                  # watch mode\nbun test --coverage               # with coverage\nbun test --update-snapshots       # update snapshots\nbun test --bail                   # stop on first failure\nbun test --test-name-pattern \"add\" # filter by name\n```\n\nSee [references\u002Ftesting.md](references\u002Ftesting.md) for all matchers, lifecycle hooks, type testing, retry\u002Frepeats, DOM testing.\n\n## Bundler & Compile\n\n```ts\n\u002F\u002F Bundle for browser\nconst result = await Bun.build({\n  entrypoints: [\".\u002Fsrc\u002Findex.ts\"],\n  outdir: \".\u002Fdist\",\n  splitting: true,\n  minify: true,\n  sourcemap: \"linked\",\n  target: \"browser\", \u002F\u002F or \"bun\", \"node\"\n});\n\nif (!result.success) {\n  for (const log of result.logs) console.error(log);\n}\n```\n\n```bash\n# Compile to standalone executable\nbun build --compile --minify --sourcemap --bytecode .\u002Fapp.ts --outfile myapp\n\n# Cross-compile\nbun build --compile --target=bun-linux-x64 .\u002Fapp.ts --outfile myapp-linux\nbun build --compile --target=bun-darwin-arm64 .\u002Fapp.ts --outfile myapp-mac\n```\n\n```ts\n\u002F\u002F Embed files in executable\nimport icon from \".\u002Ficon.png\" with { type: \"file\" };\nimport db from \".\u002Fdata.db\" with { type: \"sqlite\", embed: \"true\" };\n```\n\nSee [references\u002Fbundler.md](references\u002Fbundler.md) for all build options, plugins, cross-compile targets, Windows options, Transpiler API.\n\n## Child Processes\n\n```ts\n\u002F\u002F Async\nconst proc = Bun.spawn([\"ls\", \"-la\"], {\n  cwd: \"\u002Ftmp\",\n  stdout: \"pipe\",\n});\nconst output = await new Response(proc.stdout).text();\nawait proc.exited;\n\n\u002F\u002F Sync\nconst { stdout, exitCode } = Bun.spawnSync([\"echo\", \"hi\"]);\n\n\u002F\u002F Timeout + abort\nconst ctrl = new AbortController();\nBun.spawn([\"sleep\", \"100\"], { signal: ctrl.signal, timeout: 5000 });\n\n\u002F\u002F IPC between bun processes\nconst child = Bun.spawn([\"bun\", \"worker.ts\"], {\n  ipc(msg) { console.log(\"from child:\", msg); },\n});\nchild.send({ type: \"start\" });\n```\n\n## Configuration (bunfig.toml)\n\n```toml\n# Common options\npreload = [\".\u002Fsetup.ts\"]\nlogLevel = \"warn\"\n\n[run]\nshell = \"bun\"                    # use Bun's shell instead of system shell\nbun = true                       # alias node to bun in scripts\n\n[test]\npreload = [\".\u002Ftest-setup.ts\"]\ncoverage = true\ncoverageThreshold = 0.8\nretry = 2\n\n[install]\nexact = true                     # pin exact versions\nfrozenLockfile = true            # CI: fail if lockfile out of date\nauto = \"fallback\"                # auto-install missing packages\n```\n\nSee [references\u002Fconfiguration.md](references\u002Fconfiguration.md) for full bunfig.toml reference.\n\n## Reference Index\n\n| Topic | Reference |\n|-------|-----------|\n| HTTP server, routing, WebSockets, cookies, fullstack | [references\u002Fhttp-server.md](references\u002Fhttp-server.md) |\n| Bun.sql, bun:sqlite, Bun.redis | [references\u002Fdatabase.md](references\u002Fdatabase.md) |\n| TCP, UDP, DNS, fetch | [references\u002Fnetworking.md](references\u002Fnetworking.md) |\n| Bun Shell ($) | [references\u002Fshell.md](references\u002Fshell.md) |\n| bun:test, mocking, snapshots, coverage | [references\u002Ftesting.md](references\u002Ftesting.md) |\n| Bun.build, compile to executable, plugins | [references\u002Fbundler.md](references\u002Fbundler.md) |\n| Bun.file, S3, Glob, streams, hashing, semver | [references\u002Ffile-io.md](references\u002Ffile-io.md) |\n| bunfig.toml full reference | [references\u002Fconfiguration.md](references\u002Fconfiguration.md) |\n| Workers, HTMLRewriter, FFI, C compiler, secrets, Node.js compat | [references\u002Fadvanced.md](references\u002Fadvanced.md) |\n",{"name":5,"description":7},"main","dea450cfd9df78b5cf721964ef178a75cea55cbb","skills\u002F05-implementation-loop\u002Fbun",2,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills","https:\u002F\u002Fmarcioaltoe.github.io\u002Fskills\u002F","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe","Senior Software Engineer · Backend, Systems & AI","2026-11-14 18:29:56",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add marcioaltoe\u002Fskills --skill bun",{"tool":39,"command":40},"bunx","bunx skills add marcioaltoe\u002Fskills --skill bun",{"tool":42,"command":43},"pnpm","pnpm dlx skills add marcioaltoe\u002Fskills --skill bun","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002FSKILL.md",true,[47,53,57,61,65,69,73,77,81,85],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"agents\u002Fopenai.yaml","REFERENCE","参考文档",196,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Fagents\u002Fopenai.yaml",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"references\u002Fadvanced.md",10416,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Fadvanced.md",{"path":58,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":59,"sourceHtmlUrl":60},"references\u002Fbundler.md",8902,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Fbundler.md",{"path":62,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fconfiguration.md",3960,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Fconfiguration.md",{"path":66,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":67,"sourceHtmlUrl":68},"references\u002Fdatabase.md",9645,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Fdatabase.md",{"path":70,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Ffile-io.md",8587,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Ffile-io.md",{"path":74,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fhttp-server.md",7349,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Fhttp-server.md",{"path":78,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":79,"sourceHtmlUrl":80},"references\u002Fnetworking.md",4758,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Fnetworking.md",{"path":82,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":83,"sourceHtmlUrl":84},"references\u002Fshell.md",4220,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Fshell.md",{"path":86,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Ftesting.md",10925,"https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F05-implementation-loop\u002Fbun\u002Freferences\u002Ftesting.md",[90,98,105,112,119,126],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":97},"01M72YNVSF4JTTQG3YTR9QNT4Z","startup-validator","Comprehensive startup idea validation and market analysis tool. Use when users need to evaluate a startup idea, assess market fit, analyze competition, validate problem-solution fit, or determine market positioning. Triggers include requests to \"validate my startup idea\", \"analyze market opportunity\", \"check if there's demand for\", \"research competition for\", \"evaluate business idea\", or \"see if my idea is viable\". Provides data-driven analysis using web search, market frameworks, competitive research, and positioning recommendations.","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F10-marketing\u002Fstartup-validator\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":97},"01M72YNN34B4MYKEX1X6BB1NS1","positioning-icp","When the user wants to define their ideal customer profile, position an AI product, build messaging architecture, or validate product-market fit. Also use when the user mentions 'ICP,' 'ideal customer profile,' 'positioning,' 'PMF,' 'product-market fit,' 'messaging,' 'buyer persona,' 'enrichment signals,' 'market positioning,' or 'competitive positioning.' This skill covers market positioning, ICP definition, messaging architecture, and PMF validation for AI-native products. Do NOT use for technical implementation, code review, or software architecture.","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F10-marketing\u002Fpositioning-icp\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":97},"01M72YNG8XJ4RHRB5DQMCY9C1N","copywriting","When the user wants to write or rewrite page copy (homepage, landing, pricing, feature), or asks which headline, promise, or message to lead with. Diagnoses the input first (blank brief, real voice, or point edit) and changes only what it calls for. Claims must be supportable; a declined claim names the evidence that would unlock it. No AI tells like 'it's not X, it's Y' or 'no X, no Y, no Z'. For editing, see copy-editing. For emails, see emails. For the offer, see offers.","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F10-marketing\u002Fcopywriting\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":97},"01M72YNBF4JMQ4VCFHTW0WS6SD","business-storyteller","Transforms technical work into persuasive business-language documents for non-technical stakeholders, including internal announcements, approval proposals, incident explainers, technical-debt cases, product explainers, and investor or partner memos. Use when the user asks to present technical work to the company, explain software to business teams, write a business case, make an approval document, or convert a technical artifact into stakeholder communication in the requested language. Do not use for READMEs, specs, ADRs, external marketing pages, or customer-facing sales copy.","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F10-marketing\u002Fbusiness-storyteller\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":97},"01M72YN8NQ6QR0GHX2A8YW2K4T","brand-storytelling","Help users craft compelling brand narratives. Use when someone is defining brand strategy, writing company positioning, creating pitch narratives, developing messaging frameworks, or trying to make their company story more memorable.","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F10-marketing\u002Fbrand-storytelling\u002FSKILL.md",[],[],{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":130,"licenseFileUrl":131,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":97},"01M72YN3CJH7CKPF4AXNY79Q9S","skill-creator","Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F09-learning-loop\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmarcioaltoe\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F09-learning-loop\u002Fskill-creator\u002FSKILL.md",[],[]]