apply-edits
Skill0 starsChanged 5 months agoMITView on GitHub
CLI tool for batch file editing with search/replace patterns. Supports atomic writes (temp file + rename), encoding auto-detection, and trimmed line-by-line matching for whitespace flexibility. Must be globally installed first: 从 stdin(或 --file)读取 SEARCH/REPLACE 格式的 diff 块并应用编辑。 优先使用此方式,因为通过 stdin 传入内容可避免 shell 转义问题。 每个块三部分组成:文件路径 + SEARCH 块 + REPLACE 块。 支持多个块(同一文件或不同文件),使用原子写入,出错不回写。 Arguments are grouped in triples: <file> <old-text> <new-text>. 注意: 在 shell 中传递多行或特殊字符文本需要小心转义,建议使用上面 apply-diff 的 stdin 方式替代。 A single edit: Multiple edits in one command: Old text is matched in two…
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- crywolfe/claude-code-designtheir own version, first seen Nov 22, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- crywolfe/claude-code-design★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 143
Read a file with automatic encoding detection (BOM -> UTF-8 -> CJK -> latin1) and print as UTF-8.
- Distinctive: line 148
Write content as UTF-8 without BOM.
- Very specific: line 153
Read a file, run a JS transform, write back as UTF-8.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
apply-edits
CLI tool for batch file editing with search/replace patterns. Supports atomic writes (temp file + rename), encoding auto-detection, and trimmed line-by-line matching for whitespace flexibility.
Usage
Must be globally installed first:
npm install -g @lenml/apply_editsCalling Convention
apply-diff (推荐 — 从 stdin 读取 SEARCH/REPLACE 块)
从 stdin(或 --file)读取 SEARCH/REPLACE 格式的 diff 块并应用编辑。
优先使用此方式,因为通过 stdin 传入内容可避免 shell 转义问题。
# stdin 传入
cat <<'EOF' | apply-diff --workdir .
src/file.ts
<<<<<<< SEARCH
const a = 1;
=======
const a = 2;
>>>>>>> REPLACE
EOF
# 或者从文件读取
apply-diff --workdir . --file changes.diff格式说明:
<filepath>
<<<<<<< SEARCH
<old text>
=======
<new text>
>>>>>>> REPLACE
<another-file>
<<<<<<< SEARCH
<old text>
=======
<new text>
>>>>>>> REPLACE每个块三部分组成:文件路径 + SEARCH 块 + REPLACE 块。 支持多个块(同一文件或不同文件),使用原子写入,出错不回写。
| Argument | Description |
--workdir <dir> | Root directory for file paths (default: current directory) |
--file <path> | Read diff from file instead of stdin |
--help | Show help |
--version | Show version number |
apply-edits (传统模式 — 参数三元组)
Arguments are grouped in triples: <file> <old-text> <new-text>.
注意: 在 shell 中传递多行或特殊字符文本需要小心转义,建议使用上面 apply-diff 的 stdin 方式替代。
A single edit:
apply-edits --workdir . <file> "<old>" "<new>"Multiple edits in one command:
apply-edits --workdir . <file> "<old1>" "<new1>" <file> "<old2>" "<new2>"| Argument | Description |
--workdir <dir> | Root directory for file paths (default: current directory) |
--help | Show help |
--version | Show version number |
Matching
Old text is matched in two ways:
- Direct string replace — exact match, fast path
- Trimmed line match — each old text line (trimmed) matched against file lines (trimmed), ignoring whitespace differences
Both old and new text can span multiple lines.
Examples
Single edit (PowerShell)
apply-edits --workdir . src/main.py 'print("hello")' 'print("hello world")'For multiline text, use a here-string:
apply-edits --workdir . src/main.py @'
function foo() {
return 1;
}
'@ @'
function foo() {
return 2;
}
'@Single edit (Bash)
apply-edits --workdir . src/main.py 'print("hello")' 'print("hello world")'Multiple edits on the same file
apply-edits --workdir . src/app.ts \
'function oldOne() {' 'function newOne() {' \
src/app.ts \
'function another() {' 'function updated() {'Companion Tools
read-file <path>
Read a file with automatic encoding detection (BOM -> UTF-8 -> CJK -> latin1) and print as UTF-8.
write-file <path> [content]
Write content as UTF-8 without BOM. Omit content to read from stdin. Supports atomic write (temp file + rename).
exec-js-edits [--dry-run] <file> <js-code>
Read a file, run a JS transform, write back as UTF-8.
The JS code receives content (string) and must return a string.
exec-js-edits main.ts "content.replace(/foo/g, 'bar')"
exec-js-edits --dry-run data.json "JSON.stringify(JSON.parse(content), null, 2)"Exit codes
0— all edits applied successfully1— error occurred (validation failure, file access error, etc.)
Library API
| Entry | Import |
| CLI | apply-edits (after npm install -g @lenml/apply_edits) |
| CLI (read file) | read-file <path> |
| CLI (write file) | write-file <path> [content] |
| CLI (exec JS) | exec-js-edits [--dry-run] <file> <js-code> |
| CLI (apply-diff) | apply-diff [--workdir <dir>] [--file <path>] |
| Editor | import { simulateEdits, applyEditsAtomic } from "@lenml/apply_edits" |
| Encoding | import { readFileAutoEncoding, writeFileUtf8 } from "@lenml/apply_edits" |
| Atomic I/O | import { writeFileAtomic, randomSuffix } from "@lenml/apply_edits" |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

