[BUG] Background color bleed in terminal from chalk usage

Open 💬 38 comments Opened May 26, 2025 by tajquitgenius

claude code wrote this issue report lol

Claude Code Issue Report: Background Color Bleed in Terminal

Issue Summary

Claude Code's startup tips use chalk background colors that bleed into subsequent terminal output, causing persistent red/white backgrounds that interfere with the UI.

Environment

  • OS: macOS (Darwin 24.5.0)
  • Terminal: Terminal.app
  • Claude Code: Latest version (accessed via claude command)

Problem Description

When Claude Code starts, it displays helpful tips using chalk with background colors:

console.log(chalk.bgRed.white.bold(`> Try "refactor <filepath>"`));

The background color escape sequences (\x1b[4Xm) are not properly terminated with reset sequences (\x1b[0m), causing the background color to "bleed" into subsequent terminal output.

Visual Impact

Users see:

  • Red or white backgrounds persisting after the tip messages
  • Text becoming difficult to read due to color conflicts
  • Terminal UI appearing "broken" or glitched

Reproduction Steps

  1. Launch Claude Code from terminal: claude
  2. Observe the startup tips with colored backgrounds
  3. Notice background colors persist in the interface
  4. Background bleed affects readability of subsequent output

Root Cause Analysis

The issue occurs because:

  1. Background color codes (\x1b[4Xm) are applied
  2. No reset sequence (\x1b[0m) follows immediately
  3. Terminal continues to apply background color to subsequent text
  4. Bleed persists until manually cleared or reset

Proposed Solutions

Option 1: Use Foreground Colors Only (Recommended)

Replace background colors with bright foreground variants:

// Instead of:
chalk.bgRed.white.bold(`> Try "refactor <filepath>"`)

// Use:
chalk.redBright.bold(`> Try "refactor <filepath>"`)
// or
chalk.red.bold(`> Try "refactor <filepath>"`)

Option 2: Add Proper Reset Sequences

Ensure every background color usage ends with a reset:

chalk.bgRed.white.bold(`> Try "refactor <filepath>"`) + chalk.reset()

Option 3: Environment Awareness

Respect the NO_COLOR environment variable:

const useColors = !process.env.NO_COLOR;
const tip = useColors 
  ? chalk.redBright.bold(`> Try "refactor <filepath>"`)
  : `> Try "refactor <filepath>"`;
console.log(tip);

Current Workarounds

Users currently work around this by:

  • Setting NO_COLOR=1 environment variable
  • Manually clearing terminal with Ctrl+L or clear
  • Resetting terminal formatting before launching Claude

Expected Behavior

Tips should display with colors that:

  • Don't bleed into subsequent output
  • Are properly contained to their intended text
  • Reset cleanly when complete

Files Likely Affected

Based on typical project structure, likely locations:

  • src/ui/banner.ts - Startup tips and banners
  • src/cli/ - CLI output formatting
  • Any file using chalk.bg* methods

Search Patterns

To find affected code:

# Search for background color usage
grep -r "bgRed\|bgWhite\|bgBlue\|bgGreen" src/
grep -r "\.bg[A-Z]" src/

# Look for chalk usage without reset
grep -r "chalk\.bg" src/ | grep -v "reset"

Impact

  • Severity: Medium (cosmetic but affects usability)
  • Users Affected: ?
  • Frequency: Every startup

Additional Context

This issue was discovered while building an orchestration tool that spawns multiple interactive Claude Code instances. The background color bleed makes it difficult to read or interact.

<img width="574" alt="Image" src="https://github.com/user-attachments/assets/305fef41-e346-44ad-86a1-e852869810a1" />

View original on GitHub ↗

38 Comments

reverie · 1 year ago

Thanks for the report! Are you able to reproduce this issue?

tajquitgenius · 1 year ago

Yeah, it happens every time.

macOS (lines 290-302): Uses AppleScript to launch Terminal.app
  applescript = f"""
  tell application "Terminal"
      activate
      do script "{script_path.absolute()} {self.workspace_path.absolute()}"
      set custom title of front window to "{self.terminal_title}"
  end tell
  """
  subprocess.run(["osascript", "-e", applescript], check=True, capture_output=True, text=True)

After the terminal is launched, we automatically copy some instructions to clipboard and then run claude

     # Try to copy instructions to clipboard automatically
     echo ""
     echo "Preparing agent instructions..."

     # Check if pbcopy is available (macOS)
     if command -v pbcopy &> /dev/null && [ -f "PASTE_ME_INTO_CLAUDE.txt" ]; then
         cat PASTE_ME_INTO_CLAUDE.txt | pbcopy
         echo ""
         echo "[OK] Instructions copied to clipboard!"
         echo "[!] Just paste (Cmd+V) when Claude Code starts"
         echo ""
         echo "Starting Claude Code in 3 seconds..."
         sleep 3
     else
         # Show manual copy instructions
         echo ""
         echo "================================================================"
         echo "    📋 COPY THIS INTO CLAUDE CODE:                           "
         echo "================================================================"
         echo ""
         cat PASTE_ME_INTO_CLAUDE.txt | head -20
         echo ""
         echo "... [Full content in PASTE_ME_INTO_CLAUDE.txt]"
         echo ""
         echo "👆 Open PASTE_ME_INTO_CLAUDE.txt for full instructions"
         echo "📋 Copy the contents and paste into Claude Code"
         echo ""
         echo "Press Enter when ready to start Claude Code..."
         read -n 1
     fi

     # Start Claude Code
     echo ""
     echo "Starting Claude Code..."
     claude
JanTvrdik · 1 year ago

I have the same issue with multiple CLI tools that use colored background. My guess it that Claude Code just needs to always reset the terminal colors after showing any terminal output.

teehemkay · 1 year ago

Seeing a similar issue every time I run claude code.

<img width="1725" alt="Image" src="https://github.com/user-attachments/assets/c0e8b878-c433-4a21-9e4d-ffe16e8efb91" />
<img width="1723" alt="Image" src="https://github.com/user-attachments/assets/ad6a9623-055d-4548-9829-d69728818c34" />
<img width="1720" alt="Image" src="https://github.com/user-attachments/assets/c9a1b98e-a467-4326-97fe-4cd4e25cbd9e" />

17Amir17 · 1 year ago

Seeing this too - combination of red and white sometimes randomly disappears

acarkaan · 1 year ago

same

mitalauskas · 12 months ago

same

vincentfarefood · 12 months ago

same

justinpincar · 11 months ago

Issue appears consistently inside a GNU Screen (https://www.gnu.org/software/screen/) session.

bennypowers · 11 months ago

same with pterm (go)

<img width="1970" height="2154" alt="Image" src="https://github.com/user-attachments/assets/1ebcf7dd-8a29-4cae-8ffb-45a3e924f75b" />

mathiaswillburger · 11 months ago

<img width="1204" height="292" alt="Image" src="https://github.com/user-attachments/assets/2fef9dde-95e5-4cb7-857d-93ccd82d928e" />

Same issue happens in Claude Code terminal on Windows:

Description: When Claude executes code blocks (e.g., running Laravel tests with php artisan test), the terminal output changes color but the background color remains stuck in that color even after the command completes.

Example:

Claude runs: php artisan test --filter "some test"
Terminal output shows in green background when tests complete successfully
After test completion, terminal background remains green instead of returning to default

Expected Behavior: Terminal background should reset to default color after command execution completes.
Current Behavior: Background color persists, making subsequent terminal output difficult to read.

heeen · 11 months ago

I can also reproduce in gnu screen

taedryn · 11 months ago

Also a problem for me. Makes claude nearly unusable.

jcherniak · 11 months ago

As a workaround, ask claude to run "tput sgr0" and it will reset it. Obviously the app should do this or something similar directly, but for anyone experiencing this, that will fix it.

JanTvrdik · 11 months ago

I use an ugly workaround for now. I created a PostToolUse:Bash hook that runs the following script

#!/usr/bin/env bash

tput sgr0 >&2
echo "COLORS HAVE BEEN FIXED" >&2
exit 1 # ensures that stderr is shown to user only
maho-jared · 10 months ago

+1. Makes it nearly unusable in my macOS terminal app :/

alexanderfilipzik · 10 months ago

Same here

erashdan · 10 months ago

+1

jakubmikita · 10 months ago

Same running testing tools from Composer or NPM (like phpstan or unit tests):

<img width="1515" height="535" alt="Image" src="https://github.com/user-attachments/assets/a2c894aa-4087-4a8f-b454-899e16454b1c" />

<img width="1442" height="632" alt="Image" src="https://github.com/user-attachments/assets/30cfb911-286b-4b90-ab36-8f326b71c2cb" />

waldoalvarez00 · 10 months ago

Yes, getting it on my side as well. This bug should be very easy to fix. And is affecting readability a lot.

daugaard47 · 9 months ago

Same issue when running tests.

otavio-araujo · 9 months ago

Same here running tests.

Did someone get the solution?

geoff-plitt-thoughtful · 9 months ago

<img width="390" height="108" alt="Image" src="https://github.com/user-attachments/assets/d523c17c-c1c8-4072-957b-bfda848779e0" />
I think I'm seeing this too.

gharibian · 9 months ago

This is consistently reproducible with gnu-screen on macos. I've tried everything to match up terminal emulation and background color erase between the two---to no avail. /opt/homebrew/bin/claude is minified, which would be time consuming to debug and patch.

The only work around I've found is to not use claude in a screen session or to disable colors when using screen with:

FORCE_COLOR=0 claude
mathiaswillburger · 9 months ago

At least Claude >2.0 seems to reset the color once a new prompt is submitted.

daugaard47 · 9 months ago
At least Claude >2.0 seems to reset the color once a new prompt is submitted.

90% better than what it was. I think they definitely took this into account for version 2.

waldoalvarez00 · 9 months ago
At least Claude >2.0 seems to reset the color once a new prompt is submitted.

I noticed. It is a whole lot better than "forever bleeding until a patch is done" that did a "reset" of the background. The bleeding remained even after closing CC. I was doing a reset manually with color 07 command. And sometimes copy pasting the code from console to text editor to read, since the white/gray over green background was killing my eyes. Fortunately, I completed that project already.

github-actions[bot] · 7 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

fake-name · 6 months ago

This is absolutely still occurring, and it's EXTREMELY annoying. From what I can tell, no one at Anthropic has ever tested this?

For me, its on linux.

fake-name · 6 months ago

<img width="767" height="700" alt="Image" src="https://github.com/user-attachments/assets/1adc93fc-171f-4183-bfbd-154dfb321922" />

This is basically unusable. I have to continuously resize the terminal to actually be able to read what the damn thing is saying.

heeen · 6 months ago

fwiw it is not happening on tmux for me

fake-name · 6 months ago

Hmmmm, interesting. I'm running this in screen. If I do not use screen, I don't get the color garbage.

puellavulnerata · 6 months ago

This is still occurring with screen

moshemalawach · 5 months ago

yep... wanted to use screen to continue the work while I move home and got the issue!

TomzBench · 5 months ago

I have this issue:

https://github.com/anthropics/claude-code/issues/20459

seems similar but a little different.

<img width="1887" height="1121" alt="Image" src="https://github.com/user-attachments/assets/9d6426fd-5f59-4ade-a874-869a10decb12" />

Claud-Yx · 5 months ago

This issue has been preventing me from upgrading to newer versions. I would love to use the latest version with colors enabled, but unfortunately, due to this color bleeding bug, I've had to remain on version 2.1.2.

I understand the team has many priorities, but it would be greatly appreciated if this could be addressed when possible — especially since the fix appears to be relatively straightforward (adding proper reset sequences). Thank you for your work on Claude Code.

salcc · 4 months ago

still happening with screen on linux

silocyber01 · 2 months ago

Any updates or workarounds on this?