Claude Code silently strips backslashes in Bash tool; CLAUDE.md fix saves ~80% tokens

JoshuaJosephson · reddit · 2026-09-06

A Windows user diagnosed why Claude Code kept failing on file writes: the Bash tool strips one level of backslash escaping before the shell parses it — \\ arrives as \ — and neither single quotes nor <<'EOF' heredocs protect against it, since the collapse happens upstream of bash (isolated by byte-for-byte comparison with the PowerShell tool).

The failure is silent: commands succeed with plausible output, and corrupted "\n" characters surface much later as unrelated syntax or runtime errors.

The author shares a CLAUDE.md section that fixes it:

Measured on 2026-09-05, this setup saves nearly 80% of tokens on those tasks.

Original post →

More from coding & agent

coding & agent channel →