CLI flag safety
Use before running or suggesting shell commands with flags, especially destructive or broad ones (-f/--force, -r/-R recursive, -a/--all, -y/--yes, prune, --hard), and when a user asks what a flag means (-v, -q, -n/--dry-run, -h, -o, -p, -t, -u, -w, -x, -c, -i). Explains flags per tool and prefers dry runs and narrow scopes.
Licence MIT
Source delaparra-original
Download zipCLI flag safety
Flags change what a command does, and the same letter means different things in different tools. Before running a command, know what each flag does for that tool, and choose the least destructive form.
Before running anything
- Check the tool's own help:
<tool> --help,<tool> <subcommand> --helporman <tool>. Never assume a letter's meaning carries over from another tool. - Preview first when the tool supports it:
--dry-run/-n(rsync -n,git clean -n,kubectl apply --dry-run=client,terraform plan),--what-if(PowerShell-WhatIf). - Narrow the scope: a specific path or name instead of
-a/--all,.or*. Print the target list first (ls,docker ps -a,git status). - Quote paths and variables:
rm -rf -- "$dir", neverrm -rf $dir/(an empty variable becomesrm -rf /). - Ask for confirmation from the user before any command that deletes data, rewrites history or affects production.
Same letter, different meaning
| Flag | Common meanings | Examples |
|---|---|---|
-a / --all | all items, including hidden/stopped | ls -a, docker ps -a, git commit -a (stages all tracked changes!) |
-c | count / config / command string | grep -c, git -c key=val, bash -c "…" |
-f / --force | force, or file | rm -f, git push -f (prefer --force-with-lease), docker compose -f file.yml, tar -f |
-h / --help | help, or human-readable | ls -lh, df -h (here -h is not help) |
-i | interactive / in-place / case-insensitive | rm -i, sed -i (edits file!), grep -i, docker run -it |
-n / --dry-run | dry run, or line numbers | git clean -n, grep -n, head -n 20 |
-o / --output | output file or format | curl -o file, kubectl get -o yaml, grep -o (only matching part) |
-p | port / parents / publish | mkdir -p, docker run -p 8080:80, ssh -p 2222 |
-q / --quiet | suppress output | grep -q (exit code only), docker ps -q |
-r / -R | recursive | rm -r, cp -r, grep -r, chmod -R |
-t | tag / TTY | docker build -t name:tag, docker run -t |
-u | upstream / user | git push -u origin main, docker exec -u root |
-v | verbose / version / volume / invert | curl -v, node -v, docker run -v, grep -v (invert match!) |
-w / --watch | watch for changes | kubectl get pods -w, tsc -w |
-x | trace / exclude / extract | bash -x (trace), tar -x (extract) |
-y / --yes | assume yes to prompts | apt install -y, npx -y |
-- | end of options | git checkout -- file, rm -- -weird-name |
--no-x | negate a flag | --no-verify (skips hooks: avoid), --no-cache |
High-risk combinations (confirm first)
rm -rf,git reset --hard,git clean -fdx,git push --forcedocker system prune -a --volumes(deletes data volumes),docker compose down -vkubectl delete … --all,terraform destroy,terraform apply -auto-approvechmod -R 777(never; use the minimal permissions needed)--no-verify(bypasses checks the team put in place)
Scripts
In Bash scripts start with set -euo pipefail, quote every variable, and run shellcheck on the script.
Files
LICENSESKILL.mdSOURCE.md
Related terms
- --dry-run, -n (Dry Run)
- --no-X, --without-X (Negation flag)
- --version, -V (Version)
- -a, --all (All)
- -c, --count, --config (Count / Config)
- -f, --force (Force)
- -h, --help (Help)
- -i, --interactive (Interactive)
- -o, --output (Output)
- -p (context-dependent) (Port / Parents / Publish)
- -q, --quiet, --silent (Quiet / Silent)
- -r, -R, --recursive (Recursive)
- -t, --tag, -t (tty) (Tag / Allocate TTY)
- -u, --upstream, --user (Upstream / User)
- -v, --verbose (Verbose)
- -w, --watch (Watch)
- -x, --exclude, -x (trace) (Extract / Exclude / Trace)
- -y, --yes, --assume-yes (Auto-Yes)
- > and >>
- | (pipe)
- cat
- cd
- chmod
- chown
- cp
- curl
- echo
- env
- export
- grep
- head
- kill
- less
- ls
- man
- mkdir
- mv
- ps
- pwd
- rm
- scp
- source
- ssh
- sudo
- tail
- tar
- top / htop
- wget
- which
- zip / unzip
Installing an agent skill in Claude Code, Codex, Cursor and Copilot