Skip to main content
Dev · 283 tools

Bash Script Prompt Generator

Generates a fill-in prompt for asking an AI to write a robust bash script

PromptExample — click Generate for yours
Write a robust bash script that will back up a postgres database to S3. Requirements: - Start with #!/usr/bin/env bash and set -euo pipefail. - Set IFS to a safe value and quote all variable expansions. - Provide a usage() function and a --help flag. - Parse arguments and validate them before doing any work. - Log progress to stderr and fail loudly with a clear message and non-zero exit code. - Clean up temp files with a trap on EXIT. Constraints: POSIX-friendly where reasonable, passes shellcheck, no unquoted globs.

Generated 90 words · 524 characters

See 3 examples
  • Example 1
    Write a robust bash script that will back up a postgres database to S3.
    
    Requirements:
    - Start with #!/usr/bin/env bash and set -euo pipefail.
    - Set IFS to a safe value and quote all variable expansions.
    - Provide a usage() function and a --help flag.
    - Parse arguments and validate them before doing any work.
    - Log progress to stderr and fail loudly with a clear message and non-zero exit code.
    - Clean up temp files with a trap on EXIT.
    
    Constraints: POSIX-friendly where reasonable, passes shellcheck, no unquoted globs.
  • Example 2
    Write a robust bash script that will back up a postgres database to S3.
    
    Requirements:
    - Start with #!/usr/bin/env bash and set -euo pipefail.
    - Set IFS to a safe value and quote all variable expansions.
    - Provide a usage() function and a --help flag.
    - Parse arguments and validate them before doing any work.
    - Log progress to stderr and fail loudly with a clear message and non-zero exit code.
    - Clean up temp files with a trap on EXIT.
    
    Constraints: POSIX-friendly where reasonable, passes shellcheck, no unquoted globs.
  • Example 3
    Write a robust bash script that will back up a postgres database to S3.
    
    Requirements:
    - Start with #!/usr/bin/env bash and set -euo pipefail.
    - Set IFS to a safe value and quote all variable expansions.
    - Provide a usage() function and a --help flag.
    - Parse arguments and validate them before doing any work.
    - Log progress to stderr and fail loudly with a clear message and non-zero exit code.
    - Clean up temp files with a trap on EXIT.
    
    Constraints: POSIX-friendly where reasonable, passes shellcheck, no unquoted globs.

About this 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

  1. Describe what the script should do.
  2. Toggle whether it takes command-line arguments.
  3. Click Generate to build the prompt.
  4. 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.