Code blocks add leading whitespace when copied from terminal output

Resolved 💬 1 comment Opened Apr 1, 2026 by Xalior Closed Apr 1, 2026

Description

When Claude Code outputs code blocks (fenced with triple backticks) in the terminal, copying and pasting the content into another terminal adds leading whitespace to every line. This breaks:

  • Shell heredocs (closing EOF delimiter not recognized with leading spaces)
  • Config files (keys get split across lines or indented incorrectly)
  • Any content where leading whitespace is significant

Reproduction

  1. Ask Claude Code to output a multi-line config file in a code block
  2. Copy the content from the terminal
  3. Paste into another terminal or file
  4. Observe leading spaces on every line

Impact

Users pasting config files, shell scripts, or heredocs into remote servers get corrupted output. This came up while configuring opendkim via SSH — every approach (heredocs, printf, echo) produced broken files due to invisible leading whitespace added by the rendering layer.

Expected behavior

Code block content should be copyable without any added leading whitespace.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗