
My AI workflow with Codex+AGY can save a lot of tokens without loosing quality
One thing that kept annoying me with AI coding tools was how often they had to rediscover the same project context.
Every new session felt like
- read the architecture again
- Find the same APIs again
- trace the same code paths again
- explain the same decisions again
- burn a bunch of tokens before doing any actual work
So I started building a small local system around routing, indexing, caching, memory, and custom skills.
The main idea is simple:
Give the AI only the context it actually needs for the task.
Obsidian is basically my project brain.
I keep long-term project knowledge there:
- architecture decisions
- API docs
- frontend/backend maps
- events and flows
- tech debt
- session notes
- lessons worth remembering
But I don't want the AI reading the whole vault.
The rule is to open the most relevant note first, then expand only if needed.
I run brief.ps1 at the start of a session.
Something like
powershell -NoProfile -File ai-workspace/scripts/brief.ps1 `
-Role reviewer `
-Query "API contract validation"
It does most of the boring context gathering for me.
It checks things like
- current handoff
- frontend/backend Git heads
- dirty files
- what kind of task I'm asking for
- relevant domain manifests
- research notes
- cached fixes
- matching memory entries
- the top 2 relevant skills
Then it suggests what the AI should look at next.
This alone cuts down a lot of pointless repo exploration.
I use small custom skills instead of one giant prompt.
I have skills for repeatable tasks like
code-traversaldiff-scoperoot-cause-analysisapi-docs-verifyapi-contract-validatorsecurity-audittest-generator
The important part is that I don't load every skill.
The catalog has a rough idea of how expensive each skill is, and the workflow normally picks a maximum of two.
So if I'm reviewing a small API change, the AI doesn't need instructions for security audits, test generation, architecture analysis, and everything else at the same time.
I also added persistent project memory.
Before doing something, I can search previous knowledge:
powershell -NoProfile -File ai-workspace/scripts/brain-recall.ps1 `
-Lookup "payment callback validation"
Instead of opening a giant memory file, it checks a small index first and loads only matching entries.
After a useful session, I save things like
- what the problem was
- What fixed it
- why the fix worked
- what failed
- which files changed
- anything worth remembering next time
The idea is that if I solve the same type of issue three months later, the AI shouldn't have to rediscover everything from scratch.
I use indexes and caches for the mechanical stuff.
I also have scripts for things that don't really need an LLM:
generate-index.ps1
generate-diff-brief.ps1
compile-hot-cache.ps1
compile-incident-cache.ps1
check-staleness.ps1
They generate things like symbol indexes, endpoint indexes, Git diff summaries, known fixes, incident history, and stale-doc checks.
My thinking is
If a script can cheaply figure something out once, don't pay the model to figure it out repeatedly.
I split agents by responsibility too.
Instead of one agent doing everything, the flow is roughly:
Organizer
↓
Planner
↓
Builder
↓
Reviewer
And each one gets a small handoff containing:
- objective
- current status
- decisions
- changed files
- checks already done
- blockers
- next step
No giant conversation history.
No copying the full transcript between tools.
No re-explaining the project from zero every time.
My current token rules are pretty simple.
- load the minimum context
- Use max 2 task skills by default
- only read routed files
- Don't keep raw output around unnecessarily
- Save important decisions into memory
- Validate specific things instead of scanning everything
- shrink context harder when the token budget starts getting tight
The overall idea is basically
route the context with scripts
Use skills for specialized work.
Use indexes instead of repeated searching.
Use Obsidian for knowledge that shouldn't be forgotten.