Quote the heredoc delimiter unless you want expansion
A heredoc written <<EOF expands $variables and backticks inside it. <<'EOF' passes the text through untouched, which is what you want for a script, a config, or anything with a dollar sign in it.
cat > deploy.sh <<'EOF'
echo "$HOME is not expanded here"
EOFMost heredoc bugs come down to the quotes around that one word.
shell