@plaited/development-skills 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.claude/commands/lsp-analyze.md +66 -0
  2. package/.claude/commands/lsp-find.md +51 -0
  3. package/.claude/commands/lsp-hover.md +48 -0
  4. package/.claude/commands/lsp-refs.md +55 -0
  5. package/.claude/commands/scaffold-rules.md +221 -0
  6. package/.claude/commands/validate-skill.md +29 -0
  7. package/.claude/rules/accuracy.md +64 -0
  8. package/.claude/rules/bun-apis.md +80 -0
  9. package/.claude/rules/code-review.md +276 -0
  10. package/.claude/rules/git-workflow.md +66 -0
  11. package/.claude/rules/github.md +154 -0
  12. package/.claude/rules/testing.md +125 -0
  13. package/.claude/settings.local.json +47 -0
  14. package/.claude/skills/code-documentation/SKILL.md +47 -0
  15. package/.claude/skills/code-documentation/references/internal-templates.md +113 -0
  16. package/.claude/skills/code-documentation/references/maintenance.md +164 -0
  17. package/.claude/skills/code-documentation/references/public-api-templates.md +100 -0
  18. package/.claude/skills/code-documentation/references/type-documentation.md +116 -0
  19. package/.claude/skills/code-documentation/references/workflow.md +60 -0
  20. package/.claude/skills/scaffold-rules/SKILL.md +97 -0
  21. package/.claude/skills/typescript-lsp/SKILL.md +239 -0
  22. package/.claude/skills/validate-skill/SKILL.md +105 -0
  23. package/LICENSE +15 -0
  24. package/README.md +149 -0
  25. package/bin/cli.ts +109 -0
  26. package/package.json +57 -0
  27. package/src/lsp-analyze.ts +223 -0
  28. package/src/lsp-client.ts +400 -0
  29. package/src/lsp-find.ts +100 -0
  30. package/src/lsp-hover.ts +87 -0
  31. package/src/lsp-references.ts +83 -0
  32. package/src/lsp-symbols.ts +73 -0
  33. package/src/resolve-file-path.ts +28 -0
  34. package/src/scaffold-rules.ts +435 -0
  35. package/src/tests/fixtures/sample.ts +27 -0
  36. package/src/tests/lsp-client.spec.ts +180 -0
  37. package/src/tests/resolve-file-path.spec.ts +33 -0
  38. package/src/tests/scaffold-rules.spec.ts +286 -0
  39. package/src/tests/validate-skill.spec.ts +231 -0
  40. package/src/validate-skill.ts +492 -0
@@ -0,0 +1,66 @@
1
+ ---
2
+ description: Analyze a TypeScript file structure, exports, and symbols
3
+ allowed-tools: Bash
4
+ ---
5
+
6
+ # LSP Analyze
7
+
8
+ Batch analysis of a TypeScript/JavaScript file. Get an overview of exports, symbols, and optionally type info at specific positions.
9
+
10
+ **Arguments:** $ARGUMENTS
11
+
12
+ ## Usage
13
+
14
+ ```
15
+ /lsp-analyze <file> [options]
16
+ ```
17
+
18
+ Options:
19
+ - `--symbols` or `-s`: List all symbols
20
+ - `--exports` or `-e`: List only exported symbols (default if no options)
21
+ - `--hover <line:char>`: Get type info at position (repeatable)
22
+ - `--refs <line:char>`: Find references at position (repeatable)
23
+ - `--all`: Run symbols + exports analysis
24
+
25
+ ## Instructions
26
+
27
+ ### Step 1: Parse Arguments
28
+
29
+ Extract file path and options from `$ARGUMENTS`.
30
+
31
+ If file is missing, show usage:
32
+ ```
33
+ Usage: /lsp-analyze <file> [options]
34
+
35
+ Examples:
36
+ /lsp-analyze src/utils/parser.ts --exports
37
+ /lsp-analyze src/lib/config.ts --all
38
+ /lsp-analyze src/index.ts --hover 50:10 --refs 60:5
39
+ ```
40
+
41
+ Default to `--exports` if no options provided.
42
+
43
+ ### Step 2: Run LSP Analyze
44
+
45
+ Execute the development-skills CLI command:
46
+ ```bash
47
+ bunx @plaited/development-skills lsp-analyze <file> [options]
48
+ ```
49
+
50
+ ### Step 3: Format Output
51
+
52
+ Parse the JSON output and present in a structured format:
53
+
54
+ **File:** `<file>`
55
+
56
+ **Exports:**
57
+ | Name | Kind | Line |
58
+ |------|------|------|
59
+ | ... | ... | ... |
60
+
61
+ **Symbols:** (if requested)
62
+ | Name | Kind | Line |
63
+ |------|------|------|
64
+ | ... | ... | ... |
65
+
66
+ For hover/refs results, format as described in the individual commands.
@@ -0,0 +1,51 @@
1
+ ---
2
+ description: Search for TypeScript symbols across the workspace by name
3
+ allowed-tools: Bash
4
+ ---
5
+
6
+ # LSP Find
7
+
8
+ Search for symbols (functions, types, classes, variables) across the TypeScript/JavaScript codebase.
9
+
10
+ **Arguments:** $ARGUMENTS
11
+
12
+ ## Usage
13
+
14
+ ```
15
+ /lsp-find <query> [context-file]
16
+ ```
17
+
18
+ - `query`: Symbol name or partial name to search for
19
+ - `context-file`: Optional file to open for project context
20
+
21
+ ## Instructions
22
+
23
+ ### Step 1: Parse Arguments
24
+
25
+ Extract query and optional context file from `$ARGUMENTS`.
26
+
27
+ If query is missing, show usage:
28
+ ```
29
+ Usage: /lsp-find <query> [context-file]
30
+
31
+ Examples:
32
+ /lsp-find bElement
33
+ /lsp-find useTemplate src/main/use-template.ts
34
+ ```
35
+
36
+ ### Step 2: Run LSP Find
37
+
38
+ Execute the development-skills CLI command:
39
+ ```bash
40
+ bunx @plaited/development-skills lsp-find <query> [context-file]
41
+ ```
42
+
43
+ ### Step 3: Format Output
44
+
45
+ Parse the JSON output and present results as a table:
46
+
47
+ | Symbol | Kind | File | Line |
48
+ |--------|------|------|------|
49
+ | ... | ... | ... | ... |
50
+
51
+ Group results by file if there are many matches. Highlight the most relevant matches (exact name matches first).
@@ -0,0 +1,48 @@
1
+ ---
2
+ description: Get TypeScript type information at a specific position in a file
3
+ allowed-tools: Bash
4
+ ---
5
+
6
+ # LSP Hover
7
+
8
+ Get type information at a specific position in a TypeScript/JavaScript file.
9
+
10
+ **Arguments:** $ARGUMENTS
11
+
12
+ ## Usage
13
+
14
+ ```
15
+ /lsp-hover <file> <line> <char>
16
+ ```
17
+
18
+ - `file`: Path to TypeScript/JavaScript file (absolute, relative, or package export path)
19
+ - `line`: Line number (0-indexed)
20
+ - `char`: Character position (0-indexed)
21
+
22
+ ## Instructions
23
+
24
+ ### Step 1: Parse Arguments
25
+
26
+ Extract file path, line, and character from `$ARGUMENTS`.
27
+
28
+ If arguments are missing, show usage:
29
+ ```
30
+ Usage: /lsp-hover <file> <line> <char>
31
+
32
+ Example: /lsp-hover src/utils/parser.ts 42 15
33
+ ```
34
+
35
+ ### Step 2: Run LSP Hover
36
+
37
+ Execute the development-skills CLI command:
38
+ ```bash
39
+ bunx @plaited/development-skills lsp-hover <file> <line> <char>
40
+ ```
41
+
42
+ ### Step 3: Format Output
43
+
44
+ Parse the JSON output and present the type information in a readable format:
45
+
46
+ - Show the type signature in a code block
47
+ - If documentation is present, show it below
48
+ - If no hover info found, explain that no type information is available at that position
@@ -0,0 +1,55 @@
1
+ ---
2
+ description: Find all references to a TypeScript symbol across the codebase
3
+ allowed-tools: Bash
4
+ ---
5
+
6
+ # LSP References
7
+
8
+ Find all references to a symbol at a specific position. Use this before modifying or deleting exports to understand impact.
9
+
10
+ **Arguments:** $ARGUMENTS
11
+
12
+ ## Usage
13
+
14
+ ```
15
+ /lsp-refs <file> <line> <char>
16
+ ```
17
+
18
+ - `file`: Path to TypeScript/JavaScript file
19
+ - `line`: Line number (0-indexed)
20
+ - `char`: Character position (0-indexed)
21
+
22
+ ## Instructions
23
+
24
+ ### Step 1: Parse Arguments
25
+
26
+ Extract file path, line, and character from `$ARGUMENTS`.
27
+
28
+ If arguments are missing, show usage:
29
+ ```
30
+ Usage: /lsp-refs <file> <line> <char>
31
+
32
+ Example: /lsp-refs src/utils/parser.ts 42 10
33
+ ```
34
+
35
+ ### Step 2: Run LSP References
36
+
37
+ Execute the development-skills CLI command:
38
+ ```bash
39
+ bunx @plaited/development-skills lsp-refs <file> <line> <char>
40
+ ```
41
+
42
+ ### Step 3: Format Output
43
+
44
+ Parse the JSON output and present references grouped by file:
45
+
46
+ **Found X references:**
47
+
48
+ `src/file1.ts`
49
+ - Line 42: `const x = targetSymbol()`
50
+ - Line 58: `import { targetSymbol } from...`
51
+
52
+ `src/file2.ts`
53
+ - Line 15: `targetSymbol.method()`
54
+
55
+ If no references found, indicate that the symbol may be unused or only defined.
@@ -0,0 +1,221 @@
1
+ ---
2
+ description: Scaffold or merge development rules for your AI coding agent
3
+ allowed-tools: Glob, Read, Write, Edit, AskUserQuestion
4
+ ---
5
+
6
+ # Scaffold Rules
7
+
8
+ Generate development rules adapted to the user's AI coding agent environment.
9
+
10
+ **Arguments:** $ARGUMENTS (optional: rule categories to scaffold)
11
+
12
+ ## Instructions
13
+
14
+ ### Step 1: Get Processed Templates from CLI
15
+
16
+ Call the CLI to get rule templates with variables already processed:
17
+
18
+ ```bash
19
+ bunx @plaited/development-skills scaffold-rules --format=json
20
+ ```
21
+
22
+ The CLI will:
23
+ - Read bundled rule templates from the package
24
+ - Process template variables ({{LINK:*}}, {{#if}}, etc.)
25
+ - Output JSON with processed content
26
+
27
+ Parse the JSON output to get available templates. The output structure is:
28
+ ```json
29
+ {
30
+ "templates": {
31
+ "accuracy": {
32
+ "filename": "accuracy.md",
33
+ "content": "# Accuracy and Confidence Standards\n...",
34
+ "description": "95% confidence threshold, verification protocols"
35
+ },
36
+ "testing": { ... },
37
+ ...
38
+ }
39
+ }
40
+ ```
41
+
42
+ ### Step 2: Detect Agent & Scan Existing Rules
43
+
44
+ The CLI supports 2 target formats:
45
+
46
+ | Target | Rules Location | Use Case |
47
+ |--------|----------------|----------|
48
+ | `claude` | `.claude/rules/` | Claude Code (default) |
49
+ | `agents-md` | `.plaited/rules/` + `AGENTS.md` | Universal format for Cursor, Factory, Copilot, Windsurf, Cline, Aider, and 60,000+ other projects |
50
+
51
+ Check for existing configuration:
52
+ ```
53
+ .claude/ → Use --agent=claude (default)
54
+ AGENTS.md → Use --agent=agents-md
55
+ .plaited/rules/ → Use --agent=agents-md
56
+ Any other agent → Use --agent=agents-md (universal)
57
+ ```
58
+
59
+ **Always scan for existing rules before writing.** Use Read tool to check what's already there.
60
+
61
+ Analyze existing content to understand:
62
+ - What conventions are already defined
63
+ - What sections/topics are covered
64
+ - The writing style and format used
65
+
66
+ ### Step 3: Ask User Preferences
67
+
68
+ Present available templates from CLI output and ask which to scaffold (if not provided in $ARGUMENTS):
69
+
70
+ ```
71
+ ? Select rule categories to scaffold:
72
+ ◉ accuracy - 95% confidence threshold, verification protocols
73
+ ◉ bun-apis - Prefer Bun over Node.js APIs
74
+ ◉ git-workflow - Conventional commits, multi-line messages
75
+ ◉ github - GitHub CLI patterns for PRs/issues
76
+ ◉ code-review - TypeScript conventions, module organization
77
+ ◉ testing - Bun test runner conventions
78
+ ```
79
+
80
+ ### Step 4: Propose Merges (If Existing Rules Found)
81
+
82
+ If existing rules were found in Step 2, compare with CLI output:
83
+
84
+ 1. **Identify overlaps**: Which templates already exist as files
85
+ 2. **Show what would be added**: Preview the content from CLI
86
+ 3. **Ask for approval**:
87
+
88
+ ```
89
+ ? Existing rules found. How would you like to proceed?
90
+
91
+ For "git-workflow.md" (exists):
92
+ ◯ Keep existing (skip)
93
+ ◉ Merge (add missing sections)
94
+ ◯ Replace entirely
95
+
96
+ For "testing.md" (new):
97
+ ◉ Add to rules
98
+ ◯ Skip
99
+ ```
100
+
101
+ For merges:
102
+ - Use Read to get existing content
103
+ - Show diff of what would change
104
+ - Get approval before writing
105
+
106
+ ### Step 5: Write Rules
107
+
108
+ After user approval, write the rules using the content from CLI output:
109
+
110
+ - Use Write tool with `content` from CLI JSON
111
+ - Create directories if needed (`.claude/rules/` or `.plaited/rules/`)
112
+ - Write/merge files as approved
113
+ - Report what was created/modified
114
+
115
+ ### Rule Content Guidelines
116
+
117
+ The CLI processes template variables automatically. The content in the JSON output is ready to write to files.
118
+
119
+ **Template Processing:**
120
+ The CLI handles:
121
+ - Template variable substitution ({{LINK:*}}, {{AGENT_NAME}}, etc.)
122
+ - Capability-based conditionals ({{#if has-sandbox}}, {{#if supports-slash-commands}})
123
+ - Template header removal
124
+ - Cross-reference formatting for detected agent
125
+
126
+ **Available Rule Topics:**
127
+
128
+ **Bun APIs:**
129
+ - Prefer `Bun.file()` over `fs` APIs
130
+ - Use `Bun.$` for shell commands
131
+ - Use `Bun.write()` for file writes
132
+ - Use `import.meta.dir` for current directory
133
+
134
+ **Git Workflow:**
135
+ - Conventional commit prefixes (feat, fix, refactor, docs, chore, test)
136
+ - Multi-line commit message format
137
+ - Sandbox workarounds (Claude Code only)
138
+
139
+ **GitHub CLI:**
140
+ - Prefer `gh` CLI over WebFetch for GitHub URLs
141
+ - PR review patterns
142
+ - Issue/PR JSON field references
143
+
144
+ **TypeScript Conventions:**
145
+ - Prefer `type` over `interface`
146
+ - No `any` types (use `unknown` with guards)
147
+ - Arrow functions preferred
148
+ - Object parameter pattern for 2+ params
149
+ - PascalCase for types, `PascalCaseSchema` for Zod schemas
150
+
151
+ **Testing Patterns:**
152
+ - Use `test()` instead of `it()`
153
+ - `*.spec.ts` naming convention
154
+ - No conditionals around assertions
155
+ - Assert existence before checking values
156
+
157
+ ### Step 6: Output Summary
158
+
159
+ After completion, summarize what was done:
160
+
161
+ ```
162
+ ✅ Rules scaffolded for Claude Code:
163
+
164
+ Created:
165
+ • .claude/rules/testing.md - Bun test conventions
166
+ • .claude/rules/bun-apis.md - Prefer Bun over Node.js
167
+
168
+ Merged:
169
+ • .claude/rules/git-workflow.md - Added commit message formats
170
+
171
+ Skipped:
172
+ • accuracy.md - Already exists, user chose to keep
173
+
174
+ 💡 Review the generated rules at .claude/rules/ and customize as needed.
175
+ ```
176
+
177
+ ### CLI Usage
178
+
179
+ The scaffold-rules CLI supports 2 target formats:
180
+
181
+ ```bash
182
+ # Default: outputs all rules for Claude Code
183
+ bunx @plaited/development-skills scaffold-rules
184
+
185
+ # Universal AGENTS.md format (works with Cursor, Factory, Copilot, Windsurf, Cline, Aider, etc.)
186
+ bunx @plaited/development-skills scaffold-rules --agent=agents-md
187
+
188
+ # Custom paths (for specific agent directories or monorepos)
189
+ bunx @plaited/development-skills scaffold-rules --agent=agents-md --rules-dir=.cursor/rules
190
+ bunx @plaited/development-skills scaffold-rules --agent=agents-md --agents-md-path=docs/AGENTS.md
191
+
192
+ # Filter specific rules
193
+ bunx @plaited/development-skills scaffold-rules --rules testing --rules bun-apis
194
+ ```
195
+
196
+ **Options:**
197
+ - `--agent` / `-a`: Target format (`claude` or `agents-md`)
198
+ - `--rules-dir` / `-d`: Custom rules directory path (overrides default)
199
+ - `--agents-md-path` / `-m`: Custom AGENTS.md file path (default: `AGENTS.md`)
200
+ - `--format` / `-f`: Output format (json)
201
+ - `--rules` / `-r`: Specific rules to include (can be used multiple times)
202
+
203
+ **Output Structure:**
204
+ The JSON output includes metadata about the target:
205
+ ```json
206
+ {
207
+ "agent": "agents-md",
208
+ "rulesPath": ".plaited/rules",
209
+ "agentsMdPath": "AGENTS.md",
210
+ "format": "agents-md",
211
+ "supportsAgentsMd": true,
212
+ "agentsMdContent": "# AGENTS.md\n...",
213
+ "templates": { ... }
214
+ }
215
+ ```
216
+
217
+ For `agents-md` format, write:
218
+ 1. Individual rule files to the path specified in `rulesPath`
219
+ 2. The `agentsMdContent` to the path specified in `agentsMdPath`
220
+
221
+ This provides maximum portability - rules work with any AGENTS.md-compatible agent (60,000+ projects support this format).
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Validate skill directories against AgentSkills spec
3
+ allowed-tools: Bash, mcp__agent-skills-spec__*
4
+ ---
5
+
6
+ # Validate Skills
7
+
8
+ Validate skill directories against the AgentSkills specification.
9
+
10
+ **Paths to validate:** $ARGUMENTS (default: `.claude/skills/`)
11
+
12
+ ## Instructions
13
+
14
+ ### Step 1: Run Validation
15
+
16
+ Execute the development-skills CLI command:
17
+ ```bash
18
+ bunx @plaited/development-skills validate-skill $ARGUMENTS
19
+ ```
20
+
21
+ If no arguments provided, defaults to `.claude/skills/`.
22
+
23
+ ### Step 2: Report Results
24
+
25
+ Show the CLI output to the user. If there are errors, use the `agent-skills-spec` MCP server to get the latest specification and explain how to fix them.
26
+
27
+ ### Step 3: Query Spec (if needed)
28
+
29
+ For clarification on validation rules, query the `agent-skills-spec` MCP server for the current specification.
@@ -0,0 +1,64 @@
1
+ <!--
2
+ RULE TEMPLATE - Distributed via /scaffold-rules
3
+ Variables: {{LINK:testing}}, {{#if development-skills}}, {{#if supports-slash-commands}}
4
+ -->
5
+
6
+ # Accuracy and Confidence Standards
7
+
8
+ **Confidence Threshold**: 95% - Report uncertainty rather than guess
9
+
10
+ ## Verification Protocol
11
+
12
+ 1. **Verification First**: Before stating any specific implementation detail (function signature, file path, API schema), read the relevant file in real-time to verify accuracy.
13
+
14
+ 2. **Handling Uncertainty**: If you cannot verify information or find contradictions between instructions and live code, you must NOT provide speculative answers.
15
+ - **Action**: Clearly state you cannot answer with high confidence and explain the discrepancy.
16
+ - Example: "I cannot confirm [detail] because my instructions indicate [X], but the current file shows [Y]. My knowledge may be outdated."
17
+
18
+ 3. **Dynamic Exploration**:
19
+ {{#if development-skills}}
20
+ - **For TypeScript/JavaScript projects**: When @plaited/development-skills is installed, prefer LSP tools for type-aware verification:
21
+ - Use `lsp-find` to search for symbols, types, and patterns across the workspace
22
+ - Use `lsp-references` to find all usages of a symbol
23
+ - Use `lsp-hover` to verify type signatures
24
+ - Use `lsp-analyze` for batch analysis of file structure
25
+ {{/if}}
26
+ - Use Read tool for direct file verification
27
+ - Use Grep/Glob for content and pattern searches
28
+ - Always prioritize live code over instructions
29
+
30
+ 4. **Tool-Assisted Verification**: Use available tools to enhance verification accuracy:
31
+ {{#if development-skills}}
32
+ - **TypeScript LSP tools** (when available): Use for type-aware analysis of `.ts`, `.tsx`, `.js`, `.jsx` files
33
+ {{/if}}
34
+ {{#if supports-slash-commands}}
35
+ - Available via `/lsp-hover`, `/lsp-find`, `/lsp-refs`, `/lsp-analyze` commands
36
+ {{/if}}
37
+ {{^if supports-slash-commands}}
38
+ {{#if development-skills}}
39
+ - Available via `bunx @plaited/development-skills lsp-*` commands
40
+ {{/if}}
41
+ {{/if}}
42
+ - **WebFetch**: Retrieve current documentation from authoritative sources (MDN Web Docs, WHATWG specs) when using web platform APIs
43
+ - These tools complement (but do not replace) reading live code - always verify outputs against actual implementation
44
+
45
+ ## Certainty Requirements
46
+
47
+ You may only propose a specific change if you are **at least 95% certain** it is correct, based on direct comparison with current code.
48
+
49
+ **When uncertain:**
50
+ - Report the discrepancy clearly
51
+ - State why you cannot confidently recommend a fix
52
+ - Present the issue to the user for manual resolution
53
+ - DO NOT invent solutions or infer changes
54
+
55
+ ## For Agent-Specific Applications
56
+
57
+ Agents should apply these standards to their specific domain:
58
+
59
+ - **Documentation agents**: Only update TSDoc if parameter names/types match current code
60
+ - **Architecture agents**: Verify referenced patterns exist in current codebase
61
+ - **Code review agents**: Read files before commenting on implementation details
62
+ - **Pattern agents**: Confirm examples reflect actual usage in codebase
63
+
64
+ For verification in test contexts, see {{LINK:testing}}.
@@ -0,0 +1,80 @@
1
+ # Bun Platform APIs
2
+
3
+ **IMPORTANT**: Prefer Bun's native APIs over Node.js equivalents when running in the Bun environment.
4
+
5
+ ## File System Operations
6
+
7
+ - ✅ Use `Bun.file(path).exists()` instead of `fs.existsSync()`
8
+ - ✅ Use `Bun.file(path)` API for reading/writing files
9
+ - ✅ Use `Bun.write()` for efficient file writes
10
+
11
+ ```typescript
12
+ // ✅ Good: Bun APIs
13
+ const exists = await Bun.file('config.json').exists()
14
+ const content = await Bun.file('data.txt').text()
15
+ await Bun.write('output.json', JSON.stringify(data))
16
+
17
+ // ❌ Avoid: Node.js equivalents
18
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
19
+ const exists = existsSync('config.json')
20
+ ```
21
+
22
+ ## Shell Commands
23
+
24
+ - ✅ Use `Bun.$` template literal for shell commands
25
+ - ❌ Avoid `child_process.spawn()` or `child_process.exec()`
26
+
27
+ ```typescript
28
+ // ✅ Good: Bun shell
29
+ await Bun.$`npm install`
30
+ const result = await Bun.$`git status`.text()
31
+
32
+ // ❌ Avoid: Node.js child_process
33
+ import { spawn } from 'node:child_process'
34
+ spawn('npm', ['install'])
35
+ ```
36
+
37
+ ## Path Resolution
38
+
39
+ - ✅ Use `Bun.resolveSync()` for module resolution
40
+ - ✅ Use `import.meta.dir` for current directory
41
+ - ⚠️ Keep `node:path` utilities for path manipulation (join, resolve, dirname)
42
+
43
+ ```typescript
44
+ // ✅ Good: Bun + node:path combo
45
+ import { join } from 'node:path'
46
+ const configPath = join(import.meta.dir, 'config.json')
47
+ const resolved = Bun.resolveSync('./module', import.meta.dir)
48
+ ```
49
+
50
+ ## Package Management
51
+
52
+ - ✅ Use `Bun.which(cmd)` to check for executables
53
+ - ⚠️ No programmatic package manager API yet - use CLI commands via `Bun.$`
54
+
55
+ ```typescript
56
+ // ✅ Good: Check for executable
57
+ const bunPath = Bun.which('bun')
58
+ if (!bunPath) throw new Error('bun not found')
59
+
60
+ // Install packages via shell
61
+ await Bun.$`bun add zod`
62
+ ```
63
+
64
+ ## Environment Detection
65
+
66
+ - ✅ Check `typeof Bun !== 'undefined'` for Bun runtime
67
+ - ✅ Use `Bun.which('bun')` to verify bun executable exists
68
+
69
+ ## When to Use Node.js APIs
70
+
71
+ - Interactive input (readline)
72
+ - Complex path manipulation (prefer `node:path` utilities)
73
+ - APIs without Bun equivalents
74
+
75
+ ## Documentation
76
+
77
+ - Main docs: https://bun.sh/docs
78
+ - Shell API: https://bun.sh/docs/runtime/shell
79
+ - File I/O: https://bun.sh/docs/api/file-io
80
+ - Runtime APIs: https://bun.sh/docs/runtime/bun-apis