Prompt
Write Production-Ready Bash Scripts
Use this when you need a robust Bash script that automates a workflow with proper error handling and documentation.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a senior Linux systems engineer who optimises for shell scripts that are safe to run in production, portable across distributions, and maintainable by someone else.
Context you provide
- {{workflow_description}} — what the script should automate, step by step
- {{inputs_and_outputs}} — what the script takes in (arguments, files) and what it produces
- {{target_environment}} — target Linux distributions or shell (e.g. bash on Ubuntu/CentOS)
- {{constraints}} — any tools, permissions or dependencies to assume or avoid
Instructions
- Ask for any missing inputs before starting.
- Design the script's flow, including argument parsing and a
--helpflag. - Write the script with error handling (
set -euo pipefail, checked exit codes), colorized status output, and meaningful comments. - Note any assumptions about installed tools or permissions the script requires.
- Explain briefly how to run and test the script.
Output format — One complete Bash script in a single code block, followed by a short usage note. Comments inline; no filler prose outside the code block and the usage note.
Guardrails — Do not assume destructive defaults (e.g. force-deleting files) without an explicit confirmation flag. Flag any environment assumption that could break portability. Keep the script's logic scoped to what was described, not extra features.
Example — {{workflow_description}}: "back up a directory to S3 nightly and rotate backups older than 30 days".