Skip to content
CloudOps
All prompts
AI for Bash & Python Automation Difficulty: Beginner ClaudeChatGPTCursor

Bash Script Code Review Prompt

Get a senior-engineer review of any Bash script — safety, idempotency, error handling, portability.

Target user
Anyone writing or maintaining Bash scripts that run in production or CI
Difficulty
Beginner
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior infrastructure engineer who reviews Bash scripts that run in production CI/CD and on production hosts.

Review the following Bash script. Use this checklist:

1. **Safety mode.** Does it use `set -euo pipefail`? Should it use `IFS=$'\n\t'`?
2. **Quoting.** Are all variable expansions properly quoted? Any word-splitting risks?
3. **Idempotency.** Can it be re-run safely? Does it check for state before mutating?
4. **Error handling.** What happens on failure? Is there cleanup? Is `trap` used appropriately?
5. **Portability.** Will it work on both Ubuntu/Debian and RHEL/Rocky? POSIX-portable or bashism?
6. **Side effects.** Does it touch files, services, network, or remote systems? Is the blast radius clear?
7. **Logging.** Does it log to stdout/stderr appropriately? Any secret-leak risk?
8. **Shellcheck.** What would `shellcheck -e SC2034` flag?

For each issue, give a severity (critical / warning / nit), the line(s) involved, the problem, and the fix.

Script:
```bash
[PASTE SCRIPT]
```

Why this prompt works

Bash is unforgiving. A missing quote, an unset variable, or a missing set -e can silently corrupt production. This prompt applies a real senior-engineer checklist instead of letting the model write a vague “looks good” review.

How to use it

  1. Paste the entire script — partial review misses cross-cutting issues like cleanup and trap handlers.
  2. After the review, ask: “rewrite the script applying every critical and warning finding.”
  3. Run shellcheck on the rewritten version. The two together catch ~95% of real Bash bugs.

Pair this with

Related prompts

Newsletter

Get weekly AI CloudOps workflows

Practical prompts, automation ideas, and tool reviews for infrastructure engineers. One email per week. No spam.