fix: prevent corruption of native Claude Code binary on macOS#6
Merged
itz4blitz merged 1 commit intoitz4blitz:mainfrom Jan 28, 2026
Merged
Conversation
The parallel-execution module was reading the Claude Code binary as UTF-8 text and writing it back, which corrupts native Mach-O binaries. Invalid byte sequences get replaced with U+FFFD replacement characters. This fix adds isNativeBinary() detection that checks Mach-O magic bytes (cffaedfe, cafebabe) and ELF header (7f454c46) before attempting any read/patch operations. Native binaries are now skipped with an appropriate error message. Fixes binary corruption when running 'npx @itz4blitz/agentful init' on systems with native Claude Code installed via the bash installer. - Add isNativeBinary() helper to detect compiled executables - Guard detectTeammateTool() against native binary reads - Guard enableTeammateTool() against native binary patching - Add tests for native binary detection and rejection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
parallel-execution.jsmodule corrupts native Claude Code binaries on macOS when runningnpx @itz4blitz/agentful init.The code reads the Claude Code binary as UTF-8 text (
fs.readFileSync(claudePath, 'utf8')), which replaces invalid byte sequences with U+FFFD replacement characters (ef bf bd). When written back, the binary becomes corrupted and fails withexec format error.This affects users who install Claude Code via the official bash installer (
curl -fsSL https://claude.ai/install.sh | bash), which produces a native Mach-O binary rather than the npm-installed JavaScript version.Solution
Added
isNativeBinary()helper that checks file magic bytes before any read operations:cffaedfe- Mach-O 64-bit (macOS arm64/x64)cafebabe- Mach-O universal binary7f454c46- ELF (Linux)Both
detectTeammateTool()andenableTeammateTool()now check for native binaries and skip patching with an appropriate message.Testing
Reproduction