create-patch

A tool for creating same-length patches to Claude Code’s bundled or npm-installed JavaScript. It helps change how Claude Code behaves, including checks and limits.

In plain words
What is it for?
Use it to find checks, feature flags, error messages, or API calls in Claude Code, analyse what they do, and design matching replacements or automatic patch rules.
Why use it?
It removes the need to edit minified JavaScript by hand without knowing where the relevant code is or how to preserve its exact byte length.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/cedriccmh/claude-auto-patch/create-patch
Any agent
npx skills add Cedriccmh/claude-auto-patch --skill create-patch
Clone the repo
git clone --depth 1 https://github.com/Cedriccmh/claude-auto-patch

Made for: Claude Code, Codex.

Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,209 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00101 $0.01209
Opus 5 $0.00051 $0.00605
Sonnet 5 $0.00020 $0.00242
Haiku 4.5 $0.00010 $0.00121

Measured 2d ago against content hash 589323e98e1e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

create-patch scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/search_target.py, scripts/validate_patch.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/create-patch/SKILL.md · 145 lines

How it starts

The opening of the file, as written. The whole thing — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.

为 Claude Code 创建补丁

为 Claude Code 的 minified JS 代码(bun 二进制或 npm cli.js)创建等长二进制补丁。

工作流程

1. 定位 npm cli.js

查找 npm 全局安装的 @anthropic-ai/claude-code 包用于分析(npm 版是文本文件,适合代码探索)。

npm root -g  -->  <root>/node_modules/@anthropic-ai/claude-code/cli.js

如果未找到,向用户询问:

npm 版 Claude Code 未安装,分析代码需要它作为参考。是否执行 npm install -g @anthropic-ai/claude-code 来安装?

确认 cli.js 可用后再继续。

2. 搜索目标代码

运行 scripts/search_target.py 查找相关代码片段:

python scripts/search_target.py <cli.js路径> "<关键词>"

脚本返回匹配的代码片段及其字节偏移和上下文。

如果用户描述模糊,搜索多个相关关键词。常见搜索策略:

  • 域名限制:搜索域名字符串(如 api.anthropic.com
  • Feature flags:搜索 flag 名称
  • 错误消息:搜索错误文本
  • API 调用:搜索 endpoint 路径

3. 分析代码

搜索到的片段是 minified JS。需要心理展开还原:

# Minified
return["api.anthropic.com"].includes(Xe)}catch{return!1}

# 展开后
try {
  return ["api.anthropic.com"].includes(Xe);
} catch {
  return !1;  // false
}

对于复杂片段,可以创建格式化副本进行深入分析:

npx prettier --write <临时副本.js>

需要识别:

  • 代码做了什么(正在执行的检查/限制)
  • 期望的行为是什么(补丁应该把它改成什么)
  • 最小替换方案(实现目标的最简替换)

4. 设计等长替换

关键约束:替换后的字节长度必须与原始代码完全一致。

用 JS 注释(/* */)吸收多余字节:

原始: return["api.anthropic.com"].includes(Xe)}catch{return!1}
补丁: return!0/*                          */}catch{return!0}
      ^--- 同样长度,合法 JS,不同行为 ---^

运行 scripts/validate_patch.py 验证:

python scripts/validate_patch.py \
  --target-re 'return\["api\.anthropic\.com"\]\.includes\([A-Za-z_$][A-Za-z0-9_$]*\)\}catch\{return!1\}' \
  --patched-re 'return!0/\* *\*/\}catch\{return!0\}' \
  --replacement-prefix 'return!0/*' \
  --replacement-suffix '*/}catch{return!0}' \
  --file "<cli.js 路径>"

脚本检查:正则是否匹配、长度是否一致、替换是否有效。

5. 注册补丁

读取项目的 auto_patch.py,在 PATCHES 字典中添加新的 PatchDef 条目:

"patch_name": PatchDef(
    name="patch_name",
    description="补丁说明",
    target_re=re.compile(rb'...'),
    patched_re=re.compile(rb'...'),
    build_replacement=lambda m: _equal_length_replace(
        b"prefix", b"suffix", m
    ),
),

更新 auto-patch-config.json,添加新补丁(默认启用):

Read the full file on GitHub · 145 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 145 lines · 101 tokens per session scan A 589323e98e1e

Subscribe to this mod's changes

create-patch is a skill published in the GitHub repository Cedriccmh/claude-auto-patch (11 stars, last pushed 5mo ago), licensed MIT. It adds 101 tokens to every session and 1,209 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens