Minimizing API usage when running Archify with CLI agents #323
milos-plavsic
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Minimizing API usage when running Archify with CLI agents
If you feed your entire repository into a high-end model just to generate an Archify diagram, you are paying for more than you need. The efficient approach is to split the work across multiple models, assigning each stage the minimal reasoning depth required.
Below are single commands for Claude Code and Codex CLI that preserve the cost savings by using cheap models for the grunt work and the high-end model only for the final synthesis step.
Reasoning depth scale used in this guide
The pipeline (same structure for both agents)
The pipeline runs four stages:
Stages 1-3 are chained into a single command. Stage 4 runs automatically at the end.
One command for Claude Code
This uses Haiku 4.5 for discovery and dependency extraction, then Sonnet 4.6 (default) for the final synthesis. Sonnet delivers Opus-level quality for 60% less cost.
One command for Codex CLI
This uses gpt-5.4-mini for discovery and dependency extraction, then gpt-5.6-terra for the final synthesis. Terra is the latest workhorse optimized for codebase reasoning.
If summary files exceed the shell argument limit
Use heredoc for the synthesis step. Replace the third segment in the chain with:
For Claude Code:
Stage summary
Why this reduces usage
The Low and Medium models handle roughly 80-90% of the raw token volume (reading all source files). The High model only sees the compressed summaries – about 15,000 tokens instead of 500,000 tokens of raw code. You run the High model once, not multiple times due to retries. Models above High (Max, Ultra, Opus, Fable) add nothing for this task and are explicitly omitted.
For Claude Code, Sonnet 4.6 with default high effort is the proven sweet spot. For Codex CLI, gpt-5.6-terra provides the same level of reasoning at the right price. This gives the same diagram quality at a fraction of the cost.
All reactions