apply-patch

Instructions for using the apply_patch tool to create, update, move, rename, or delete text files through structured patches. The tool produces changes that can be reviewed as a patch.

In plain words
What is it for?
Use it when an agent needs to edit repository text files, including adding files, changing content, moving files, renaming files, or deleting files.
Why use it?
It provides a consistent format for making file changes and reduces the risk of applying unclear or malformed edits.

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/beautyyuyanli/codex-apply-patch/codex-apply-patch
Any agent
npx skills add BeautyyuYanli/codex-apply-patch --skill codex-apply-patch
Clone the repo
git clone --depth 1 https://github.com/BeautyyuYanli/codex-apply-patch

Made for: Claude Code, Codex.

Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,452 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.00026 $0.02452
Opus 5 $0.00013 $0.01226
Sonnet 5 $0.00005 $0.00490
Haiku 4.5 $0.00003 $0.00245

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

Security

Grade A, and why

apply-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.

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.

SKILL.md · 361 lines

How it starts

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

apply_patch Tool Instructions

Use apply_patch to create, update, move, rename, or delete text files through a structured, reviewable patch.

Tool contract

  • Input type: FREEFORM.
  • Pass exactly one raw patch string.
  • Do not wrap the patch in JSON.
  • Do not wrap the patch in Markdown fences.
  • Do not include commentary before or after the patch.
  • Do not invoke apply_patch in parallel with another tool.
  • Use LF (\n) line endings in the patch input.

A patch must begin with *** Begin Patch and end with *** End Patch.

Formal grammar

The following grammar uses Lark syntax and assumes a contextual lexer. Whitespace is significant and must not be globally ignored.

start: begin_patch operation+ end_patch

begin_patch: "*** Begin Patch" LF
end_patch: "*** End Patch" LF?

?operation: add_file
          | delete_file
          | update_file

// Create a non-empty text file.
// Every content line, including an empty content line, begins with "+".
add_file: "*** Add File: " path LF add_line+
add_line: "+" line_text LF

// Delete an existing file.
// A delete operation has no body.
delete_file: "*** Delete File: " path LF

// Update an existing file, move it, or do both.
// An update must contain a move clause, a change block, or both.
update_file: "*** Update File: " path LF update_body

?update_body: move_clause change_block?
            | change_block

// Move or rename the updated file.
move_clause: "*** Move to: " path LF

// Apply one or more contextual or changed lines.
// The optional EOF marker must be the final item in the block.
change_block: change_item+ eof_marker?

?change_item: section_header
            | change_line

// A section header is a locator and is not written to the file.
section_header: "@@" LF
              | "@@ " nonempty_text LF

// " " means context, "-" means deletion, and "+" means insertion.
change_line: CHANGE_PREFIX line_text LF

// Assert that the preceding change is anchored at the end of the file.
eof_marker: "*** End of File" LF

path: nonempty_text
line_text: NONEMPTY_TEXT?
nonempty_text: NONEMPTY_TEXT

CHANGE_PREFIX: "+" | "-" | " "
NONEMPTY_TEXT: /[^\r\n]+/
LF: "\n"

Read the full file on GitHub · 361 lines

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 · 361 lines · 26 tokens per session scan A c67dae643839

Subscribe to this mod's changes

apply-patch is a skill published in the GitHub repository BeautyyuYanli/codex-apply-patch (57 stars, last pushed 3d ago), licensed Apache-2.0. It adds 26 tokens to every session and 2,452 once invoked, about $0.0001 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

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 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