# 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](<https://delaparra-services.nl/skills/cli-flag-safety/download>)   

# 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. 
1. **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 `). 
1. **Narrow the scope:** a specific path or name instead of ` -a `/` --all `, ` . ` or ` * `. Print the target list first (` ls `, ` docker ps -a `, ` git status `). 
1. **Quote paths and variables:** ` rm -rf -- "$dir" `, never ` rm -rf $dir/ ` (an empty variable becomes ` rm -rf / `). 
1. **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

 

- [--dry-run, -n (Dry Run)](<https://delaparra-services.nl/knowledge-hub/dry-run-n-dry-run>) 
- [--no-X, --without-X (Negation flag)](<https://delaparra-services.nl/knowledge-hub/no-x-without-x-negation-flag>) 
- [--version, -V (Version)](<https://delaparra-services.nl/knowledge-hub/version-v-version>) 
- [-a, --all (All)](<https://delaparra-services.nl/knowledge-hub/a-all-all>) 
- [-c, --count, --config (Count / Config)](<https://delaparra-services.nl/knowledge-hub/c-count-config-count-config>) 
- [-f, --force (Force)](<https://delaparra-services.nl/knowledge-hub/f-force-force>) 
- [-h, --help (Help)](<https://delaparra-services.nl/knowledge-hub/h-help-help>) 
- [-i, --interactive (Interactive)](<https://delaparra-services.nl/knowledge-hub/i-interactive-interactive>) 
- [-o, --output (Output)](<https://delaparra-services.nl/knowledge-hub/o-output-output>) 
- [-p (context-dependent) (Port / Parents / Publish)](<https://delaparra-services.nl/knowledge-hub/p-context-dependent-port-parents-publish>) 
- [-q, --quiet, --silent (Quiet / Silent)](<https://delaparra-services.nl/knowledge-hub/q-quiet-silent-quiet-silent>) 
- [-r, -R, --recursive (Recursive)](<https://delaparra-services.nl/knowledge-hub/r-r-recursive-recursive>) 
- [-t, --tag, -t (tty) (Tag / Allocate TTY)](<https://delaparra-services.nl/knowledge-hub/t-tag-t-tty-tag-allocate-tty>) 
- [-u, --upstream, --user (Upstream / User)](<https://delaparra-services.nl/knowledge-hub/u-upstream-user-upstream-user>) 
- [-v, --verbose (Verbose)](<https://delaparra-services.nl/knowledge-hub/v-verbose-verbose>) 
- [-w, --watch (Watch)](<https://delaparra-services.nl/knowledge-hub/w-watch-watch>) 
- [-x, --exclude, -x (trace) (Extract / Exclude / Trace)](<https://delaparra-services.nl/knowledge-hub/x-exclude-x-trace-extract-exclude-trace>) 
- [-y, --yes, --assume-yes (Auto-Yes)](<https://delaparra-services.nl/knowledge-hub/y-yes-assume-yes-auto-yes>) 
- [\> and \>\>](<https://delaparra-services.nl/knowledge-hub/and>) 
- [| (pipe)](<https://delaparra-services.nl/knowledge-hub/pipe>) 
- [cat](<https://delaparra-services.nl/knowledge-hub/cat>) 
- [cd](<https://delaparra-services.nl/knowledge-hub/cd>) 
- [chmod](<https://delaparra-services.nl/knowledge-hub/chmod>) 
- [chown](<https://delaparra-services.nl/knowledge-hub/chown>) 
- [cp](<https://delaparra-services.nl/knowledge-hub/cp>) 
- [curl](<https://delaparra-services.nl/knowledge-hub/curl>) 
- [echo](<https://delaparra-services.nl/knowledge-hub/echo>) 
- [env](<https://delaparra-services.nl/knowledge-hub/env-cli-commands>) 
- [export](<https://delaparra-services.nl/knowledge-hub/export>) 
- [grep](<https://delaparra-services.nl/knowledge-hub/grep>) 
- [head](<https://delaparra-services.nl/knowledge-hub/head>) 
- [kill](<https://delaparra-services.nl/knowledge-hub/kill>) 
- [less](<https://delaparra-services.nl/knowledge-hub/less>) 
- [ls](<https://delaparra-services.nl/knowledge-hub/ls>) 
- [man](<https://delaparra-services.nl/knowledge-hub/man>) 
- [mkdir](<https://delaparra-services.nl/knowledge-hub/mkdir>) 
- [mv](<https://delaparra-services.nl/knowledge-hub/mv>) 
- [ps](<https://delaparra-services.nl/knowledge-hub/ps>) 
- [pwd](<https://delaparra-services.nl/knowledge-hub/pwd>) 
- [rm](<https://delaparra-services.nl/knowledge-hub/rm>) 
- [scp](<https://delaparra-services.nl/knowledge-hub/scp>) 
- [source](<https://delaparra-services.nl/knowledge-hub/source>) 
- [ssh](<https://delaparra-services.nl/knowledge-hub/ssh>) 
- [sudo](<https://delaparra-services.nl/knowledge-hub/sudo>) 
- [tail](<https://delaparra-services.nl/knowledge-hub/tail>) 
- [tar](<https://delaparra-services.nl/knowledge-hub/tar>) 
- [top / htop](<https://delaparra-services.nl/knowledge-hub/top-htop>) 
- [wget](<https://delaparra-services.nl/knowledge-hub/wget>) 
- [which](<https://delaparra-services.nl/knowledge-hub/which>) 
- [zip / unzip](<https://delaparra-services.nl/knowledge-hub/zip-unzip>)

 

[Installing an agent skill in Claude Code, Codex, Cursor and Copilot](<https://delaparra-services.nl/manuals/een-skill-installeren-in-je-ai-assistent>)

[HTML version](https://delaparra-services.nl/skills/cli-flag-safety)
