bun-runtime-best-practices
Teaches best practices for Bun runtime, focusing on file I/O, environment variables, and subprocess management for improved performance.
Install this skill
Security score
The bun-runtime-best-practices skill was audited on Mar 1, 2026 and we found 42 security issues across 2 threat categories, including 3 critical. Review the findings below before installing.
Categories Tested
Security Issues
Direct command execution function call
| 127 | ### Use Bun.spawn() Instead of child_process |
Direct command execution function call
| 135 | const child = spawn("ls", ["-la"]); |
Direct command execution function call
| 138 | **✅ Prefer: Bun.spawn()** |
Direct command execution function call
| 142 | const proc = Bun.spawn(["ls", "-la"]); |
Direct command execution function call
| 147 | const proc = Bun.spawn(["git", "status"], { |
Direct command execution function call
| 166 | const proc = Bun.spawn(["sh", "-c", "echo Hello && date"], { |
Direct command execution function call
| 173 | const proc1 = Bun.spawn(["ls", "-la"], { stdout: "pipe" }); |
Direct command execution function call
| 174 | const proc2 = Bun.spawn(["grep", ".ts"], { |
Direct command execution function call
| 357 | const proc = Bun.spawn(["echo", "hello"], { stdout: "pipe" }); |
Direct command execution function call
| 644 | 3. **Processes**: Use `Bun.spawn()` instead of `child_process` |
Template literal with variable interpolation in command context
| 207 | const configPath = `${import.meta.dir}/config.json`; |
Template literal with variable interpolation in command context
| 222 | const configPath = `${import.meta.dir}/../config.json`; |
Template literal with variable interpolation in command context
| 429 | ws.send(`Echo: ${message}`); |
Template literal with variable interpolation in command context
| 488 | const users = await pg`SELECT * FROM users WHERE active = ${true}`; |
Template literal with variable interpolation in command context
| 492 | const posts = await mysql`SELECT * FROM posts LIMIT ${10}`; |
Template literal with variable interpolation in command context
| 496 | const data = await sqlite`SELECT * FROM table WHERE id = ${123}`; |
Template literal with variable interpolation in command context
| 514 | const [newUser] = await db` |
Template literal with variable interpolation in command context
| 521 | const users = await db` |
Template literal with variable interpolation in command context
| 530 | await tx`INSERT INTO accounts (user_id, balance) VALUES (${userId}, ${0})`; |
Template literal with variable interpolation in command context
| 531 | await tx`UPDATE users SET has_account = true WHERE id = ${userId}`; |
Template literal with variable interpolation in command context
| 535 | const getUser = db.prepare`SELECT * FROM users WHERE id = ${0}`; |
Template literal with variable interpolation in command context
| 550 | await db` |
Template literal with variable interpolation in command context
| 556 | const products = await db` |
Template literal with variable interpolation in command context
| 564 | await db`INSERT INTO products (name, price) VALUES ${values}`; |
Template literal with variable interpolation in command context
| 575 | const users = await db`SELECT * FROM users WHERE active = ${true}`; |
Node child_process module reference
| 127 | ### Use Bun.spawn() Instead of child_process |
Node child_process module reference
| 129 | **❌ Avoid: child_process** |
Node child_process module reference
| 132 | import { spawn } from "child_process"; |
Node child_process module reference
| 133 | import { exec } from "node:child_process"; |
Node child_process module reference
| 644 | 3. **Processes**: Use `Bun.spawn()` instead of `child_process` |
Access to .env file
| 90 | ### Use Bun.env Instead of process.env |
Access to .env file
| 92 | **❌ Avoid: process.env** |
Access to .env file
| 95 | const apiKey = process.env.API_KEY; |
Access to .env file
| 96 | const port = process.env.PORT || "3000"; |
Access to .env file
| 99 | **✅ Prefer: Bun.env** |
Access to .env file
| 102 | const apiKey = Bun.env.API_KEY; |
Access to .env file
| 103 | const port = Bun.env.PORT ?? "3000"; |
Access to .env file
| 105 | // Bun.env is typed and provides better autocomplete |
Access to .env file
| 106 | // Load from .env file automatically |
Access to .env file
| 122 | const env = EnvSchema.parse(Bun.env); |
Access to .env file
| 149 | env: { ...Bun.env, GIT_AUTHOR_NAME: "Bot" }, |
Access to .env file
| 643 | 2. **Environment**: Use `Bun.env` instead of `process.env` |