Stop Wasting 89% of Your AI Agent's Tokens on CLI Noise
AI coding agents - Claude Code, Cursor, GitHub Copilot, Windsurf - run your CLI tools and feed the output back into the LLM context window. The problem: most CLI tools were built for humans staring at terminals, not for machines parsing results.
Progress bars, color codes, box-drawing borders, ASCII art banners - all meaningless noise for an LLM. And you're paying for every token of it.
The numbers #
Over ~2,900 CLI commands measured by rtk-ai, 11.6M input tokens were consumed, of which 10.3M (89.2%) were noise. A typical 2-hour AI coding session generates ~210K tokens of raw CLI output - enough to overflow a 200K context window with mostly garbage.
A team of 10 developers wastes approximately $1,750/month on noise tokens alone.
A PHPUnit example #
Here's the default PHPUnit output for a test suite with 500 tests, 1 failure:
PHPUnit 12.5.14 by Sebastian Bergmann and contributors.
Runtime: PHP 8.4.19
Configuration: /var/www/html/phpunit.xml
............................................................... 63 / 500 ( 12%)
............................................................... 126 / 500 ( 25%)
............................................................... 189 / 500 ( 37%)
..................................F............................ 252 / 500 ( 50%)
............................................................... 315 / 500 ( 63%)
............................................................... 378 / 500 ( 75%)
............................................................... 441 / 500 ( 87%)
........................................................... 500 / 500 (100%)
Time: 00:12.345, Memory: 256.00 MB
There was 1 failure:
1) Tests\Unit\AppHelperTest::get_morph_class_accepts_model_instance
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'App\Models\Role'
+'App\Models\Role---error'
/var/www/html/tests/Unit/AppHelperTest.php:20
FAILURES!
Tests: 500, Assertions: 1200, Failures: 1.
~250 tokens. The progress lines, banner, timing, and memory stats account for most of it. The actual failure information is only ~85 tokens.
Now the same result with --no-progress:
PHPUnit 12.5.14 by Sebastian Bergmann and contributors.
Runtime: PHP 8.4.19
Configuration: /var/www/html/phpunit.xml
Time: 00:12.345, Memory: 256.00 MB
There was 1 failure:
1) Tests\Unit\AppHelperTest::get_morph_class_accepts_model_instance
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'App\Models\Role'
+'App\Models\Role---error'
/var/www/html/tests/Unit/AppHelperTest.php:20
FAILURES!
Tests: 500, Assertions: 1200, Failures: 1.
~140 tokens. Same failure details. The banner and footer are still there (PHPUnit doesn't let you suppress them), but the 500 progress dots are gone. ~45% reduction - and on a 5,000-test suite, the savings are even larger.
What wastes the most tokens #
| Token waster | Impact |
|---|---|
Progress bars (████, dots) |
500-2000 tokens per run |
Box-drawing borders (+---+) |
2-5x more tokens than plain text |
| ASCII art banners | 50-200 tokens per logo |
| Repeated dots (PHPUnit) | ~1 token per dot, hundreds per suite |
Note: ANSI color codes (\x1b[31m) are often cited as a waste, but most CLI tools auto-detect TTY and disable colors when output is piped - which is always the case with AI agents. Flags like --colors=never, --no-ansi, and --monochrome are usually redundant. The flags below focus on what actually matters.
The fix: one flag per tool #
Every PHP quality tool has flags to disable the noise. Here's the cheat sheet:
# PHPUnit / ParaTest
--no-progress
# PHPStan - use raw format (file:line:message, one per line)
--no-progress --error-format=raw
# Psalm - use text format (file:line:col:severity, one per line)
# Psalm 7: use --output-format=compact (one-line, relative paths, no URLs)
--no-progress --no-suggestions --output-format=text
# phpcs - use emacs format (file:line:col:severity, one per line)
--report=emacs -q
# PHP-CS-Fixer
--show-progress=none -q -n
# Rector
--no-progress-bar --output-format=github
# Pint - use agent format (auto-detected in Claude Code/OpenCode)
./vendor/bin/pint --test --format agent
# Composer
composer install -q
PHPStan 2.x note: When CLAUDECODE=1 is set (always true in Claude Code), PHPStan injects a ~940-byte preamble with AI instructions and adds [identifier=X] suffixes to every error. This agent detection overhead can be larger than the format difference itself. If it bothers you, set CLAUDECODE=0 before running PHPStan.
Where to put these flags #
Don't memorize them. Put them in your CLAUDE.md or AGENTS.md file - this is read by Claude Code, Cursor, Gemini CLI, OpenCode, and others:
## Running Tools
Always use these flags when running CLI tools:
- Tests: `vendor/bin/phpunit --no-progress`
- PHPStan: `vendor/bin/phpstan analyse --no-progress --error-format=raw`
- Psalm: `vendor/bin/psalm --no-progress --no-suggestions --output-format=text`
- phpcs: `vendor/bin/phpcs --report=emacs -q`
- PHP-CS-Fixer: `vendor/bin/php-cs-fixer fix --show-progress=none -q -n`
- Rector: `vendor/bin/rector process --no-progress-bar --output-format=github`
The pattern #
Across all tools, the pattern is the same:
- Disable progress bars - the #1 token waster
- Use one-line-per-error format -
raw,text,emacs,githuborcompact - Don't switch to JSON - it has ~50% overhead from key repetition. Plain text is more token-efficient for error lists
- Skip color flags - most tools auto-detect TTY and disable colors when piped
Do this once, save thousands of tokens per session, and stop feeding your AI agent junk.
Token counts in this article are measured with the cl100k_base tokenizer (GPT-4). Claude, Gemini, and other models use different tokenizers, so exact counts will vary — but the ratios and savings hold across models.
What's else? #
This article covers PHP, but the same problem exists in every ecosystem. I've collected quiet-mode flags for Node, Python, Go, Rust, Ruby, Java, Kotlin, Swift, and .NET in one place: awesome-ai-friendly-cli — a curated list of CLI flags that cut token waste across languages and tools.
If you want to go further, check out rtk - a CLI proxy that sits between your AI agent and your tools, automatically filtering noise tokens in real time.
No flags to remember, no CLAUDE.md to maintain.
It measured the 89% waste number at the top of this article.
Content Changelog · Updated:
- : Add "What's else?" section with links to awesome-ai-friendly-cli and rtk
- Previous: First hour of a new Laravel project