[BUG] Claude Code splices ANSI color codes when wrapping stdout from a program it ran

Resolved 💬 4 comments Opened Dec 9, 2025 by ide Closed Feb 6, 2026

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?

Claude Code prints the output of programs it runs. It line wraps the output without accounting for ANSI color codes. This produces output like this where part of an ANSI color code is printed:

  ⎿  abcdefghijklmno           
     ;34mpqrstuvwxyzABCD
     mEFGHIJKLMNOPQRST

<img width="317" height="103" alt="Image" src="https://github.com/user-attachments/assets/40741cee-b8e4-484e-a2e4-c23586db4585" />

What Should Happen?

Claude Code should split lines at human-visible character boundaries and treat ANSI color codes as atomic units.

Error Messages/Logs

Steps to Reproduce

Make an executable Bash script with:

#!/bin/bash

colors=(31 32 33 34 35 36) # red green yellow blue purple cyan
text="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"

output=""
for (( i=0; i<${#text}; i++ )); do
    color=${colors[$((i % 6))]}
    char="${text:$i:1}"
    output+=$'\e[0;'"${color}m${char}"
done
output+=$'\e[0m'

echo "$output"

Then ask Claude Code to run it. It should print the output and wrap lines, sometimes breaking ANSI color codes.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.62

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗