[BUG] Multi-line paste corrupts `$'` sequences in Claude Code CLI input
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 pasting a multi-line block into Claude Code CLI, lines containing $' get transformed/corrupted.
The same text may behave differently when pasted line-by-line vs as one block.
This breaks valid code/text, including Python/Matplotlib LaTeX strings like:
plt.xlabel(r'$\log_{10}(\mu/\text{GeV})$', fontsize=14)
plt.ylabel(r'$\alpha_i^{-1}$', fontsize=14)
where these line would show in the CLI as:
plt.xlabel(r'$\log_{10}(\mu/\text{GeV}), fontsize=14)
plt.ylabel(r'$\alpha_i^{-1}, fontsize=14)
This leads the model to incorrectly decide that the code has a bug (missing $' in these two lines).
This is a general pattern, as pasting something like:
X$'Y
X$$'
would show in the CLI as:
XY
X$'
What Should Happen?
pasting multiple-lines containing $', should perserve $' (which currently doesn't happen as mentioned above).
Example:
plt.xlabel(r'$\log_{10}(\mu/\text{GeV})$', fontsize=14)
plt.ylabel(r'$\alpha_i^{-1}$', fontsize=14)
X$'Y
X$$'
Error Messages/Logs
Steps to Reproduce
Paste this entire block at once into Claude Code CLI:
plt.xlabel(r'$\log_{10}(\mu/\text{GeV})$', fontsize=14)
plt.ylabel(r'$\alpha_i^{-1}$', fontsize=14)
X$'Y
X$
abc
X$$'
Observed output:
plt.xlabel(r'$\log_{10}(\mu/\text{GeV}), fontsize=14)
plt.ylabel(r'$\alpha_i^{-1}, fontsize=14)
XY
X$
abc
X$'
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v2.1.62
Platform
Other
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
- Pasting some of these lines individually can behave differently (for example
X$'Ymay stay intact alone). - Corruption is consistent when they are pasted as a multi-line block.
- This corrupts code snippets on paste, leading the model to report"fake" bugs.
This looks like JavaScript replacement-string semantics being applied to pasted text in a block path:
$'interpreted specially (post-match substitution) and removed/mutated$$collapsing to$
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗