[BUG] Background color bleed in terminal from chalk usage
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
claudecommand)
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
- Launch Claude Code from terminal:
claude - Observe the startup tips with colored backgrounds
- Notice background colors persist in the interface
- Background bleed affects readability of subsequent output
Root Cause Analysis
The issue occurs because:
- Background color codes (
\x1b[4Xm) are applied - No reset sequence (
\x1b[0m) follows immediately - Terminal continues to apply background color to subsequent text
- 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=1environment variable - Manually clearing terminal with
Ctrl+Lorclear - 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 bannerssrc/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.
Thanks for the report! Are you able to reproduce this issue?
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
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.
Seeing a similar issue every time I run claude code.
Seeing this too - combination of red and white sometimes randomly disappears
same
same
same
Issue appears consistently inside a GNU Screen (https://www.gnu.org/software/screen/) session.
same with pterm (go)
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.
I can also reproduce in gnu screen
Also a problem for me. Makes claude nearly unusable.
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.
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
+1. Makes it nearly unusable in my macOS terminal app :/
Same here
+1
Same running testing tools from Composer or NPM (like phpstan or unit tests):
Yes, getting it on my side as well. This bug should be very easy to fix. And is affecting readability a lot.
Same issue when running tests.
Same here running tests.
Did someone get the solution?
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
At least Claude >2.0 seems to reset the color once a new prompt is submitted.
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.
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.
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.