Community-contributed binary patches for Claude Code CLI — unlock hard-coded limitations without waiting for upstream changes.
Disclaimer: This is unofficial and not supported by Anthropic. It modifies the Claude Code binary. Use at your own risk. Keep backups and know how to reinstall Claude Code.
npx skills add huybuidac/claude-code-patchkit -gThe
-gflag installs globally (user-level) so the skill is available in all projects. Without it, the skill is only available in the current project.
/plugin marketplace add huybuidac/claude-code-patchkit
/plugin install claude-patch
- Node.js (LTS) on PATH — all platforms; scanning and patching run through one Node tool
codesignon macOS (ships with Xcode Command Line Tools)- Claude Code installed as a native binary, and write permission to it
Platforms: macOS arm64 (tested) / x86_64 (expected), Windows 11 arm64 (tested) / 10-11 x64 (expected), Linux (untested).
Inside a Claude Code session:
/claude-patch # Interactive mode
/claude-patch apply subagent-model # Apply specific patch
/claude-patch apply auto-compact-by-model # Claude ≈400K, GPT ≈300K
/claude-patch revert subagent-model # Revert to backup
/claude-patch status # Show all patch states
| Patch | Description | Risk |
|---|---|---|
| subagent-model | Unlock model param on Agent tool — use any model id per-call |
Low |
| auto-compact-by-model | Model-aware extended-context compact targets: Claude ≈400K, GPT ≈300K | Medium |
The auto-compact-by-model patch targets Claude Code’s central compaction resolver (functionally tested on 2.1.208; derivation verified through 2.1.233). For models whose resolved context ceiling is above 200K, it sets internal windows that normally trigger at approximately:
claude-*: 400K actual context tokensgpt-*: 300K actual context tokens
A numeric CLAUDE_CODE_AUTO_COMPACT_WINDOW remains the fallback for other models. Matched extended-context Claude/GPT rules take precedence, so an existing global value can stay configured for standard or unknown model families. CLAUDE_AUTOCOMPACT_PCT_OVERRIDE may still compact earlier.
The patch creates a backup plus a revert sidecar, and requires a Claude Code restart because running processes keep the old executable mapped.
Claude Code is distributed as a bun-compiled binary with embedded JS bundles. Some behaviors are locked behind hard-coded Zod schemas. This is an Agent Skill — Claude reads the patch definitions and runs the procedure with your confirmation before any write. Each apply is a length-preserving byte swap:
- Derive the anchor — see below
- Context guards — stable strings before and after must match, and any variable binding the replacement depends on must be proven, not assumed
- State detection — unpatched / patched / abnormal, before acting
- Backup —
<binary>.bak.<timestamp>, plus a<binary>.rtk-<patch>.jsonsidecar recording the original bytes - Verified write — each offset is checked against its expected bytes before being overwritten, so a stale offset aborts instead of corrupting the binary
- Signature — ad-hoc codesign on macOS; on Windows Authenticode becomes
HashMismatch(binary still runs) - Self-verify — re-scan and confirm the marker count
The bundler renames minified identifiers every few builds. A hardcoded anchor then matches 0 times — indistinguishable from "the feature was removed" — so routine drift looks like a broken fingerprint. Real examples from subagent-model: .enum([...]) → xr([...]) → Mr([...]), three rewrites in four months.
So each patch derives its anchor at scan time from landmarks that don't move: string literals the product ships (.describe() text, source:"…" labels) and positional locals the bundler assigns by position rather than name. The patch definitions document the derivation rule instead of the bytes.
This also covers bundle multiplicity — the JS bundle is embedded 1 or 2 times depending on platform/version (macOS ≤ 2.1.132 = 2, ≥ 2.1.133 = 1, Windows = 1). Landmarks are counted, never asserted.
claude.exe is locked while running, so writes go to a copy that then takes the original's path — renaming a running image only updates the directory entry. Restart Claude Code afterwards, and clean up any *.replacing.* file once the old process has exited.
- Never patches without explicit user confirmation
- Aborts if fingerprint doesn't match (schema changed in new version)
- Always creates backup before modifying
- Re-applies required per Claude Code update (new binary = clean slate)
- Copy
skills/claude-patch/patches/TEMPLATE.md - Register the derivation in
patch-bin.jsand document the rule in your.md - Test on at least 2 Claude Code versions
- Submit a PR
- Anchor derived from a stable landmark — not a pasted byte sequence containing minified names
- Length-preserving replacement, ideally referencing only positional locals (they survive renames)
- A guard that proves whatever the replacement assumes about the surrounding code
- Unique, permanently stable marker string for state detection
- Tested version list, distinguishing functionally tested from structurally verified
- macOS arm64 (Apple Silicon) — tested
- macOS x86_64 — should work (untested)
- Windows 11 arm64 — tested
- Windows 10/11 x64 — should work (untested)
- Linux — binary layout may differ, contributions welcome
- Normal route:
/claude-patch revert <patch>, ornode patch-bin.js revert --patch <patch>. It prefers the<binary>.rtk-<patch>.jsonsidecar (exact reverse-patch), falls back to a content-validated<binary>.bak.<timestamp>, and snapshots<binary>.preRevert.<ts>first. - Keep the sidecar. A patched binary alone cannot reconstruct a drifted minified alias — only its length survives.
- Don't restore a backup by size or filename. On macOS the backup is Apple-signed while the patched binary is ad-hoc signed, so sizes legitimately differ; and Claude Code re-bundles within a dot-version, so same name ≠ same build. Let
revertvalidate it by content. - Clean up Windows
*.replacing.*files after Claude Code has exited (they may stay on disk while the old process is still mapped) - To reinstall Claude Code: delete the install dir (
~/.local/share/claude/on Unix,%USERPROFILE%\.local\bin\claude.exeon Windows) and re-run the installer
MIT