NO_COLOR and TTY detection
Why it matters
When mytool list > out.txt writes \x1b[32mOK\x1b[0m into the file, the user opens out.txt and sees escape-code garbage. When CI logs capture ANSI codes as ^[[32m, grep patterns break. When a blind user's screen reader hits color codes, output becomes unintelligible. The NO_COLOR convention (no-color.org) and TTY detection exist for exactly this reason — ignoring them corrupts piped output, log files, and accessibility tooling.
Severity rationale
Medium because raw ANSI codes in piped output or log files corrupt downstream consumers and break accessibility.
Remediation
Check process.env.NO_COLOR and process.stdout.isTTY before emitting ANSI codes, or use a library like picocolors that does this automatically. Wire the check once in src/cli/lib/color.ts:
import pc from 'picocolors'
// picocolors honors NO_COLOR and isTTY automatically
console.error(pc.green('Success'))
Test with NO_COLOR=1 mytool list and mytool list | cat.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the CLI Quality Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
Taxons
History
- 2026-04-18·v1.0.0·Initial import from cli-quality·automated