We cut Claude's token usage 79% by redesigning our CLI for agents
Blog post from Infracost
Infracost has significantly redesigned its CLI to optimize interactions with AI coding agents such as Claude, resulting in a substantial reduction in token usage and API costs while maintaining accuracy. The redesign focused on improving the efficiency of the CLI's response to AI calls by implementing predicate pushdown and adopting TOON (Token-Oriented Object Notation) for output, which minimizes redundant data processing and reduces the token count. Benchmarks showed that these changes improved performance and cost efficiency while maintaining accuracy compared to previous methods that required more complex and costly scripting. The enhancements, originally driven by the opaque nature of agent usage, also offer benefits to human users by simplifying processes, allowing for more efficient terminal use, and facilitating better integration with CI scripts. The upgrade to version 2.0 reflects these significant changes in design and functionality, emphasizing efficiency and effectiveness for both AI and human callers.