sd
Use this skill when the user wants to find and replace text in files, especially with regex patterns, or when they need an easier alternative to sed for text transformation.
Files1
View on GitHubSKILL.mdplugins/sd/skills/quickstart/SKILL.md
GitHubsd Plugin
Intuitive find & replace CLI — sed alternative with regex support. ~11x faster than sed.
Commands
Find & Replace
sd replace file— Find and replace in a file (in-place)sd replace run— Find and replace across one or more filessd replace preview— Preview changes in a file without modifyingsd replace fixed— Fixed string mode (no regex), in-placesd replace across— Cross-line matching (dot matches newlines), in-placesd self version— Print sd version
Args (all structured commands)
--find— Pattern (regex, or literal string forfixed)--replace— Replacement string (supports capture groups:$1,$2)--file— File to operate on--files— File(s) forreplace run
Usage Examples
- "Replace 'foo' with 'bar' in a file"
- "Preview changes before modifying"
- "Replace with regex capture groups"
- "Literal string replace (no regex escaping)"
- "Match across lines in a file"
Installation
cargo install sd
sc plugins install ./plugins/sd --on-conflict replace --json
sc Command Examples
# In-place replacement
sc sd replace file --find "before" --replace "after" --file config.txt
# Preview (no modification)
sc sd replace preview --find "before" --replace "after" --file config.txt
# Fixed literal string (no regex)
sc sd replace fixed --find "hello.world" --replace "hi" --file config.txt
# Capture groups
sc sd replace file --find "(\w+)=(\w+)" --replace "$1: $2" --file env.txt
# Multi-file (via replace run)
sc sd replace run --find "oldname" --replace "newname" --files "*.txt"
# Cross-line (dot matches \n)
sc sd replace across --find "hello.world" --replace "hi universe" --file data.txt
Raw sd examples (via passthrough)
# Trim trailing whitespace
echo "lorem ipsum 23 " | sd '\s+$' ''
# Capture groups on stdin
echo "cargo +nightly watch" | sd '(\w+)\s+\+(\w+)\s+(\w+)' 'cmd: $1, channel: $2, subcmd: $3'
Key Features
- Intuitive syntax (no
/gflag needed, replaces all by default) - JS/Python regex syntax (friendlier than POSIX)
- ~11x faster than sed
- Supports
$1,$2capture group references -f sflag makes.match newlines (cross-line patterns)-Fflag for literal string matching (no regex escaping needed)