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
-
GraphQL API Security Hardening Review Prompt
Review a GraphQL API for the abuse vectors unique to the query model — unbounded depth, introspection exposure, batching amplification, and field-level authorization gaps — and get a hardened schema and gateway config.
-
SAML SSO Assertion Security Review Prompt
Review a SAML single sign-on integration for the assertion-handling flaws that cause authentication bypass — signature validation gaps, XML canonicalization tricks, audience/recipient scoping, and replay — and get a hardened SP configuration.
-
Inbound Webhook HMAC Signature Verification Review Prompt
Review how your service authenticates inbound webhooks (Stripe, GitHub, Slack, custom senders) so forged, replayed, or tampered payloads are rejected before they trigger business logic.
-
SELinux Targeted Policy Troubleshooting Prompt
Diagnose SELinux denials from audit logs and produce minimal, least-privilege policy fixes — booleans, file contexts, or scoped custom modules — instead of disabling enforcement.
More DevOps Security & Hardening prompts & error guides
Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.
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.