This advice is largely automated by https://github.com/koalaman/shellcheck

As well, having a bash language server enabled (https://github.com/bash-lsp/bash-language-server) helps immensely.