bun-file-io
Original:🇺🇸 English
Not Translated
Use this when you are working on file operations like reading, writing, scanning, or deleting files. It summarizes the preferred file APIs and patterns used in this repo. It also notes when to use filesystem helpers for directories.
2installs
Sourcegroeimetai/snow-flow
Added on
NPX Install
npx skill4agent add groeimetai/snow-flow bun-file-ioSKILL.md Content
Use this when
- Editing file I/O or scans in
packages/opencode - Handling directory operations or external tools
Bun file APIs (from Bun docs)
- is lazy; call
Bun.file(path),text,json,stream,arrayBuffer,bytesto read.exists - Metadata: ,
file.size,file.type.file.name - writes strings, buffers, Blobs, Responses, or files.
Bun.write(dest, input) - deletes a file.
Bun.file(...).delete() - returns a FileSink for incremental writes.
file.writer() - +
Bun.Globfor scans.Array.fromAsync(glob.scan({ cwd, absolute, onlyFiles, dot })) - Use to find a binary, then
Bun.whichto run it.Bun.spawn - for stream output.
Bun.readableStreamToText/Bytes/JSON
When to use node:fs
- Use for directories (
node:fs/promises,mkdir, recursive operations).readdir
Repo patterns
- Prefer Bun APIs over Node for file access.
fs - Check before reading.
Bun.file(...).exists() - For binary/large files use and MIME checks via
arrayBuffer().file.type - Use +
Bun.Globfor scans.Array.fromAsync - Decode tool stderr with .
Bun.readableStreamToText - For large writes, use .
Bun.write(Bun.file(path), text)
Quick checklist
- Use Bun APIs first.
- Use /
path.joinfor paths.path.resolve - Prefer promise over
.catch(...)when possible.try/catch