mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
## Summary Added Claude Code hooks to prevent common development mistakes when working on the Bun codebase. ## Changes - Created `.claude/hooks/pre-bash-zig-build.js` - A pre-bash hook that validates commands - Created `.claude/settings.json` - Hook configuration ## Prevented Mistakes 1. **Running `zig build obj` directly** → Redirects to use `bun bd` 2. **Using `bun test` in development** → Must use `bun bd test` (or set `USE_SYSTEM_BUN=1`) 3. **Combining snapshot updates with test filters** → Prevents `-u`/`--update-snapshots` with `-t`/`--test-name-pattern` 4. **Running `bun bd` with timeout** → Build needs time to complete without timeout 5. **Running `bun bd test` from repo root** → Must specify a test file path to avoid running all tests ## Test plan - [x] Tested all validation rules with various command combinations - [x] Verified USE_SYSTEM_BUN=1 bypass works - [x] Verified file path detection works correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
27 lines
517 B
JSON
27 lines
517 B
JSON
{
|
|
"hooks": {
|
|
"PreToolUse": [
|
|
{
|
|
"matcher": "Bash",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/pre-bash-zig-build.js"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"PostToolUse": [
|
|
{
|
|
"matcher": "Write|Edit|MultiEdit",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/post-edit-zig-format.js"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|