Claude patch
Patch Claude Code CLI binary to unlock hard-coded limitations. Use when the user wants to apply, revert, or check status of binary patches after upgrading Claude Code. Community-contributed patches for model restrictions, feature flags, and schema unlocks.From its SKILL.md
npx -y skills add huybuidac/claude-code-patchkit --skill claude-patchAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
- runs commandsInstructs the agent to run 8 commands, including `case "$(uname -s 2>/dev/null)" in Darwin|Linux) PLATFORM=unix ;; *) PLATFORM=windows ;; esac` and 7 more.
SKILL.md
7.0 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it
claude-patch
Binary patches for Claude Code CLI — unlock hard-coded limitations without waiting for upstream changes.
Workflow
- Detect platform (macOS/Linux vs Windows) and Claude Code binary
- Ask user which patch to apply (or accept from argument)
- Load patch definition from
patches/directory - Detect state (unpatched / patched / abnormal)
- Confirm with user before any modification
- Backup → Patch → Re-sign (macOS) / strip-or-skip-sig (Windows) → Verify
Step 0: Detect platform (do this FIRST, exactly once)
Set $PLATFORM to either unix or windows. For every subsequent step in this skill, execute ONLY the block matching $PLATFORM — do not run both Unix and Windows blocks for the same step.
Pick the snippet matching the shell you have:
- Bash available (macOS/Linux):
case "$(uname -s 2>/dev/null)" in Darwin|Linux) PLATFORM=unix ;; *) PLATFORM=windows ;; esac - PowerShell available (Windows):
$Platform = if ($IsWindows -or $env:OS -eq 'Windows_NT') { 'windows' } else { 'unix' }
If you have access to both, prefer the one matching the OS (bash on Unix, PowerShell on Windows). Don't try both — pick one.
Step 1: Detect binary
Unix (bash):
CLAUDE_BIN=$(python3 -c "import os,shutil; p=shutil.which('claude'); print(os.path.realpath(p) if p else '')" 2>/dev/null)
[ -z "$CLAUDE_BIN" ] && CLAUDE_BIN="$HOME/.local/share/claude/current"
Windows (PowerShell):
$CLAUDE_BIN = (Get-Command claude -ErrorAction SilentlyContinue).Source
if (-not $CLAUDE_BIN) { $CLAUDE_BIN = "$env:USERPROFILE\.local\bin\claude.exe" }
Show path and version for user confirmation before proceeding.
Step 2: Select patch
If user specified a patch name → use it directly. Otherwise → list available patches and ask user to choose.
Available patches — read each .md file in patches/ directory:
| Patch | Description |
|---|---|
| subagent-model | Unlock model param on Agent tool — use any model id per-call |
Commands:
apply <patch-name>— apply a patchrevert <patch-name>— revert (restore from backup)status— show state of all patches on current binarylist— list available patches
Step 3: Load and execute patch
Read the patch definition file at ${CLAUDE_SKILL_DIR}/patches/<name>.md. Each file contains:
- Fingerprint (anchor pattern + expected count)
- Context guard (surrounding bytes to verify correct location)
- Replacement (length-preserving byte swap)
- State detection logic
- Verification steps
Safety rules
- NEVER patch without explicit user confirmation
- NEVER patch if fingerprint or context guard doesn't match
- ALWAYS backup before patching (
<binary>.bak.<timestamp>) - macOS: re-sign after patching (Gatekeeper requires valid signature)
- Windows: don't re-sign — Authenticode signature becomes invalid (
HashMismatch) but binary still runs; document the change to the user - ALWAYS self-verify marker count after patching
- If state is abnormal → abort and report, never patch blind
Bundle multiplicity
The bun-compiled binary may embed the JS bundle one or more times depending on platform/version:
- macOS ≤ 2.1.132: 2 instances
- macOS ≥ 2.1.133: 1 instance (Anthropic switched packaging)
- Windows: 1 instance (all observed versions)
Patch definitions detect the count dynamically — never hard-assert a specific number. State detection rule: any positive anchor count = unpatched; any positive marker count = patched; mixed = abnormal.
Windows-specific notes
- File-lock:
claude.execannot be modified in-place while the process is running. Use the rename-swap pattern:- Copy
claude.exe→claude.exe.patching - Patch the copy at the known offset
Rename-Item claude.exe → claude.exe.bak.<ts>(works on running .exe — same volume rename only updates directory entry)Move-Item claude.exe.patching → claude.exe
- Copy
- Backups stay around — running process keeps the
.bakfile open until exit. Cleanup of old backups should happen after Claude Code is restarted. - Signature: Authenticode by Anthropic, PBC. After patching,
Get-AuthenticodeSignaturereportsHashMismatch. Windows still executes the binary; SmartScreen/AppLocker may flag it depending on policy.
Step 4: Verification
After patching, run the verification block in the patch definition that matches your $PLATFORM. Each patch file provides parallel Unix and Windows verification — run only the one for your platform.
Revert workflow
When reverting a patch:
- Find backups:
# Unix ls -t "$CLAUDE_BIN".bak.* | head -5# Windows Get-ChildItem "$CLAUDE_BIN.bak.*" | Sort-Object LastWriteTime -Descending | Select-Object -First 5 - Show timestamps and sizes and let user pick which backup to restore.
- Confirm current binary is patched before reverting — check marker count > 0.
- Choose revert mode:
- Backup restore (preferred) — only if backup file size matches current binary size (same sub-build). Claude Code occasionally re-bundles within the same dot-version, leaving stale
.bakfiles on disk that no longer match.- Unix:
cp "$BACKUP" "$CLAUDE_BIN" - Windows: same rename-swap pattern as for apply (running
claude.exeis locked)
- Unix:
- In-place reverse-patch (fallback) — when no size-matching backup exists. Write the original 32-byte enum back over the marker. Length-preserving, doesn't depend on backup integrity. See each patch definition for the exact reverse procedure.
- Backup restore (preferred) — only if backup file size matches current binary size (same sub-build). Claude Code occasionally re-bundles within the same dot-version, leaving stale
- Always make a safety snapshot (
<binary>.preRevert.<ts>) of the current patched binary before any write, so the revert itself is undoable. - Re-sign (macOS only):
Windows: skip — backup retains the original Authenticode signature unchanged.codesign --remove-signature "$CLAUDE_BIN" 2>/dev/null || true codesign --force --sign - "$CLAUDE_BIN" - Verify marker count is 0 and anchor count is positive (any value, depending on bundle multiplicity).
Contributing
To add a new patch, create ${CLAUDE_SKILL_DIR}/patches/<name>.md following the structure in patches/TEMPLATE.md.
What ships with it: 3 files
36.3 KB alongside SKILL.md, 1 of them executable
patches/
- scan-bin.jsruns3.5 KB
- subagent-model.md31.2 KB
- TEMPLATE.md1.6 KB