apply-patch
What it does
This skill applies a set of code changes as one patch using Git. It is for developers whose agent needs to change multiple files or whose simple edits keep failing to match.
When to use it
- ✓When one change needs edits across three or more files.
- ✓When simple find-and-replace edits keep failing because the text does not match.
- ✓When you want to apply a patch that came from a pull request or a git diff.
Skill link
https://github.com/agentscope-ai/agentscope-java/blob/main/agentscope-examples/agents/agentscope-codingagent/src/main/resources/workspace-templates/skills/apply-patch/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Apply the same rename across the four files in this module as one patch, and check it applies cleanly first.”
5 new skills a week. 1 minute to read.
How it works
The skill writes a unified diff describing the changes, checks that it applies, and then applies it with Git all at once. If the patch is rejected, the agent reads the current lines again and rebuilds the patch.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Apply Patch
The built-in edit_file does an exact string match on a single file and has no fuzzy
tolerance. For multi-file changes, or when edit_file keeps failing to find the string,
construct a unified diff and apply it atomically with git.
Procedure
Write the unified diff to a file in the sandbox (use
write_fileor a heredoc viaexecute):diff --git a/path/to/file b/path/to/file --- a/path/to/file +++ b/path/to/file @@ -10,7 +10,7 @@ context line -old line +new lineValidate before applying:
git apply --check changes.patchApply:
git apply changes.patch(use-p0if paths are nota/...b/...).If
git applyrejects the hunk, the surrounding context is stale —read_filethe exact lines again, regenerate the diff with correct context, and retry.
When to prefer this
- Editing 3+ files for one logical change (atomic, all-or-nothing).
- Repetitive or whitespace-sensitive edits where
edit_fileexact-match struggles. - Re-applying a patch produced elsewhere (e.g. from a PR or
git diff).
Always run the verify-changes skill afterwards.
FAQ
Does it check the patch first?
Yes, the skill checks the patch before applying it.
What happens if the patch fails?
The agent reads the current file lines again and makes a new patch.
Is it all or nothing?
The patch is applied as one change, so it is meant to be all or nothing.
Details
Original description by the author
Apply multi-file or tricky edits atomically with git apply instead of many fragile edit_file calls. Use when changing several files at once or when edit_file fails to match.
Popularity
- GitHub stars
- 6.2k
- Ranking position
- #14386
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
agentscope-java
6.2kHelps your agent write non-blocking Java code for AgentScope, a multi-agent framework built on Project Reactor.
data-report
6.2kHelps your agent summarize a dataset into a report with averages, totals, ranges and trends, saved as a Markdown file.
data-transform
6.2kHelps your agent convert a data file between formats such as CSV and JSON, so the data can be used in other tools.
git-changelog
6.2kHelps your agent write a changelog or release notes from a Git history, grouped into features, fixes and other changes.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.