Support ANSI color codes in hook stderr/stdout output
Feature Request
PostToolUse hook output (stderr with exit 2) is displayed in the Claude Code UI, but ANSI escape codes are rendered as raw text (e.g. [31m[FAIL][0m) instead of being interpreted as colors.
Use Case
I have a security scan hook that runs after git clone/curl/wget commands. The scan results include status labels like [PASS], [WARN], [FAIL] that would benefit from color coding (green/yellow/red) for quick visual scanning.
Current Behavior
ANSI codes in hook stderr output appear as raw escape sequences in the tool output area:
[31m[FAIL][0m Secrets: 3 secret(s) detected
[32m[PASS][0m Vulnerabilities: No known CVEs found
Expected Behavior
ANSI color codes should be interpreted and rendered, so [FAIL] appears red, [PASS] appears green, etc. — similar to how terminal output from the Bash tool itself is rendered.
Workaround
Currently using plain text labels without colors.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗