@lenml/apply_edits
v1.2.1
Published
A CLI tool for batch file editing with SEARCH/REPLACE and MATCH/REPLACE patterns, supporting atomic transactions and cross-platform compatibility. Designed for AI coding assistants like Codex.
Maintainers
Readme
@lenml/apply_edits
CLI tool for batch file editing with search/replace patterns. Atomic writes (temp file + rename), encoding auto-detection, trimmed line matching.
Windows PowerShell Note: PowerShell 5 (
powershell.exe) defaults to UTF-16 LE when piping, which breaks encoding. Upgrade to PowerShell 7+ (pwsh.exe).
Install
npm install -g @lenml/apply_editsUsage
apply-diff (Recommended — SEARCH/REPLACE blocks via stdin)
Reads SEARCH/REPLACE blocks from stdin and applies edits atomically. Prefer this over shell arguments to avoid escaping issues.
cat <<'EOF' | apply-diff --workdir .
src/file.ts
<<<<<<< SEARCH
const a = 1;
=======
const a = 2;
>>>>>>> REPLACE
EOFOr read from a file:
apply-diff --workdir . --file changes.diffSee SKILL.md for full format documentation.
apply-edits (CLI arguments — triples)
See SKILL.md for full documentation.
apply-edits --workdir . src/file.ts "old code" "new code"Tip: When editing multiple files or multi-line text, use
apply-diffwith stdin instead to avoid shell escaping complexity.
Install as Agent Skill
install it: https://raw.githubusercontent.com/lenML/apply_edits_tool/refs/heads/main/skill/SKILL.mdinstall it: https://cdn.jsdelivr.net/npm/@lenml/apply_edits/skill/SKILL.mdinstall it: https://unpkg.com/@lenml/apply_edits/skill/SKILL.md