From bc745ec0a488c538b669862a9add06574005b5c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:15:24 +0000 Subject: [PATCH 01/10] Update Alternatives section with modern tool comparison Add comprehensive comparison table covering sd, fastmod, ast-grep, and comby with feature matrix. Include guidance on when to use each tool and mention rnr for file-only renaming. Replace outdated prose with structured, actionable information. --- README.md | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e998043..70694ee 100644 --- a/README.md +++ b/README.md @@ -124,21 +124,39 @@ If no arguments are supplied, it reads from stdin and writes to stdout. ## Alternatives -Aren’t there standard tools for this already? - -It’s a bit surprising, but not really. -Getting the features right is a bit tricky, I guess. -The -[standard](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) -[answers](http://stackoverflow.com/questions/6840332/rename-multiple-files-by-replacing-a-particular-pattern-in-the-filenames-using-a) -like *sed*, *perl*, *awk*, *rename*, *Vim* macros, or even IDE refactoring tools, often -cover specific cases, but tend to be error-prone or not offer specific features you -probably want. Things like nondestructive mode, file renaming as well as search/replace, -multiple simultaneous renames/swaps, or renaming enclosing parent directories. -Also many of these vary by platform, which adds to the corner cases. -Inevitably you end up digging through the darker corners of a man page, doing -semi-automated things in an IDE, or writing hacked scripts that are an embarrassment to -share. +There are many tools for search/replace and refactoring. Here's how repren compares: + +### Modern CLI Tools + +| Feature | repren | [sd](https://github.com/chmln/sd) | [fastmod](https://github.com/facebookincubator/fastmod) | [ast-grep](https://ast-grep.github.io/) | [comby](https://comby.dev/) | +| --- | --- | --- | --- | --- | --- | +| Simultaneous edits and swaps (foo↔bar) | ✅ | ❌ | ❌ | ❌ | ❌ | +| File/directory renaming | ✅ | ❌ | ❌ | ❌ | ❌ | +| Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | +| Language-agnostic | ✅ | ✅ | ✅ | ❌ | ✅ | +| Structural/AST-aware | ❌ | ❌ | ❌ | ✅ | ✅ | +| Dry run + backups + undo | ✅ | ❌ | Preview | Preview | Preview | +| Interactive interface | ❌ | ❌ | ✅ | ✅ | ✅ | +| Dependencies | Python, zero deps | Rust binary | Rust binary | Rust binary | OCaml binary | + +**When to use each:** + +- **repren**: Bulk renames with file/directory renaming, case preservation, or simultaneous + swaps. Works on any text file with full backup/undo support. +- **sd**: Simple, fast sed replacement for straightforward find/replace (2-11x faster than + sed). +- **fastmod**: Large codebase refactors where you want interactive human review of each + change. +- **ast-grep**: Language-aware refactoring where you need to match code structure (e.g., + function calls, not just text). Supports 40+ languages. +- **comby**: Structural matching across languages without learning AST syntax. + +For file renaming only (no content replacement), +[rnr](https://github.com/ismaelgv/rnr) is a capable Rust-based alternative with regex +support and dry-run mode. + +Classic tools like *sed*, *perl*, *awk*, and *rename* can work for simple cases but +often lack dry-run mode, simultaneous swaps, or cross-platform consistency. ## Installation From af8959c12937bc90badb857ea7845b56ddb5bdea Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:17:22 +0000 Subject: [PATCH 02/10] Update README for v2.0.0 release Change banner from v2.0.0-rc1 to v2.0.0 and update release link. Keep explicit @latest in uvx command to encourage users and agents to use the latest version. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 70694ee..85c3f48 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ * * * -✨ **NEW:** [v2.0.0-rc1](https://github.com/jlevy/repren/releases/tag/2.0.0-rc1) is out, +✨ **NEW:** [v2.0.0](https://github.com/jlevy/repren/releases/tag/2.0.0) is out, refreshed for Python 3.10-3.14 and agent use! -It’s self-documenting so just tell Claude Code to run `uvx repren@latest --help` and +It's self-documenting so tell Claude Code to run `uvx repren@latest --help` and install as a skill.✨ * * * From 7762d21967da793bbdeb6ae17cbccd1360844a2b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:19:55 +0000 Subject: [PATCH 03/10] Use uvx repren@latest in SKILL.md to avoid stale cache uvx caches package versions, so agents with an old cached version would not get updated features. Using @latest ensures agents always fetch the newest version from PyPI. --- repren/skills/SKILL.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/repren/skills/SKILL.md b/repren/skills/SKILL.md index 468d1a9..e3571c4 100644 --- a/repren/skills/SKILL.md +++ b/repren/skills/SKILL.md @@ -1,11 +1,11 @@ --- name: repren description: Performs simultaneous multi-pattern search-and-replace, file/directory renaming, and case-preserving refactoring across codebases. Use for bulk refactoring, global find-and-replace, or when user mentions repren, multi-file rename, or pattern-based transformations. -allowed-tools: Bash(repren:*), Bash(uvx repren:*), Read, Write +allowed-tools: Bash(repren:*), Bash(uvx repren@latest:*), Read, Write --- # Repren - Multi-Pattern Search and Replace -> **Full documentation: Run `uvx repren --docs` for all options, flags, and advanced +> **Full documentation: Run `uvx repren@latest --docs` for all options, flags, and advanced > usage.** Multi-pattern search/replace tool for bulk refactoring with simultaneous replacements, @@ -15,12 +15,12 @@ file/directory renaming, and case-preserving transformations. **Always start with dry-run** to preview changes: ```bash -uvx repren --from='old_name' --to='new_name' --full --dry-run src/ +uvx repren@latest --from='old_name' --to='new_name' --full --dry-run src/ ``` Then execute if output looks correct: ```bash -uvx repren --from='old_name' --to='new_name' --full src/ +uvx repren@latest --from='old_name' --to='new_name' --full src/ ``` ## When to Use Repren @@ -51,7 +51,7 @@ CONSTANT_OLD CONSTANT_NEW Apply all patterns at once: ```bash -uvx repren --patterns=patterns.txt --full src/ +uvx repren@latest --patterns=patterns.txt --full src/ ``` Repren handles overlapping patterns intelligently: you can swap names (foo↔bar) in a @@ -61,7 +61,7 @@ single pass. Handle all case variants automatically: ```bash -uvx repren --from='my_var' --to='my_function' --preserve-case --full src/ +uvx repren@latest --from='my_var' --to='my_function' --preserve-case --full src/ ``` Transforms: `my_var`→`my_function`, `myVar`→`myFunction`, `MyVar`→`MyFunction`, @@ -73,7 +73,7 @@ With `--full`, in addition to searching and replacing content, repren will renam and directories matching the patterns. ```bash -uvx repren --from='old_module' --to='new_module' --full src/ +uvx repren@latest --from='old_module' --to='new_module' --full src/ ``` Renames files and directories, creating parent directories as needed. @@ -83,7 +83,7 @@ Files never clobber: numeric suffixes are added if conflicts arise. Use full Python regex syntax with backreferences: ```bash -uvx repren --from='figure ([0-9]+)' --to='Figure \1' --full docs/ +uvx repren@latest --from='figure ([0-9]+)' --to='Figure \1' --full docs/ ``` Pattern file example: @@ -103,7 +103,7 @@ Original files never truncated on errors. **Always preview changes first:** ```bash -uvx repren --dry-run --patterns=patterns.txt --full mydir/ +uvx repren@latest --dry-run --patterns=patterns.txt --full mydir/ ``` Shows exactly what would change without modifying files. @@ -112,14 +112,14 @@ Shows exactly what would change without modifying files. Restore from backups if needed: ```bash -uvx repren --undo --from='old' --to='new' --full src/ +uvx repren@latest --undo --from='old' --to='new' --full src/ ``` ### Clean Backups Remove backups when satisfied: ```bash -uvx repren --clean-backups src/ +uvx repren@latest --clean-backups src/ ``` ## Common Workflows @@ -128,64 +128,64 @@ uvx repren --clean-backups src/ 1. Preview changes: ```bash -uvx repren --from='OldName' --to='NewName' --preserve-case --word-breaks --full --dry-run src/ +uvx repren@latest --from='OldName' --to='NewName' --preserve-case --word-breaks --full --dry-run src/ ``` 2. Execute if output looks correct: ```bash -uvx repren --from='OldName' --to='NewName' --preserve-case --word-breaks --full src/ +uvx repren@latest --from='OldName' --to='NewName' --preserve-case --word-breaks --full src/ ``` 3. Review changes, test, then clean backups: ```bash -uvx repren --clean-backups src/ +uvx repren@latest --clean-backups src/ ``` ### Filtering Files Include only specific file types: ```bash -uvx repren --patterns=patterns.txt --include='.*\.(py|pyi)$' --full src/ +uvx repren@latest --patterns=patterns.txt --include='.*\.(py|pyi)$' --full src/ ``` Exclude directories: ```bash -uvx repren --patterns=patterns.txt --exclude='tests|node_modules|__pycache__' --full src/ +uvx repren@latest --patterns=patterns.txt --exclude='tests|node_modules|__pycache__' --full src/ ``` ### Word Boundaries Match only at word boundaries (safer for variable names): ```bash -uvx repren --from='var' --to='variable' --word-breaks --full src/ +uvx repren@latest --from='var' --to='variable' --word-breaks --full src/ ``` ### Literal Patterns Treat patterns as literal strings (not regex): ```bash -uvx repren --from='file.txt' --to='data.txt' --literal --full docs/ +uvx repren@latest --from='file.txt' --to='data.txt' --literal --full docs/ ``` ### Multi-Line Patterns Process entire files at once for patterns spanning lines: ```bash -uvx repren --patterns=patterns.txt --at-once --full src/ +uvx repren@latest --patterns=patterns.txt --at-once --full src/ ``` ## Machine-Readable Output Use JSON format for programmatic processing: ```bash -uvx repren --format=json --from='old' --to='new' --full src/ +uvx repren@latest --format=json --from='old' --to='new' --full src/ ``` Returns structured data about all changes made. ## Key Flags -Most important flags (run `uvx repren --docs` for complete list): +Most important flags (run `uvx repren@latest --docs` for complete list): | Flag | Purpose | | --- | --- | From 272677602f95848b215f172795ab0bb26aedbf84 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:23:31 +0000 Subject: [PATCH 04/10] Update golden test baseline for uvx repren@latest change --- tests/golden-tests-expected.log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/golden-tests-expected.log b/tests/golden-tests-expected.log index 89d25fa..4284b4b 100644 --- a/tests/golden-tests-expected.log +++ b/tests/golden-tests-expected.log @@ -809,7 +809,7 @@ run --skill | head -5 --- name: repren description: Performs simultaneous multi-pattern search-and-replace, file/directory renaming, and case-preserving refactoring across codebases. Use for bulk refactoring, global find-and-replace, or when user mentions repren, multi-file rename, or pattern-based transformations. -allowed-tools: Bash(repren:*), Bash(uvx repren:*), Read, Write +allowed-tools: Bash(repren:*), Bash(uvx repren@latest:*), Read, Write --- From be999a132a7a4252311b750f6685567a22204422 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:35:36 +0000 Subject: [PATCH 05/10] Add sed/awk/perl column to Alternatives comparison table - Include classic tools with Stack Overflow link for context - Rename "Dependencies" to "Install method" for clarity - Use "Binary" for tools distributed as pre-built binaries - Use "Varies (OS/shell)" for classic Unix tools --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 85c3f48..4c573fb 100644 --- a/README.md +++ b/README.md @@ -126,23 +126,26 @@ If no arguments are supplied, it reads from stdin and writes to stdout. There are many tools for search/replace and refactoring. Here's how repren compares: -### Modern CLI Tools - -| Feature | repren | [sd](https://github.com/chmln/sd) | [fastmod](https://github.com/facebookincubator/fastmod) | [ast-grep](https://ast-grep.github.io/) | [comby](https://comby.dev/) | -| --- | --- | --- | --- | --- | --- | -| Simultaneous edits and swaps (foo↔bar) | ✅ | ❌ | ❌ | ❌ | ❌ | -| File/directory renaming | ✅ | ❌ | ❌ | ❌ | ❌ | -| Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | -| Language-agnostic | ✅ | ✅ | ✅ | ❌ | ✅ | -| Structural/AST-aware | ❌ | ❌ | ❌ | ✅ | ✅ | -| Dry run + backups + undo | ✅ | ❌ | Preview | Preview | Preview | -| Interactive interface | ❌ | ❌ | ✅ | ✅ | ✅ | -| Dependencies | Python, zero deps | Rust binary | Rust binary | Rust binary | OCaml binary | +### Comparison + +| Feature | repren | [sed/awk/perl](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) | [sd](https://github.com/chmln/sd) | [fastmod](https://github.com/facebookincubator/fastmod) | [ast-grep](https://ast-grep.github.io/) | [comby](https://comby.dev/) | +| --- | --- | --- | --- | --- | --- | --- | +| Simultaneous edits and swaps (foo↔bar) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | +| File/directory renaming | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | +| Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | +| Language-agnostic | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| Structural/AST-aware | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | +| Dry run + backups + undo | ✅ | ❌ | ❌ | Preview | Preview | Preview | +| Interactive interface | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | +| Install method | Python (zero deps) | Varies (OS/shell) | Binary | Binary | Binary | Binary | **When to use each:** - **repren**: Bulk renames with file/directory renaming, case preservation, or simultaneous swaps. Works on any text file with full backup/undo support. +- **sed/awk/perl**: Quick one-liners if you know the syntax. See + [classic approaches](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549). + Often lack dry-run mode, simultaneous swaps, or cross-platform consistency. - **sd**: Simple, fast sed replacement for straightforward find/replace (2-11x faster than sed). - **fastmod**: Large codebase refactors where you want interactive human review of each @@ -155,9 +158,6 @@ For file renaming only (no content replacement), [rnr](https://github.com/ismaelgv/rnr) is a capable Rust-based alternative with regex support and dry-run mode. -Classic tools like *sed*, *perl*, *awk*, and *rename* can work for simple cases but -often lack dry-run mode, simultaneous swaps, or cross-platform consistency. - ## Installation No dependencies except Python 3.10+. It’s easiest to install with From 8eaf83502eccae1196be98e43f228acc4886fe7a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:37:39 +0000 Subject: [PATCH 06/10] Add rnr to Alternatives comparison table rnr is a Rust-based file/directory renaming tool with: - File/directory renaming (its primary feature) - Dry run by default, backup option, undo via dump files - No content replacement (rename only) - Distributed as binary --- README.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4c573fb..5e76fe5 100644 --- a/README.md +++ b/README.md @@ -128,16 +128,16 @@ There are many tools for search/replace and refactoring. Here's how repren compa ### Comparison -| Feature | repren | [sed/awk/perl](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) | [sd](https://github.com/chmln/sd) | [fastmod](https://github.com/facebookincubator/fastmod) | [ast-grep](https://ast-grep.github.io/) | [comby](https://comby.dev/) | -| --- | --- | --- | --- | --- | --- | --- | -| Simultaneous edits and swaps (foo↔bar) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | -| File/directory renaming | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | -| Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | -| Language-agnostic | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| Structural/AST-aware | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | -| Dry run + backups + undo | ✅ | ❌ | ❌ | Preview | Preview | Preview | -| Interactive interface | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | -| Install method | Python (zero deps) | Varies (OS/shell) | Binary | Binary | Binary | Binary | +| Feature | repren | [sed/awk/perl](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) | [sd](https://github.com/chmln/sd) | [fastmod](https://github.com/facebookincubator/fastmod) | [ast-grep](https://ast-grep.github.io/) | [comby](https://comby.dev/) | [rnr](https://github.com/ismaelgv/rnr) | +| --- | --- | --- | --- | --- | --- | --- | --- | +| Simultaneous edits and swaps (foo↔bar) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| File/directory renaming | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | +| Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| Language-agnostic | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | +| Structural/AST-aware | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | +| Dry run + backups + undo | ✅ | ❌ | ❌ | Preview | Preview | Preview | ✅ | +| Interactive interface | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | +| Install method | Python (zero deps) | Varies (OS/shell) | Binary | Binary | Binary | Binary | Binary | **When to use each:** @@ -153,10 +153,8 @@ There are many tools for search/replace and refactoring. Here's how repren compa - **ast-grep**: Language-aware refactoring where you need to match code structure (e.g., function calls, not just text). Supports 40+ languages. - **comby**: Structural matching across languages without learning AST syntax. - -For file renaming only (no content replacement), -[rnr](https://github.com/ismaelgv/rnr) is a capable Rust-based alternative with regex -support and dry-run mode. +- **rnr**: File/directory renaming only (no content replacement). Has dry-run by default, + backup option, and undo via dump files. ## Installation From 9b0c4e7a1c0e16d0eefac3224b64edd260d9bd28 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:38:53 +0000 Subject: [PATCH 07/10] Change 'Install method' to 'Dependencies' with more detail --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e76fe5..488c623 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ There are many tools for search/replace and refactoring. Here's how repren compa | Structural/AST-aware | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | | Dry run + backups + undo | ✅ | ❌ | ❌ | Preview | Preview | Preview | ✅ | | Interactive interface | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | -| Install method | Python (zero deps) | Varies (OS/shell) | Binary | Binary | Binary | Binary | Binary | +| Dependencies | Python 3.10+ (no other deps) | Varies (OS/shell) | Binary (Rust) | Binary (Rust) | Binary (Rust) | Binary (OCaml) | Binary (Rust) | **When to use each:** From 328e7c9266a4010076c12c0ae92df06cf8dddc12 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:41:04 +0000 Subject: [PATCH 08/10] Merge dry run and interactive rows into single 'Interactivity' row --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 488c623..734121b 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,7 @@ There are many tools for search/replace and refactoring. Here's how repren compa | Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | | Language-agnostic | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | | Structural/AST-aware | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | -| Dry run + backups + undo | ✅ | ❌ | ❌ | Preview | Preview | Preview | ✅ | -| Interactive interface | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | +| Interactivity | Dry run, backups, undo | ❌ | ❌ | Interactive review | Interactive review | Interactive review | Dry run, backups, undo | | Dependencies | Python 3.10+ (no other deps) | Varies (OS/shell) | Binary (Rust) | Binary (Rust) | Binary (Rust) | Binary (OCaml) | Binary (Rust) | **When to use each:** From d7bb3b0f74115860abe43f940c4c197348bf394d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:45:44 +0000 Subject: [PATCH 09/10] Update Alternatives section in docs and docstring Update docs/repren-docs.md (source of truth) with modern tool comparison table including sed/awk/perl, sd, fastmod, ast-grep, comby, and rnr. The gendocs script propagates this to README.md and repren.py docstring. --- docs/repren-docs.md | 45 ++++++++++++++++++++++++++++++--------------- repren/repren.py | 45 ++++++++++++++++++++++++++++++--------------- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/docs/repren-docs.md b/docs/repren-docs.md index 6cb5bd2..0643ae7 100644 --- a/docs/repren-docs.md +++ b/docs/repren-docs.md @@ -111,21 +111,36 @@ If no arguments are supplied, it reads from stdin and writes to stdout. ## Alternatives -Aren’t there standard tools for this already? - -It’s a bit surprising, but not really. -Getting the features right is a bit tricky, I guess. -The -[standard](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) -[answers](http://stackoverflow.com/questions/6840332/rename-multiple-files-by-replacing-a-particular-pattern-in-the-filenames-using-a) -like *sed*, *perl*, *awk*, *rename*, *Vim* macros, or even IDE refactoring tools, often -cover specific cases, but tend to be error-prone or not offer specific features you -probably want. Things like nondestructive mode, file renaming as well as search/replace, -multiple simultaneous renames/swaps, or renaming enclosing parent directories. -Also many of these vary by platform, which adds to the corner cases. -Inevitably you end up digging through the darker corners of a man page, doing -semi-automated things in an IDE, or writing hacked scripts that are an embarrassment to -share. +There are many tools for search/replace and refactoring. Here's how repren compares: + +### Comparison + +| Feature | repren | [sed/awk/perl](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) | [sd](https://github.com/chmln/sd) | [fastmod](https://github.com/facebookincubator/fastmod) | [ast-grep](https://ast-grep.github.io/) | [comby](https://comby.dev/) | [rnr](https://github.com/ismaelgv/rnr) | +| --- | --- | --- | --- | --- | --- | --- | --- | +| Simultaneous edits and swaps (foo↔bar) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| File/directory renaming | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | +| Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| Language-agnostic | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | +| Structural/AST-aware | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | +| Interactivity | Dry run, backups, undo | ❌ | ❌ | Interactive review | Interactive review | Interactive review | Dry run, backups, undo | +| Dependencies | Python 3.10+ (no other deps) | Varies (OS/shell) | Binary (Rust) | Binary (Rust) | Binary (Rust) | Binary (OCaml) | Binary (Rust) | + +**When to use each:** + +- **repren**: Bulk renames with file/directory renaming, case preservation, or simultaneous + swaps. Works on any text file with full backup/undo support. +- **sed/awk/perl**: Quick one-liners if you know the syntax. See + [classic approaches](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549). + Often lack dry-run mode, simultaneous swaps, or cross-platform consistency. +- **sd**: Simple, fast sed replacement for straightforward find/replace (2-11x faster than + sed). +- **fastmod**: Large codebase refactors where you want interactive human review of each + change. +- **ast-grep**: Language-aware refactoring where you need to match code structure (e.g., + function calls, not just text). Supports 40+ languages. +- **comby**: Structural matching across languages without learning AST syntax. +- **rnr**: File/directory renaming only (no content replacement). Has dry-run by default, + backup option, and undo via dump files. ## Installation diff --git a/repren/repren.py b/repren/repren.py index 7c468b3..2e1cba0 100755 --- a/repren/repren.py +++ b/repren/repren.py @@ -113,21 +113,36 @@ ## Alternatives -Aren’t there standard tools for this already? - -It’s a bit surprising, but not really. -Getting the features right is a bit tricky, I guess. -The -[standard](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) -[answers](http://stackoverflow.com/questions/6840332/rename-multiple-files-by-replacing-a-particular-pattern-in-the-filenames-using-a) -like *sed*, *perl*, *awk*, *rename*, *Vim* macros, or even IDE refactoring tools, often -cover specific cases, but tend to be error-prone or not offer specific features you -probably want. Things like nondestructive mode, file renaming as well as search/replace, -multiple simultaneous renames/swaps, or renaming enclosing parent directories. -Also many of these vary by platform, which adds to the corner cases. -Inevitably you end up digging through the darker corners of a man page, doing -semi-automated things in an IDE, or writing hacked scripts that are an embarrassment to -share. +There are many tools for search/replace and refactoring. Here's how repren compares: + +### Comparison + +| Feature | repren | [sed/awk/perl](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549) | [sd](https://github.com/chmln/sd) | [fastmod](https://github.com/facebookincubator/fastmod) | [ast-grep](https://ast-grep.github.io/) | [comby](https://comby.dev/) | [rnr](https://github.com/ismaelgv/rnr) | +| --- | --- | --- | --- | --- | --- | --- | --- | +| Simultaneous edits and swaps (foo↔bar) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| File/directory renaming | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | +| Case-preserving variants | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| Language-agnostic | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | +| Structural/AST-aware | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | +| Interactivity | Dry run, backups, undo | ❌ | ❌ | Interactive review | Interactive review | Interactive review | Dry run, backups, undo | +| Dependencies | Python 3.10+ (no other deps) | Varies (OS/shell) | Binary (Rust) | Binary (Rust) | Binary (Rust) | Binary (OCaml) | Binary (Rust) | + +**When to use each:** + +- **repren**: Bulk renames with file/directory renaming, case preservation, or simultaneous + swaps. Works on any text file with full backup/undo support. +- **sed/awk/perl**: Quick one-liners if you know the syntax. See + [classic approaches](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549). + Often lack dry-run mode, simultaneous swaps, or cross-platform consistency. +- **sd**: Simple, fast sed replacement for straightforward find/replace (2-11x faster than + sed). +- **fastmod**: Large codebase refactors where you want interactive human review of each + change. +- **ast-grep**: Language-aware refactoring where you need to match code structure (e.g., + function calls, not just text). Supports 40+ languages. +- **comby**: Structural matching across languages without learning AST syntax. +- **rnr**: File/directory renaming only (no content replacement). Has dry-run by default, + backup option, and undo via dump files. ## Installation From 6f31aea26aae7f428172814736e4611490626557 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 17:54:45 +0000 Subject: [PATCH 10/10] Refine Alternatives section to be more prescriptive about repren advantages Update "When to use each" section to more clearly highlight the limitations of alternatives compared to repren: - sed/awk/perl: note error-prone nature for complex patterns - sd: clarify lacks file renaming, case preservation, multi-pattern swaps - fastmod: note lacks case preservation, swaps, and file renaming - ast-grep: recommend when semantic understanding matters more than speed - comby: note structural matching is overkill for simple text refactoring - rnr: recommend repren if content replacement is also needed --- README.md | 21 ++++++++++++--------- docs/repren-docs.md | 21 ++++++++++++--------- repren/repren.py | 21 ++++++++++++--------- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 734121b..016a156 100644 --- a/README.md +++ b/README.md @@ -142,18 +142,21 @@ There are many tools for search/replace and refactoring. Here's how repren compa - **repren**: Bulk renames with file/directory renaming, case preservation, or simultaneous swaps. Works on any text file with full backup/undo support. -- **sed/awk/perl**: Quick one-liners if you know the syntax. See +- **sed/awk/perl**: Classic approaches for quick one-liners. See [classic approaches](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549). - Often lack dry-run mode, simultaneous swaps, or cross-platform consistency. -- **sd**: Simple, fast sed replacement for straightforward find/replace (2-11x faster than - sed). -- **fastmod**: Large codebase refactors where you want interactive human review of each - change. + Often error-prone for complex patterns and lack dry-run mode, simultaneous swaps, or + cross-platform consistency. +- **sd**: Fast sed replacement (2-11x faster than sed), but limited to simple find/replace + without file renaming, case preservation, or multi-pattern swaps. +- **fastmod**: Good for interactive human review of changes, but lacks case preservation, + simultaneous swaps, and file/directory renaming. - **ast-grep**: Language-aware refactoring where you need to match code structure (e.g., - function calls, not just text). Supports 40+ languages. -- **comby**: Structural matching across languages without learning AST syntax. + function calls, not just text). Use when semantic understanding matters more than speed. +- **comby**: Structural matching across languages without learning AST syntax. Useful when + you need to match code patterns like balanced braces, but overkill for simple text + refactoring. - **rnr**: File/directory renaming only (no content replacement). Has dry-run by default, - backup option, and undo via dump files. + backup option, and undo via dump files. Use repren if you also need content replacement. ## Installation diff --git a/docs/repren-docs.md b/docs/repren-docs.md index 0643ae7..ed36f83 100644 --- a/docs/repren-docs.md +++ b/docs/repren-docs.md @@ -129,18 +129,21 @@ There are many tools for search/replace and refactoring. Here's how repren compa - **repren**: Bulk renames with file/directory renaming, case preservation, or simultaneous swaps. Works on any text file with full backup/undo support. -- **sed/awk/perl**: Quick one-liners if you know the syntax. See +- **sed/awk/perl**: Classic approaches for quick one-liners. See [classic approaches](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549). - Often lack dry-run mode, simultaneous swaps, or cross-platform consistency. -- **sd**: Simple, fast sed replacement for straightforward find/replace (2-11x faster than - sed). -- **fastmod**: Large codebase refactors where you want interactive human review of each - change. + Often error-prone for complex patterns and lack dry-run mode, simultaneous swaps, or + cross-platform consistency. +- **sd**: Fast sed replacement (2-11x faster than sed), but limited to simple find/replace + without file renaming, case preservation, or multi-pattern swaps. +- **fastmod**: Good for interactive human review of changes, but lacks case preservation, + simultaneous swaps, and file/directory renaming. - **ast-grep**: Language-aware refactoring where you need to match code structure (e.g., - function calls, not just text). Supports 40+ languages. -- **comby**: Structural matching across languages without learning AST syntax. + function calls, not just text). Use when semantic understanding matters more than speed. +- **comby**: Structural matching across languages without learning AST syntax. Useful when + you need to match code patterns like balanced braces, but overkill for simple text + refactoring. - **rnr**: File/directory renaming only (no content replacement). Has dry-run by default, - backup option, and undo via dump files. + backup option, and undo via dump files. Use repren if you also need content replacement. ## Installation diff --git a/repren/repren.py b/repren/repren.py index 2e1cba0..eaaed81 100755 --- a/repren/repren.py +++ b/repren/repren.py @@ -131,18 +131,21 @@ - **repren**: Bulk renames with file/directory renaming, case preservation, or simultaneous swaps. Works on any text file with full backup/undo support. -- **sed/awk/perl**: Quick one-liners if you know the syntax. See +- **sed/awk/perl**: Classic approaches for quick one-liners. See [classic approaches](http://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line/29191549). - Often lack dry-run mode, simultaneous swaps, or cross-platform consistency. -- **sd**: Simple, fast sed replacement for straightforward find/replace (2-11x faster than - sed). -- **fastmod**: Large codebase refactors where you want interactive human review of each - change. + Often error-prone for complex patterns and lack dry-run mode, simultaneous swaps, or + cross-platform consistency. +- **sd**: Fast sed replacement (2-11x faster than sed), but limited to simple find/replace + without file renaming, case preservation, or multi-pattern swaps. +- **fastmod**: Good for interactive human review of changes, but lacks case preservation, + simultaneous swaps, and file/directory renaming. - **ast-grep**: Language-aware refactoring where you need to match code structure (e.g., - function calls, not just text). Supports 40+ languages. -- **comby**: Structural matching across languages without learning AST syntax. + function calls, not just text). Use when semantic understanding matters more than speed. +- **comby**: Structural matching across languages without learning AST syntax. Useful when + you need to match code patterns like balanced braces, but overkill for simple text + refactoring. - **rnr**: File/directory renaming only (no content replacement). Has dry-run by default, - backup option, and undo via dump files. + backup option, and undo via dump files. Use repren if you also need content replacement. ## Installation