[BUG] Random colored text fragments in terminal output

Resolved 💬 24 comments Opened Jan 10, 2026 by i-dedova Closed Apr 18, 2026
💡 Likely answer: A maintainer (claude[bot], contributor) responded on this thread — see the highlighted reply below.

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?

Environment

  • OS: Windows 11
  • Claude Code version: 2.1.3
  • VS Code version: 1.108.0
  • PowerShell versions tested:
  • Windows PowerShell 5.1.26100.7462
  • PowerShell 7.5.4
  • Terminal apps tested:
  • VS Code integrated terminal
  • Windows Terminal
  • Standalone PowerShell windows

Description

When running a Claude Code session, terminal output displays random colored text fragments. Certain words or parts of words appear in blue/purple colors while the surrounding text remains white. This happens throughout Claude's responses in a seemingly random pattern.

The colored fragments appear to be regular words from Claude's responses, not error messages or special output. The coloring makes responses visually distracting and harder to read.

Additional Context

  • Issue persists across all terminal applications (not specific to VS Code)
  • Happens with both PowerShell 5.1, PowerShell 7 and Windows PowerShell, Command Line.

<img width="1482" height="754" alt="Image" src="https://github.com/user-attachments/assets/11b7a471-4ed6-4c2b-a888-015a0bc988c6" />

  • Problem occurs only when Claude Code is actively running
  • Disabling all Claude Code hooks and statusline configuration does not resolve the issue
  • The colored fragments are actual words from responses, not ANSI escape codes or error messages

What Should Happen?

All terminal text output should display in consistent, uniform color (typically white/default terminal color for normal text).

Error Messages/Logs

Steps to Reproduce

  1. Start a Claude Code session: claude
  2. Have a conversation with Claude (any topic)
  3. Observe Claude's text responses in the terminal

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.3

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

_No response_

View original on GitHub ↗

24 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/2780
  2. https://github.com/anthropics/claude-code/issues/14720
  3. https://github.com/anthropics/claude-code/issues/17050

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

jasonftl · 6 months ago

Same here in 2.1.5 Opus on Windows 11 via standard Command Prompt.

<img width="1115" height="894" alt="Image" src="https://github.com/user-attachments/assets/01e3b7a8-c6a1-461c-840c-4d8a476d6612" />

TomzBench · 5 months ago

me too.

I reported https://github.com/anthropics/claude-code/issues/20459 but I closed it because this one is older. I linked mine though so you can see details about my computer and versions.

also here is my screen shot

<img width="1887" height="1121" alt="Image" src="https://github.com/user-attachments/assets/2ef6777f-0da0-4439-853e-64ffca97f90a" />

and another:

<img width="1276" height="430" alt="Image" src="https://github.com/user-attachments/assets/4b91b74f-29aa-4f0d-a05d-25ed8d412fdf" />

sbrockway · 5 months ago

Same on v2.1.23
I am using the native installer on Windows. Not the node based installer.
I have a coworker that still uses WSL who does not see this behavior.

Alexbits · 5 months ago

This is how it looks in my Windows Terminal. Very annoying.

<img width="1412" height="869" alt="Image" src="https://github.com/user-attachments/assets/54e6edc3-331e-4bf1-a664-2b5439f17d15" />

WargameGPT · 5 months ago

Root Cause Found & One-Line Fix

Full analysis posted at https://github.com/anthropics/claude-code/issues/14720#issuecomment-3857905322

TL;DR: The bug is in the IP5 function in cli.js. When word-wrapping consumes spaces at line breaks, the style-position tracker $ falls behind by 1 per wrap. This accumulates, shifting all ANSI highlighting rightward over long paragraphs.

The fix: search cli.js for z&&_.length>0 (exactly one match, in the IP5 function). Remove the z&&:

// Before (whitespace correction only runs in trim mode):
if(z&&_.length>0){let W=/\s/.test(_[0]);if($<Y.length&&/\s/.test(Y[$])&&!W)while($<Y.length&&/\s/.test(Y[$]))$++}

// After (whitespace correction runs in all wrap modes):
if(_.length>0){let W=/\s/.test(_[0]);if($<Y.length&&/\s/.test(Y[$])&&!W)while($<Y.length&&/\s/.test(Y[$]))$++}

Tested on 2.1.33, completely eliminates the prose highlighting drift. Code blocks are unaffected (they use a different rendering path). If you ask Claude Code to fix itself using this information, it can locate and patch the function automatically.

Caleb-KS · 5 months ago

I am seeing the incorrect coloring on my Claude (started happening within the last two weeks) and so is a coworker that just installed claude fresh.

i-dedova · 5 months ago

@WargameGPT bless you for that advice! It works brilliantly! I went a bit further and wired the patching to SessionStart Hook to check for Claude updates and implement the patching to the new version automatically. Here's the summary of what we did with Claude for Windows. Hope it might be helpful for others.

Fix: ANSI Highlight Drift (Random Color Fragments in Terminal Output)

Symptoms: Random colored text fragments appear in normal Claude responses. Colors shift rightward after line breaks, getting worse with longer outputs. Not error messages — just broken ANSI highlight re-application after word-wrap.

Root cause: The bundled Bun binary has a function bh0 (in Ink's rendering pipeline) with TWO re-sync blocks gated by parameter D (default false). Both blocks are dead code, causing the style-map index to drift after word-wrap line breaks.

Fix approach: Patch X&& (3 bytes) to (3 spaces) in both gate conditions. Each pattern appears twice (Bun double-embed = 4 total patches). Auto-update overwrites the fix, so a SessionStart hook re-patches automatically.

The Two Patterns

Pattern 1 (start-of-line): if(D&&_.length>0){let F=/\s/.test(_[0])

  • Anchor: .length>0){let with 4 pre-bytes matching X&&Y
  • Skips whitespace in original text when wrapped line starts with non-space

Pattern 2 (end-of-line): if(D&&M<I.length-1){let F=I[M+1]

  • Anchor: .length-1){let with 6 pre-bytes matching X&&Y<Z
  • Peeks at next line's first char, skips whitespace until finding it

Implementation

Solved with ~/.claude/hooks/modules/binary-patcher.js (JS SessionStart hook). The patcher:

  1. Finds latest version file by semver in ~/.local/share/claude/versions/
  2. Reads binary into Buffer, searches for both pattern anchors
  3. Replaces X&& (3 bytes) with spaces in each match
  4. Writes patched buffer to version file
  5. Attempts to copy to claude.exe (rename strategy). If locked (common — current session holds it), spawns a detached background watcher that polls every 5s until the exe is released, then copies automatically
  6. Caches mtime/size in state file (exePending flag tracks incomplete exe patches, confirmNext flag triggers success message on next session)

User-facing messages

Messages flow via SessionStart additionalContext → Claude relays in first response.

| Scenario | Message |
|----------|---------|
| Fresh patch, exe copied | "Restart Claude Code for the fix to take effect." |
| Fresh patch, exe locked | "Close all sessions. Background process will update." |
| Next session after watcher | "Fix applied successfully. Colors should render correctly." |
| Exe pending retry success | "Fix applied successfully." |
| Exe pending retry failed | "Fix is queued. Background process will update." |

AdamCassidy · 5 months ago

I actually like this. It's kind of like Bionic reading.

Bird22 · 5 months ago

Same issue, although @WargameGPT fix didn't work for me as I didn't use NMP to install and I can't seem to find my cli.js file for Claude?

countzero · 5 months ago

Regarding to https://gist.github.com/frostbtn/f85b574ce132c8853945df852e1e0d31 the bug was introduced with Claude Code 2.1.14 that implies that version 2.1.12 from ~ a month ago is the last officially usable version for Windows.

Workaround

claude install 2.1.12

@bcherny, @ashwin-ant and @fvolcic please take a look at this coloring bug, it renders the app unusable on Windows and there is now a sufficient amount of tickets regarding this issue with deep analysis and sound solution suggestions.

rfmsanz-ethan · 4 months ago

This hook worked for me. I am using CC native ARM64 binary. I know the pattern is the same in the other architectures' binaries, but I don't know if there are any differences to take into account. You could start with these and ask Claude to check them and implement them according to your current installation.

OneDrive Folder with Hook

If anyone can get the attention of anthropic devs to implement a fix of the root cause (as identified by @WargameGPT - https://github.com/anthropics/claude-code/issues/17314#issuecomment-3857915285) that would be super.

slepkin · 4 months ago

If you installed CC via irm https://claude.ai/install.ps1 | iex (because the docs say installation via npm is deprecated), cli.js does not exist so we can't use the fix above. I tried to revert to 2.1.14, but the problem persisted there. In case my methodology was flawed, here's where I found the old version:

https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.1.14/win32-x64/claude.exe

(You're probably not willing to download an exe from a random https://storage.googleapis.com URL, so take a look at the contents of https://claude.ai/install.ps1 and observe that this is the URL they're using.)

I put this where I installed the old version, $HOME\.local\bin\claude.exe, ran claude, and still see the error, even though the version is clearly 2.1.14.

<img width="1586" height="602" alt="Image" src="https://github.com/user-attachments/assets/e5aafc37-d4c3-4c77-96b9-9da83460456d" />

rfmsanz-ethan · 4 months ago
If you installed CC via irm https://claude.ai/install.ps1 | iex (because the docs say installation via npm is deprecated), cli.js does not exist so we can't use the fix above.

I am not using the npm version of CC. Mine is Windows native install using irm https://claude.ai/install.ps1 | iex.

The fix that I referenced (hook) works. There is no cli.js file as an independent file; it is packaged within the claude.exe binary. The hook patches the binary file that is downloaded to {userprofile}\.local\share\claude\versions and then overwrites the claude.exe in {userprofile}\.local\bin (the actual claude code binary) when the file is no longer in use.

calilafollett-rm · 4 months ago
## Root Cause Found & One-Line Fix Full analysis posted at #14720 (comment) TL;DR: The bug is in the IP5 function in cli.js. When word-wrapping consumes spaces at line breaks, the style-position tracker $ falls behind by 1 per wrap. This accumulates, shifting all ANSI highlighting rightward over long paragraphs.

It sure would be nice to get Anthropic to take care of this. We have internal users starting to complain the output is hard to read. This seems like a silly simple fix to implement, test and release.

It's a quality-of-life issue for many, especially those with visual impairments.

VagnerVit · 4 months ago

Fixed in 2.1.47

jasonftl · 4 months ago

<img width="731" height="166" alt="Image" src="https://github.com/user-attachments/assets/23745f19-5df7-4075-9b34-fe0151e5cacf" />

Still not fixed for me on claude --version - 2.1.47 (Claude Code)

rfmsanz-ethan · 4 months ago
Fixed in 2.1.47

I hope this is true. Unfortunately, 2.1.47 breaks Bun on ARM64 Windows, so I'm stuck on 2.1.45 until that regression is fixed.

Caleb-KS · 4 months ago

seems it's fixed for me in 2.1.50

countzero · 4 months ago

Fixed for me in 2.1.50. Thank you.

jasonftl · 4 months ago

Fixed for me now too. Thank you!

yurukusa · 3 months ago

This colored text fragment issue is usually caused by ANSI escape sequence handling differences between terminals on Windows.
Workaround 1 — Set TERM environment variable:

$env:TERM = "xterm-256color"
claude

Or in your PowerShell profile ($PROFILE):

$env:TERM = "xterm-256color"

This tells Claude Code to use standard xterm color codes instead of potentially unsupported sequences.
Workaround 2 — Enable Virtual Terminal Processing:
In PowerShell:

[console]::OutputEncoding = [System.Text.Encoding]::UTF8
$env:COLORTERM = "truecolor"

Workaround 3 — Use Windows Terminal instead of VS Code terminal:
Windows Terminal generally has better ANSI support than VS Code's integrated terminal on Windows. If you're seeing this in VS Code, try running claude in Windows Terminal directly.
Workaround 4 — Force ANSI theme:

claude --theme ansi-dark  # or ansi-light

The ANSI themes use the basic 16-color palette which is more universally supported than 256-color or truecolor modes.
Workaround 5 — Disable colors entirely:

$env:NO_COLOR = "1"
claude

The NO_COLOR environment variable (from no-color.org) tells CLI tools to disable all color output. This removes the visual artifacts at the cost of a monochrome experience.

claude[bot] contributor · 2 months ago

This is a duplicate of #17892, which was fixed as of version 2.1.47.

github-actions[bot] · 2 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.