name: ai-cli description: >- Use modern, token-efficient command-line tools (fd, ripgrep, ast-grep, bat, sd, jq, yq, tokei, eza, dust, procs, delta, hyperfine, just) instead of legacy coreutils (find, grep, cat, sed, ls, du, ps) for any shell, file, or codebase task — on any platform (Linux/macOS/Windows) and through any executor (a terminal, Claude Code's bash tool, Desktop Commander, or an MCP shell bridge). Trigger whenever you are about to search files, grep for text, read or inspect files, find-and-replace, refactor code, traverse a repository, process JSON/YAML, or inspect disk usage or processes — even if the user did not name a specific tool. These tools are faster, .gitignore-aware, and emit clean structured output that protects the context window. For installation across operating systems and platform-specific quirks, see references/. If you run commands specifically through the LocalREPL MCP bridge, also consult the local-repl-cli skill for environment-specific gotchas.
AI-CLI — Modern Command-Line Tools for Agents
Legacy GNU coreutils (find, grep, cat, sed, ls) were designed for a
human at a terminal. They are slow, awkward to compose, and emit output hostile
to a language model's context window. This skill maps common shell tasks onto
fast, structured-output replacements and defines the invocation rules that keep
them predictable for an agent.
This skill is execution-agnostic. The rules below hold whether you run
commands in a plain terminal, via Claude Code's bash tool, via Desktop
Commander, or through an MCP shell bridge. What does change between
environments — $PATH inheritance, which shell /bin/sh points to, pager
behavior, GNU-vs-BSD flag differences — is covered in
references/cross-platform.md. Read it before debugging anything that "works
in my terminal but not here."
Why this matters for an agent
Three failure modes to design against:
- Context blowout —
cat-ing a 10,000-line file dumps the whole thing into context. Read surgically instead. - Recursion noise & loops —
finddescends intonode_modules/,.git/,.venv/, producing thousands of irrelevant paths. The modern tools respect.gitignoreand skip hidden dirs by default. - Tokenization corruption — ANSI color codes shatter clean tokenization. Strip them on every call.
The Golden Rules (every invocation, every platform)
- No color. Always
--color=never/--no-color. Color escapes corrupt tokenization and carry no information for an agent. - No pagers, no TUIs.
bat(anddelta,git) hang waiting on an interactive pager. Always--paging=never. Never invoke interactive modes (-i,fzf,zoxide'szi) — there is no human at the keyboard. - Read surgically. Never dump a whole file. Search first, then read a line
range around the hit (
bat -r 50:120). - Prefer structured output. Use
--json(ripgrep, ast-grep) and pipe tojq/yq. Parse data structures; don't regex over prose. - Stay deterministic and safe. Preview any file mutation before applying
(
sd -p, ast-grep without--update-all). When chaining steps in bash, useset -euo pipefail— but see cross-platform.md, since/bin/shmay be dash, not bash. - Emit absolute paths. Prefer absolute paths (
fd -a) so a later step never depends on the current working directory.
Task → Tool quick map
| Goal | Tool | Replaces | Canonical agent one-liner |
|---|---|---|---|
| Find files by name/type | fd |
find |
fd -a --color=never -e py pattern |
| Search file contents | rg (ripgrep) |
grep |
rg --json 'pattern' |
| Search/rewrite by code structure | ast-grep |
grep+sed |
ast-grep -p 'pat' -l python |
| Read part of a file | bat |
cat |
bat --style=plain --paging=never -r 40:80 f |
| Find & replace text | sd |
sed |
sd -p 'before' 'after' file |
| Process JSON | jq |
— | rg --json x | jq -r '.data.path.text' |
| Process YAML/TOML | yq |
— | yq '.key' f.yaml |
| Size up a codebase | tokei |
wc/cloc |
tokei --output json |
| List a directory tree | eza |
ls/tree |
eza --tree --level=2 --color=never |
| Disk usage | dust |
du |
dust -d 1 |
| Inspect processes | procs |
ps |
procs --no-color |
| Read a git diff | delta |
git diff pager |
git diff | delta --no-gitconfig |
| Run project tasks | just |
make |
just <recipe> |
| Benchmark a command | hyperfine |
time |
hyperfine --warmup 3 'cmd' |
Choosing your search tool: fd vs rg vs ast-grep
fd— you know something about the filename, path, or type ("find alltest_*.py").rg— you want text/content anywhere, as a fast first pass. Use-lto get just filenames to feed the next step.ast-grep— you care about code structure, not text (refactors; "find every call tofoo()regardless of whitespace, comments, or wrapping"). Regex can't see thatfoo(\n a,\n b)equalsfoo(a, b); ast-grep can — and it won't clobber a substring inside another name.
Rule of thumb: locate with rg/fd, transform with ast-grep/sd.
Core tools (agent-optimized invocations)
fd — file discovery (replaces find)
.gitignore- and hidden-aware by default; -H includes hidden, -I ignores
ignore-files (needed when cleaning gitignored cache dirs). Smart-case.
fd -a -e py 'test_'— absolute paths, Python files matchingtest_fd -t d -a '__pycache__'— directories onlyfd -e json -x jq '.version' {}— run a command per match (parallel)
ripgrep (rg) — content search (replaces grep)
rg --color=never 'TODO'— basic recursive searchrg --json 'fn main'— structured records; pipe tojqrg -l 'import torch'— files-with-matches only; feed to the next toolrg -t py -C 3 'def train'— Python only, 3 lines of contextrg -F 'literal[brackets]'— fixed-string mode
ast-grep — structural search & rewrite (replaces grep+sed for code)
- ⚠️ On Linux the command is
ast-grep, notsg(sgissetgroups). - search:
ast-grep -p 'console.log($A)' -l js - rewrite (preview):
ast-grep -p 'console.log($A)' -r 'logger.info($A)' -l js - apply: add
-U/--update-all— preview first, then re-run with-U. - metavariables:
$VAR= one node;$$$ARGS= a sequence. ($$$binds arg lists, not function bodies —def $NAME($$$): $$$matches nothing.)
bat — surgical file reading (replaces cat)
- ⚠️ Always
--paging=neveror it hangs on a pager. bat --style=plain --paging=never --color=never -r 50:120 file.py- use
--style=numberswhen you need line numbers to plan an edit.
sd / jq / yq — replace & structured data
sd -p 'foo' 'bar' file— preview find/replace; drop-pto apply. For code identifiers use ast-grep instead (sd clobbers substrings).jq -r '.items[].name' f.json— raw strings out;jq -cfor compact.yq '.tools.python' pyproject.toml— yq handles YAML/TOML/JSON/XML.
Extended tools
- tokei —
tokei --output jsonfor languages/files/lines. First move when sizing an unfamiliar repo. - eza — directory listing; the maintained successor to
exa(which is abandoned — don't useexa).eza --tree --level=2 --color=never. - dust —
dust -d 1shows what's eating disk (replacesdu). - procs —
procs --no-color python(replacesps). - delta — a viewer for git/unified diffs; pipe
git diffthrough it. - hyperfine —
hyperfine --warmup 3 'a' 'b'for rigorous benchmarking. - just — a command runner (replaces
make);just --list,just <recipe>.
Installation & cross-platform
references/installation.md— install matrix across Linux package managers, macOS (Homebrew), Windows (scoop/winget), and the universalcargo/npm/piproutes; includes the Debianfd→fdfind/bat→batcatrename trap.references/cross-platform.md— OS and shell differences agents trip on: GNU vs BSD/macOS flags, thesg/setgroups clash,$PATHinheritance in spawned subprocesses,/bin/sh-is-dash, and Windows/WSL/PowerShell notes.references/cookbook.md— execution-agnostic combined pipelines (orient-in-a-repo, locate→read, safe refactor, rg→jq).scripts/check_tools.sh— POSIX self-check (OK/MISSING + install hints). On Windows run it under WSL or Git Bash, or port the loop to PowerShell.
When to use this skill
Trigger when the task involves searching, inspecting, counting, comparing, refactoring, or traversing files/code, or extracting fields from JSON/YAML — even when no specific tool is named. Do NOT trigger for pure in-language work (writing a Python function), single-file edits handled by an edit tool, or questions that don't touch the filesystem.
Running through a specific executor
The tool knowledge here is identical regardless of how shell runs. Only the
wrapper differs: Claude Code's bash tool and Desktop Commander's process tools
work directly. If you run commands through the LocalREPL MCP bridge, also
read the local-repl-cli skill — it documents that environment's specific
gotchas (structured run_shell output, /bin/sh not bash, PATH inheritance,
ripgrep's stdin-hang, and operational-memory logging).