[BUG] Copied multi-line commands from Claude Code output contain formatting artifacts — still unfixed after 6+ months
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When Claude Code outputs a multi-line command for the user to copy and run in their terminal, the copied text contains formatting artifacts — extra spaces, line breaks in wrong places, or line-number prefixes — that cause the command to fail when pasted.
Example: Claude outputs a command like:
python3 km.py add posthog-project-key --service posthog --tier 3 --owner david --secret "phc_abc123" --notes "PostHog project API key (public, client-side). Use as NEXT_PUBLIC_POSTHOG_KEY. Cloud US instance."
When the user copies this from the Claude Code terminal and pastes it into their shell, the text gets split across lines with formatting artifacts inserted, causing zsh: command not found errors on the fragments.
This is a real workflow problem. Claude Code frequently needs to give users commands to run (especially when the command requires interactive input like a password prompt that Claude can't handle itself). The user's only option is to copy from Claude's output, but the copy is corrupted.
What Should Happen?
Text copied from Claude Code's output should be identical to the source text — no added spaces, no line-number prefixes, no formatting artifacts. Multi-line code blocks and commands should be copy-safe.
Issue History — This Has Been Reported Repeatedly and Mishandled
This bug has been reported at least 6 times over the past 6+ months. Every report gets auto-closed by bots as a "duplicate" — but the duplicates point to each other in a circle, and none of them were ever actually fixed:
- #5097 — Original report (closed as duplicate)
- #4686 — Closed as duplicate
- #10969 — Reopened as v2 of the bug, tagged
has repro, had active discussion. Auto-closed by inactivity bot despite human comments asking for a dev response. Now locked. - #18798 — Closed as duplicate of #10969 (which was already closed)
- #23014 — Closed as duplicate
- #33223 — Closed as duplicate of #18798 (which was closed as duplicate of #10969)
The auto-close bot (#16497) and the circular-duplicate problem (#19267) have themselves been reported as issues.
The result: A bug that affects every user who copies multi-line output from Claude Code has been in the product for 6+ months with zero developer engagement, bounced between closed issues by automation, and is now locked so the original reporters can't even comment.
Steps to Reproduce
- Ask Claude Code to output a long single-line command (e.g., a
curlorpython3command with many flags) - The terminal wraps it visually across multiple lines
- Select and copy the command from the terminal output
- Paste into a separate terminal window
- Observe: the pasted text contains extra whitespace, line breaks, or other artifacts that were not in the original command
Claude Model
Opus (Claude Opus 4.6)
Is this a regression?
No, this never worked
Claude Code Version
v2.1.81
Platform
Anthropic API (Max subscription)
Operating System
macOS Darwin 25.4.0
Terminal/Shell
zsh (macOS Terminal)
Additional Information
Previous issue chain: #5097 → #4686 → #10969 → #18798 → #23014 → #33223. All closed, most locked. No fix delivered.
Related meta-issues about the auto-close/circular-duplicate problem: #16497, #19267.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗