You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rtk-rewrite.sh PreToolUse hook causes EAGAIN (posix_spawn resource exhaustion) under heavy tool use #968
The rtk-rewrite.sh PreToolUse hook causes EAGAIN: resource temporarily unavailable, posix_spawn '/bin/sh' errors when Claude Code is making rapid Bash tool calls.
Root cause
The hook runs on everyBash tool invocation and spawns multiple child processes:
Under heavy tool use (e.g., parallel agent calls, rapid-fire commands), this saturates the OS process spawn capacity momentarily, causing posix_spawn to fail with EAGAIN.
Environment
macOS 15 (Darwin 25.3.0), Apple Silicon
Claude Code (CLI)
rtk installed via cargo
ulimit -u = 8000, kern.maxproc = 12000
Reproduction
Configure the rtk-rewrite hook per the docs
Run a Claude Code session with heavy Bash tool use (e.g., launching background tasks, parallel searches, agent subprocesses)
Cache the rtk --version check — the version guard runs rtk --version | grep | cut on every invocation. This could be checked once and cached in a file.
Combine the jq calls — the script calls jq 3 separate times (parse input, build updated input, build output). These could be a single jq invocation.
Use a long-running sidecar instead of spawning fresh processes per hook invocation — e.g., a simple socket/pipe server that the hook script queries.
Rate-limit or debounce — if the same command pattern was just checked, skip the rewrite.
PreToolUse hook spawns too many child processes per invocation, causing EAGAIN under heavy parallel tool use; PRs #970 and #956 already in progress to address this.
📁 Relevant files
rtk-rewrite.sh
Triaged automatically by wshm · This is an automated analysis, not a human review.
This will be fixed by #956 which replaces the bash hook chain (/bin/sh → rtk-rewrite.sh → jq ×3 + grep + cut) with a single native Rust binary: rtk hook claude.
One process instead of ~6 per hook invocation — no more posix_spawn saturation under parallel agent use.
Activity
fix(hook): reduce rewrite hook spawn overhead
fix(hooks): reduce jq invocations in rtk-rewrite\n\nFixes rtk-ai#968
fix(hook): reduce rewrite hook spawn overhead
fix(hooks): reduce jq invocations in rtk-rewrite\n\nFixes rtk-ai#968
pszymkowiak commentedon Apr 4, 2026
🔍 Automated Triage
bugmediumSummary
PreToolUse hook spawns too many child processes per invocation, causing EAGAIN under heavy parallel tool use; PRs #970 and #956 already in progress to address this.
📁 Relevant files
rtk-rewrite.shTriaged automatically by wshm · This is an automated analysis, not a human review.
pszymkowiak commentedon Apr 12, 2026
This will be fixed by #956 which replaces the bash hook chain (
/bin/sh → rtk-rewrite.sh → jq ×3 + grep + cut) with a single native Rust binary:rtk hook claude.One process instead of ~6 per hook invocation — no more
posix_spawnsaturation under parallel agent use.fix(hook): reduce rewrite hook spawn overhead
fix(hooks): reduce jq invocations in rtk-rewrite\n\nFixes rtk-ai#968
fix(hook): reduce rewrite hook spawn overhead
fix(hooks): reduce jq invocations in rtk-rewrite\n\nFixes rtk-ai#968