DELAPARRA
Index
Color
NL

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 zip

CLI 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

  1. Check the tool's own help: <tool> --help, <tool> <subcommand> --help or man <tool>. Never assume a letter's meaning carries over from another tool.
  2. 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).
  3. Narrow the scope: a specific path or name instead of -a/--all, . or *. Print the target list first (ls, docker ps -a, git status).
  4. Quote paths and variables: rm -rf -- "$dir", never rm -rf $dir/ (an empty variable becomes rm -rf /).
  5. 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 --force
  • docker system prune -a --volumes (deletes data volumes), docker compose down -v
  • kubectl delete … --all, terraform destroy, terraform apply -auto-approve
  • chmod -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

  • LICENSE
  • SKILL.md
  • SOURCE.md

Related terms

Installing an agent skill in Claude Code, Codex, Cursor and Copilot