Before automating anything with Claude Code CLI, add this one line to every bash script: set -euo pipefail.
-eexits on any non-zero command.-utreats undefined variables as errors.-o pipefailcatches failures inside pipelines.
Without these three flags, your Claude Code CLI script will silently skip errors, commit broken output, and give you a false exit code 0. Every automation should start with this line — non-negotiable.
Full lesson available at systemdrd.com.