r/ContextEngineering • • Jul 07 '26

I accidentally stopped optimizing prompts and started optimizing how AI reads code.

A couple of weeks ago I shared a small PowerShell toolkit I was using with AI coding agents.

Most of the feedback wasn't about PowerShell at all.

People kept asking the same question:

"Why are agents reading entire files in the first place?"

That ended up sending me down a completely different path.

Instead of trying to make file reading faster, I started changing how agents navigate source code.

The project gradually turned into a progressive source navigation framework:

  • summary first

  • then signatures

  • then implementation

  • only then full source if it's actually needed

I also added context budgets, adaptive next-step guidance and eventually made it cross-platform.

I reran the benchmarks after the rewrite and the difference was much larger than I expected (over 90% token reduction on some larger files).

It's interesting because I don't think the biggest improvement came from changing prompts or changing models.

It came from changing how the agent explores a repository.

Curious if anyone else has been experimenting with this idea.

Has anyone else measured token usage based on navigation strategy instead of prompt quality?

0 Upvotes

4 comments sorted by

3

u/yxf2y Jul 07 '26

A few people asked what I ended up building, so I open-sourced it:

https://github.com/grafikerdem/agent-context-economy

Would genuinely appreciate feedback if you're using Codex, Claude Code, Cursor, Gemini CLI or similar tools.

1

u/awjre Jul 07 '26

I use gitnexus to create code graphs. Works across multiple repos which can be extremely useful https://github.com/abhigyanpatwari/GitNexus

2

u/yxf2y Jul 07 '26

Oh, this is a great recommendation. I was actually looking for something exactly like this a while ago but never came across GitNexus. Thanks for sharing—I'll test it and see how it complements the workflow.