Claude repeatedly fails heredoc/string escaping when writing files to remote servers, causing multi-attempt delays

Resolved 💬 2 comments Opened Apr 15, 2026 by GoR-XarraY Closed May 24, 2026

Severity: MEDIUM — Repeated failures, session time waste

What happened

When writing a multi-line HTML file to a remote server via SSH, Claude used bash heredoc syntax (<< 'HEREDOC') inside a Python string that itself contained single quotes. This caused unexpected EOF errors on every attempt. Claude tried multiple approaches over several attempts without diagnosing the root cause, burning session time on each failure.

The correct fix was simple: write the file locally with the Write tool first, then SCP it to the server. Claude eventually reached this solution but only after multiple failed attempts.

Attempts made (all failed):

  1. SSH + bash heredoc — failed (single quotes in content)
  2. SSH + Python heredoc via << 'PYEOF' — failed (single quotes in Python string)
  3. Second Python heredoc attempt — failed same way
  4. Finally: Write locally + SCP — succeeded

Impact

  • 3-4 wasted attempts and significant session time on a trivially-solvable problem
  • User watching failures pile up while under time pressure
  • Credits consumed on each failed Bash tool call

Expected behavior

When writing a file with complex content (HTML, JS, CSS) to a remote server:

  1. First choice: Write locally with Write tool, then SCP
  2. If inline is needed: use Python with a file object, not bash heredoc

Claude should recognize heredoc quoting conflicts before attempting them.

Requested resolution

  • Refund of session credits from the failed attempts
  • Fix: Claude should default to Write-then-SCP for complex file content rather than attempting bash heredoc which is fragile with mixed quotes

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗