When to use it

Use this prompt for file cleanups, backups, batch renames, deployment helpers and other small automation jobs. Shell scripts are short but can do a lot of damage: a single unquoted variable or empty path can delete the wrong directory. The prompt is built around safety first, so it suits people who write scripts occasionally as well as administrators who want a consistent standard.

How to customize it

  • [SHELL] decides the syntax. Bash, POSIX sh, Windows PowerShell 5.1 and PowerShell 7 all behave differently.
  • [OPERATING SYSTEM] matters because tools such as find, sed and date take different flags on Linux and macOS.
  • [HOW IT RUNS] changes logging and error handling: a cron job has no one watching the terminal.
  • [INPUTS] should list every argument and environment variable the script expects.
  • [THINGS IT MUST NEVER TOUCH] is your guardrail. Be explicit about directories, file types and time windows.

Why it works

The requirements list encodes common defensive practices: fail on errors, validate inputs, quote variables and log actions. Without them, generated scripts often work on the happy path and fail dangerously on the unusual one, such as a missing argument that turns a path into /.

The dry-run default is the most important safety feature. It lets you see exactly which files would be affected before anything changes. The plain-English list of changes gives a reviewer who does not read shell fluently a way to approve the script. If an AI agent will run scripts for you, combine this with the advice in our guide on least-privilege API keys for AI coding agents.

Tips and variations

  • Always run the dry run on a test folder or a copy of the data first.
  • Run shellcheck on Bash scripts or PSScriptAnalyzer on PowerShell scripts before using them.
  • Ask “What happens if this script is run twice?” to check that it is safe to repeat.
  • Never paste passwords or tokens into the prompt; use placeholders and a secrets manager.
  • For scripts that run unattended, ask for a lock file so two copies cannot run at the same time.