There are techniques from traditional programming environments that can help. Some basic tools like using an editor with syntax highlighting will help as well. There are builtin options that Bash provides to make debugging and your everyday Linux System Administration job easier.
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-debug-bash-scripts