[BUG] Code block copy-paste injects formatting characters that break bash
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 copying code blocks from Claude Code output (web, desktop app, or mobile),
invisible or visible formatting characters (angle brackets, special quotes, etc.)
get included in the clipboard. Pasting into a terminal causes:
-bash: syntax error near unexpected token `|'
This happens consistently across:
- Claude Code web (claude.ai/code)
- Claude Code desktop app (Mac)
- Mobile browser
Steps to reproduce:
- Claude outputs a bash command like: docker compose -f file.yml up -d
- Copy the command from the output (url gets characters < and > around it)
- Paste into terminal
- Bash throws syntax error due to invisible formatting characters
Expected: Clean plaintext copy with no formatting artifacts
Actual: Formatting characters included in clipboard
This is particularly painful for users running commands on remote servers
via SSH on mobile.
What Should Happen?
When copy pasting from the code section of Claude, characters breaking the commands, should not happen in the code block.
curl http://www.dsffedsrf.com/
Not
curl <http://www.dsffedsrf.com/>
Expected: Clean plaintext copy with no formatting artifacts
Actual: Formatting characters included in clipboard
Error Messages/Logs
-bash: syntax error near unexpected token `|'
Steps to Reproduce
Steps to reproduce:
- Claude outputs a bash command like: docker compose -f file.yml up -d
- Copy the command from the output (url gets characters < and > around it)
- Paste into terminal
- Bash throws syntax error due to invisible formatting characters
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Code 2.1.96
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗