Use compact output flags for common Bash commands to reduce token consumption

Status Closed — not planned
Maintainer reply None cached
Activity 4 comments · opened Mar 9, 2026 · closed May 1, 2026

Summary

Claude Code's system prompt already instructs the model to prefer dedicated tools (Read, Grep, Glob) over Bash equivalents. But commands that must go through Bash — git, test runners, build tools — still use verbose default output, consuming significant context tokens unnecessarily.

The model could be instructed to prefer native compact output formats when generating Bash commands. This is zero-overhead, zero-dependency, and preserves all error information.

Proposed flags

| Command | Compact flag | Effect |
|---------|-------------|--------|
| git status | --porcelain | Machine-readable, no prose |
| git log | --oneline | One line per commit |
| git diff | Prepend --stat | File-level summary before full diff |
| pytest | --tb=short -q | Compact tracebacks, quiet pass output |
| cargo test | Pipe to tail -20 | Summary only unless debugging |

Why this works

These are upstream optimizations — asking the tool for less noise rather than post-processing output. Key properties:

  • No information loss on errors (compact modes preserve failure details)
  • No external dependencies or shell hooks
  • No latency overhead
  • Implementable as a system prompt change

Context

Analysis of RTK (a CLI proxy for token compression) shows that injecting upstream flags is their highest-leverage strategy — responsible for ~70% of savings. The remaining filtering/truncation techniques involve lossy compression with real tradeoffs. The flag approach avoids those tradeoffs entirely.

---
🤖 Written by Claude Code

View original on GitHub ↗

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