Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit 1bc919d

Browse files
committed
ignore: add bun/file io skill just for our repo
1 parent 17438a2 commit 1bc919d

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: bun-file-io
3+
description: 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.
4+
---
5+
6+
## Use this when
7+
8+
- Editing file I/O or scans in `packages/opencode`
9+
- Handling directory operations or external tools
10+
11+
## Bun file APIs (from Bun docs)
12+
13+
- `Bun.file(path)` is lazy; call `text`, `json`, `stream`, `arrayBuffer`, `bytes`, `exists` to read.
14+
- Metadata: `file.size`, `file.type`, `file.name`.
15+
- `Bun.write(dest, input)` writes strings, buffers, Blobs, Responses, or files.
16+
- `Bun.file(...).delete()` deletes a file.
17+
- `file.writer()` returns a FileSink for incremental writes.
18+
- `Bun.Glob` + `Array.fromAsync(glob.scan({ cwd, absolute, onlyFiles, dot }))` for scans.
19+
- Use `Bun.which` to find a binary, then `Bun.spawn` to run it.
20+
- `Bun.readableStreamToText/Bytes/JSON` for stream output.
21+
22+
## When to use node:fs
23+
24+
- Use `node:fs/promises` for directories (`mkdir`, `readdir`, recursive operations).
25+
26+
## Repo patterns
27+
28+
- Prefer Bun APIs over Node `fs` for file access.
29+
- Check `Bun.file(...).exists()` before reading.
30+
- For binary/large files use `arrayBuffer()` and MIME checks via `file.type`.
31+
- Use `Bun.Glob` + `Array.fromAsync` for scans.
32+
- Decode tool stderr with `Bun.readableStreamToText`.
33+
- For large writes, use `Bun.write(Bun.file(path), text)`.
34+
35+
## Quick checklist
36+
37+
- Use Bun APIs first.
38+
- Use `path.join`/`path.resolve` for paths.
39+
- Prefer promise `.catch(...)` over `try/catch` when possible.

.opencode/skill/test-skill/SKILL.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)