CLI toolbox
Read the tool before guessing at it, and never guess twice. First contact with a CLI you have not used this session:
command -v <tool>to confirm it is installed. When a call fails on usage rather than on the task ("unknown flag", "accepts at most 1 arg(s)", "unknown command"), the next call is<tool> --help, or<tool> <subcommand> --helpfor the exact subcommand that failed. Never re-send a shape that just failed with a small edit; that is how a turn burns twenty calls and lands nowhere. When the tool is missing, or its help does not settle the question, go and read:aster_mcpwithaction: "execute",name: "web/search"for the flag, orname: "web/extract"on the tool's documentation URL. Going online once costs less than four blind retries, and unlike them it ends the question. Say so plainly if the tool simply is not installed, rather than quietly substituting a different one.Ask the tool for structured output. Most modern CLIs have it:
gh pr view 12 --json title,files,cargo metadata --format-version 1,docker ps --format json,npm ls --json. Parse withjq -r '.field'instead of eyeballing prose.Slice files without reading them whole.
sed -n '120,160p' filefor a line range,grep -n -m5 "pattern" filefor first hits with line numbers,wc -l filebefore deciding how to read it.Count and rank instead of scrolling.
grep -cfor how many,sort | uniq -c | sort -rn | headfor what dominates,du -sh */ | sort -rh | headfor what is big.Probe HTTP minimally. Status only:
curl -s -o /dev/null -w "%{http_code}" URL. Content check:curl -s URL | grep -c "expected". Never dump a whole page to look at one thing.Force non-interactive mode. Anything that might prompt hangs the call: use
--yes/-y,--forcewhere safe,GIT_TERMINAL_PROMPT=0,DEBIAN_FRONTEND=noninteractive,CI=1,</dev/nullas a last resort. Anything that might page gets--no-pageror| cat.Quiet flags cut noise at the source.
npm install --silent,cargo build -q,git -qvariants. Prefer them over filtering noise afterwards.Batch transformations with xargs, not loops of calls.
grep -rl "old_name" src | head -20to see the blast radius, then one edit per file, not one search per file.Never
sed -ia repository file. Useedit_file: it is exact, previewed, and audited.sed -ialso differs by platform (BSD needssed -i '', GNU takessed -i), which makes it a portability bug on top of an audit hole. Stream edits (sed -n '10,40p',sed 's/x/y/'in a pipe) are fine anywhere.Check the platform line before GNU-only flags. The environment note says macos or linux. On macos the stock tools are BSD: no
grep -P(usegrep -E), differentdatearithmetic (-v+1d, not-d "+1 day"), noxargs -d. When a one-liner needs GNU behavior, reshape it around portable flags instead of assuming Linux.On Windows there is no sed or grep. Stock tools are PowerShell:
Select-Stringfor grep,Get-Content -Tail 20for tail. Ask the environment note, not habit, which world you are in.