| name | cli-fd |
| description | Covers effective use of fd as a modern, fast replacement for `find`. Covers fd PATTERN, -e ext, -t type, -H hidden, -I no-ignore, -x exec, -X batch exec, -E exclude, --changed-within, -d depth, --size, bulk operations, exec placeholders, and combining with ripgrep, bat, and fzf. Activates when the user asks about fd, finding files by name/type/date/size, or running commands on matched files.
|
fd — Modern find Replacement
Repo: https://github.com/sharkdp/fd
fd is a simple, fast alternative to find. It uses Rust regex for pattern
matching, respects .gitignore by default, colorizes output, and has an
intuitive interface. Replaces the majority of find use cases with far less
typing.
When to Activate
Manual triggers:
- "How do I use fd?"
- "Find files by name / extension / type"
- "Find files changed recently"
- "Run a command on all files matching a pattern"
Auto-detect triggers:
- User wants to locate files in a project tree
- User wants to filter by file extension, size, or modification time
- User wants to run a command on every matched file
- User is building a pipeline with ripgrep, bat, or fzf
Key Commands
Basic Search
fd
fd 'config'
fd '^config\.'
fd 'test' src/
fd 'README' ~ /tmp
Filter by Extension and Type
fd -e ts
fd -e ts -e tsx
fd -t f
fd -t d
fd -t l
fd -t x
fd -t e
fd -e json -t f 'schema'
Hidden & Ignored Files
fd -H 'dotfile'
fd -I 'node_modules'
fd -HI '.env'
fd --no-ignore-vcs 'build'
Depth & Size
fd -d 2 'config'
fd --min-depth 2 'test'
fd --size +1mb -t f
fd --size -10kb -e log
fd --size +100kb --size -1mb -t f
Time-Based Filtering
fd --changed-within 1d
fd --changed-within '1 week'
fd --changed-before '2024-01-01'
fd -e log --changed-within 1h
Excluding Paths
fd -E node_modules
fd -E '*.test.ts'
fd -E '.git' -E dist -E node_modules
Executing Commands on Results
-x — Run command per file (parallel by default)
fd -e png -x convert {} {.}.jpg
fd -e py -x black {}
fd 'Makefile' -x make -C {//}
fd -e ts -x wc -l
Exec Placeholders
| Placeholder | Meaning |
|---|
{} | full path (./src/app.ts) |
{/} | filename only (app.ts) |
{//} | parent directory (./src) |
{.} | path without extension (./src/app) |
{/.} | filename without extension (app) |
-X — Batch exec (all results as one invocation)
fd -e ts -X eslint
fd -e md -X prettier --write
fd -t f -e log -X rm
fd -e ts -X wc -l | sort -rn | head
Pipe to xargs
fd -e json | xargs jq '.version'
fd -e ts -0 | xargs -0 grep -l 'useEffect'
fd -e ts | xargs -P4 tsc --noEmit
Advanced Patterns
Bulk Rename
fd -e jpeg -x mv {} {.}.jpg
fd 'spec\.ts$' -x mv {} {//}/new_{/}
fd -e ts | xargs rename 's/Component/Widget/g'
Bulk Archive / Copy
fd '.env.example' -x cp {} {.}
fd -e md -X tar czf docs.tar.gz
Find Large Directories (disk usage)
fd -t d -d 1 | xargs du -sh | sort -rh | head -20
Count Files by Extension
fd -t f | sed 's/.*\.//' | sort | uniq -c | sort -rn | head -15
Find Duplicate Filenames
fd -t f -x basename {} | sort | uniq -d
Search, Then Open in Editor
code $(fd -e ts 'UserService')
fd -e ts | fzf -m | xargs code
Integration with ripgrep
fd -e ts --changed-within 1d | xargs rg 'TODO'
fd -e ts -E '*.test.ts' -E '*.spec.ts' src/ | while read f; do
[[ ! -f "${f%.ts}.test.ts" ]] && echo "missing test: $f"
done
Practical Examples
Pre-commit Cleanup
fd -e js -E 'node_modules' dist/ -X rm
fd __pycache__ -t d -X rm -rf
Watch for New Files (poll approach)
while true; do
fd --changed-within 5s -e ts | xargs -r npx tsc --noEmit
sleep 5
done
List Files Ignored by Git (find what .gitignore hides)
fd -I --type f | rg --files-without-match '.' --no-ignore
Quick Project Stats
echo "=== File counts by type ==="
for ext in ts js py go rs; do
count=$(fd -e $ext -t f | wc -l)
echo " .$ext: $count"
done
Configuration (.fdignore)
# .fdignore — same syntax as .gitignore, placed at project root or ~/.config/fd/ignore
node_modules/
dist/
.next/
.cache/
*.min.js
*.d.ts
coverage/
Chaining with Other Skills
- ripgrep (cli-ripgrep): Use
fd to select files (by type, date, size), then pipe to rg for content search — cleaner and faster than rg -g globs for complex file filters.
- bat:
fd -e md | xargs bat --language=md — syntax-highlighted preview of all markdown files.
- fzf (cli-fzf): Set
FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' so fzf uses fd for file listing; also pipe fd results into fzf for interactive selection.