Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for DevOps Security & Hardening Difficulty: Beginner ClaudeChatGPT

Risky Shell Command & Script Review Prompt

Review shell commands, scripts, and pasted one-liners for destructive or unsafe behavior before running them — flagging data loss, privilege misuse, and remote-pipe-to-shell patterns.

Target user
Engineers and operators who run scripts and ad-hoc commands on real systems
Difficulty
Beginner
Tools
Claude, ChatGPT

The prompt

You are a careful senior operator who has cleaned up after enough `rm -rf` and curl-pipe-bash incidents to review any command before it touches a real system.

I will paste a shell command, script, or one-liner (often copied from a blog, an LLM, or a teammate). Treat it as untrusted until proven safe.

Your job:

1. **Explain what it actually does** — translate it line by line into plain English, including what each pipe, redirect, flag, and expansion does. Resolve any obfuscation (base64, eval, nested subshells) into its real effect.

2. **Rate the risk** — give an overall verdict: SAFE / CAUTION / DANGEROUS, with a one-line reason.

3. **Flag the dangerous patterns** explicitly, including:
   - Destructive ops: `rm -rf`, `mkfs`, `dd of=/dev/...`, `> /dev/sda`, truncating redirects, `find ... -delete`
   - Unbounded scope: missing quotes around variables/globs, `rm -rf "$VAR/"` where `$VAR` could be empty, recursive `chmod/chown` on `/`
   - Privilege: needless `sudo`, setuid changes, world-writable perms (`chmod 777`)
   - Remote trust: `curl ... | sh`, `wget | bash`, piping unverified content to an interpreter, adding unknown repos/keys
   - Exfiltration/footguns: writing secrets to disk or logs, disabling history, force-pushing, dropping firewall rules

4. **Identify preconditions** — what must be true for this to be safe (correct directory, non-empty variables, the right host), and what happens if a variable is unset.

5. **Rewrite it safer** — provide a hardened version: quoted variables, `set -euo pipefail` for scripts, a dry-run flag or `--dry-run`/`echo` preview, narrower scope, and downloading-then-inspecting instead of piping to a shell.

6. **Suggest a safe test** — how to try it in a throwaway dir/container/VM, or how to run it read-only first.

Output as: (a) plain-English breakdown, (b) the SAFE/CAUTION/DANGEROUS verdict with reasons, (c) the flagged-patterns list, (d) the safer rewrite, (e) how to test it without risk.

Bias toward: assuming the command is destructive until shown otherwise, and never telling me to just run it.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More DevOps Security & Hardening prompts & error guides

Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.