Dev
Bash Script Prompt Generator
Bash scripts written without strict error handling fail silently, leave temp files behind, and break when a variable contains a space. This tool generates a fill-in prompt you hand to an AI assistant so it writes a script that fails loudly and cleans up after itself. Describe what the script should do and toggle whether it takes command-line arguments. With arguments enabled, the prompt requires parsing and validation before any work. Without them, it asks for documented environment variables. Both modes require `#!/usr/bin/env bash`, `set -euo pipefail`, quoted expansions, a `usage()` with `--help`, logging to stderr, and a `trap` on `EXIT` for cleanup. Run the result through `shellcheck` before using it near real data.
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Describe what the script should do.
- Toggle whether it takes command-line arguments.
- Click Generate to build the prompt.
- Paste it into your AI assistant and run shellcheck on the result.
Use Cases
- •Getting a robust, shellcheck-clean script from an AI assistant
- •Avoiding unquoted-variable and error-handling bugs
- •Standardising script structure across a team
- •Scaffolding a backup, deploy, or maintenance script
- •Teaching safe bash conventions to newer engineers
Tips
- →State the exact inputs and outputs so the assistant validates them.
- →Always run the result through shellcheck before trusting it.
- →Ask for a dry-run flag on anything destructive.
- →Test on a copy before pointing the script at real data.
FAQ
why require set -euo pipefail
`-e` exits on any error, `-u` treats unset variables as errors, and `-o pipefail` propagates failures inside pipelines. Without them a failed command is silently ignored and the script continues, which is how shell scripts cause real data loss.
what does the trap on EXIT do
It runs a cleanup function whenever the script exits — whether normally, on error, or on a signal. That guarantees temporary files and locks are removed even when the script dies partway through, equivalent to a `finally` block.
how does the arguments toggle change the prompt
With arguments enabled the prompt asks for argument parsing and validation before any work. With it disabled, the prompt asks for configuration via environment variables and requires each one to be documented — the better pattern for scheduler-run scripts.
You might also like
Popular tools from other categories that share themes with this one.
Try these next
More free tools from other corners of the catalog, picked by shared themes.