diff --git a/CLAUDE.md b/CLAUDE.md index 09a8499345..54f107ec54 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -177,47 +177,6 @@ Built-in JavaScript modules use special syntax and are organized as: - `internal/` - Internal modules not exposed to users - `builtins/` - Core JavaScript builtins (streams, console, etc.) -### Special Syntax in Built-in Modules - -1. **`$` prefix** - Access to private properties and JSC intrinsics: - - ```js - const arr = $Array.from(...); // Private global - map.$set(...); // Private method - const arr2 = $newArrayWithSize(5); // JSC intrinsic - ``` - -2. **`require()`** - Must use string literals, resolved at compile time: - - ```js - const fs = require("fs"); // Directly loads by numeric ID - ``` - -3. **Debug helpers**: - - `$debug()` - Like console.log but stripped in release builds - - `$assert()` - Assertions stripped in release builds - - `if($debug) {}` - Check if debug env var is set - -4. **Platform detection**: `process.platform` and `process.arch` are inlined and dead-code eliminated - -5. **Export syntax**: Use `export default` which gets converted to a return statement: - ```js - export default { - readFile, - writeFile, - }; - ``` - -Note: These are NOT ES modules. The preprocessor converts `$` to `@` (JSC's actual syntax) and handles the special functions. - -## CI - -Bun uses BuildKite for CI. To get the status of a PR, you can use the following command: - -```bash -bun ci -``` - ## Important Development Notes 1. **Never use `bun test` or `bun ` directly** - always use `bun bd test` or `bun bd `. `bun bd` compiles & runs the debug build. @@ -229,19 +188,6 @@ bun ci 7. **Avoid shell commands** - Don't use `find` or `grep` in tests; use Bun's Glob and built-in tools 8. **Memory management** - In Zig code, be careful with allocators and use defer for cleanup 9. **Cross-platform** - Run `bun run zig:check-all` to compile the Zig code on all platforms when making platform-specific changes -10. **Debug builds** - Use `BUN_DEBUG_QUIET_LOGS=1` to disable debug logging, or `BUN_DEBUG_=1` to enable specific scopes +10. **Debug builds** - Use `BUN_DEBUG_QUIET_LOGS=1` to disable debug logging, or `BUN_DEBUG_=1` to enable specific `Output.scoped(.${scopeName}, .visible)`s 11. **Be humble & honest** - NEVER overstate what you got done or what actually works in commits, PRs or in messages to the user. 12. **Branch names must start with `claude/`** - This is a requirement for the CI to work. - -## Key APIs and Features - -### Bun-Specific APIs - -- **Bun.serve()** - High-performance HTTP server -- **Bun.spawn()** - Process spawning with better performance than Node.js -- **Bun.file()** - Fast file I/O operations -- **Bun.write()** - Unified API for writing to files, stdout, etc. -- **Bun.$ (Shell)** - Cross-platform shell scripting -- **Bun.SQLite** - Native SQLite integration -- **Bun.FFI** - Call native libraries from JavaScript -- **Bun.Glob** - Fast file pattern matching diff --git a/src/AGENTS.md b/src/AGENTS.md new file mode 120000 index 0000000000..681311eb9c --- /dev/null +++ b/src/AGENTS.md @@ -0,0 +1 @@ +CLAUDE.md \ No newline at end of file diff --git a/src/CLAUDE.md b/src/CLAUDE.md new file mode 100644 index 0000000000..d53c2b889b --- /dev/null +++ b/src/CLAUDE.md @@ -0,0 +1,5 @@ +## Zig + +- Prefer `@import` at the **bottom** of the file. +- It's `@import("bun")` not `@import("root").bun` +- You must be patient with the build. diff --git a/src/js/CLAUDE.md b/src/js/CLAUDE.md index ed175a119a..e34bbfc526 100644 --- a/src/js/CLAUDE.md +++ b/src/js/CLAUDE.md @@ -72,6 +72,8 @@ $debug("Module loaded:", name); // Debug (stripped in release) $assert(condition, "message"); // Assertions (stripped in release) ``` +**Platform detection**: `process.platform` and `process.arch` are inlined and dead-code eliminated + ## Validation and Errors ```typescript