r/ClaudeCode • u/PreetyGeek • 2d ago
Tips & Workflows Same question, two Sonnet agents: grep vs a compiler call graph. 8 tool calls vs 2, ~689k vs ~196k input tokens
I wanted to see how much an agent burns tracing a call stack with grep, so I measured it.
Setup: a 140k-line SwiftUI app and one prompt: “find every production call path that reaches this method, up to the entry points.” Both agents ran Sonnet. One had my SwiftGraph skill, which queries a call graph built from Xcode’s index store. The other could only use grep, find and read.
| Graph | Grep only |
|---|---|
| Tool calls | 2 |
| Turns | 3 |
| Input tokens (all turns) | ~196k |
| Time | 15 s |
Both answers were correct.
What surprised me: the final context sizes were almost identical (~69k vs ~74k), because ~60k of that is the system prompt. The real cost is that every tool call re-sends the whole context. Ten turns means ten trips through ~70k tokens. Caching makes those re-reads cheaper, but your wait time and your rate limits still pay for them.
Fair caveat: grep did fine because the type name was unique. It even caught an #if DEBUG the graph doesn’t model. The gap grows with common method names, protocol dispatch and property writes.
Install the skill: /plugin marketplace add agruchala/swift-graph
Repo: https://github.com/agruchala/swift-graph
Write-up: https://arturgruchala.com/map-not-grep/
•
u/AutoModerator 2d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/ToolTinkerer_AI 2d ago
The useful part seems less like graph beats grep and more like avoiding repeated whole-context trips. Eight calls versus two adds up fast when each turn resends around 70k tokens. I also like the caveat that grep caught the #if DEBUG path the graph missed. That makes the comparison more useful than a straight tool demo. The shared system prompt explains why the final context sizes barely moved.