Thursday, December 3, 2026 | London 10°C · Drizzle
DailyGlimpse

AI

Fixing Git Diff Color Issues When Piping to Claude Code in CI

SystemDR - Scalable System Design 1 min read

You test your pipe-to-Claude script locally, and it works perfectly. But when you push it to CI, it fails with a JSON parse error. The root cause? git diff uses --color=auto, which detects a terminal and enables colors. However, some configurations use --color=always, which forces ANSI escape codes into the pipe even on CI runners. Claude's stdout then contains raw escape sequences that break downstream tools like jq.

The fix is simple: add two characters—--no-color to your git diff command. Alternatively, include a sed ANSI strip as a safety net:

sed 's/\x1b\[[0-9;]*[mGKHF]//g'

This ensures clean, parseable output regardless of the environment.

React