Agent efficiency
A coding agent wastes tokens in two ways.
First, it re-reads its context, the whole conversation so far, at every step it takes. A single request can start dozens of steps, so a long conversation is read dozens of times.
Second, it studies screenshots to decide whether a change worked. A screenshot costs many tokens, and what comes back is a judgement rather than a pass or fail.
Its tokens are better spent on checks I build into each repository, such as tests, type checks and linters (tools that scan code for mistakes). Each one runs where the agent works and prints a short pass or fail. The agent can then check its work after every change, and fix it until the checks pass.
I keep one set of rules and skills (procedures an agent follows), mjeightyfive/skills, that every coding agent reads in every repository I work in. Each piece of it pushes the agent's tokens towards those checks. This note gives the reasoning behind each rule, skill and technique in it.
Takeaways
Where do a coding agent's tokens go?
Building on the strongest model and checking screenshots by eye cost the most, and a long context makes every call more expensive. I learned this by logging each stage's cost against its estimate. A fresh agent reviewing a diff costs a fraction of a build, so the agent spends its tokens on checks, such as tests, type checks and linters, that print a short pass or fail, and on reviews from small contexts.
The figures come from the usage log my agents append to at each stage, a piece of work that ends at a check: 21 stages and runs on Claude models with a measured share of the usage window (the usage limit that resets soonest), each placed in a bar by a written rule. The chart is drawn from a data file that names the log line behind every figure. The same log is what estimates learn from, as Estimate in windows and hours explains.
Building on the strongest model tier cost 15 to 27 % of a window per stage, median 19. Stages that checked screenshots or renders by eye cost 5 to 27 %, median 13. A stage run at 400 to 700 thousand tokens of context cost 4 to 15 %, median 10, but each call in it re-read the whole context, and whole runs that kept a long context across many subagents reached 73 to 90 %. A fresh agent reviewing a finished change cost 3 to 8 %, median 6, its fixes and the final checks included. The readings are whole percents of an account other sessions sometimes shared, and a stage can fall under more than one bar. Only rows run on Claude models count, because each tool's window is a different size.
So verification is where the tokens should go: commands that check and report in one line, and a fresh agent reviewing from a small context, rather than a model reading and re-reading.
How does the size of a request change the work?
A tiny fix is done and checked, a new feature is offered a numbered plan first, and work that spans sessions runs in stages. The machinery grows with the job, so small work never pays for it.
Plan mode, the rules file, skills and the plans folder each do one job. Plan mode, a read-only first step, asks the questions, AGENTS.md holds the rules, a skill holds a procedure, and plans/ holds the record. The size of the request decides which of them come into play.
A tiny change or a small fix is done and checked, and plan mode comes in only when the request is unclear. A new idea or feature gets one offer to become a numbered plan, written from a fixed template, before any code. That plan is what I point the next agent at when something is unclear, so the folder grows into a record of decisions as a side effect of ordinary work. Work that spans sessions goes to /scope, a choice between approaches to /explore, and an audit to /improve.
What are the gate and the app driver?
The gate runs lint, types, tests and the build as one command, and the driver launches the app and uses it as a user would. Both are set up once and run locally after every change, at no model cost, until the work passes or three rounds of fixes have failed.
The app driver is a small CLI (command-line interface) that launches the app on its own port, walks a journey by its sub-feature ID, and prints one line per step with the path to its evidence.
In a new repository, or one missing the gate or the driver, the first agent proposes the toolset before any feature work: what runs locally, and what goes to CI (continuous integration), such as cross-browser runs, long end-to-end suites and load tests. I pick from its options. I decide it case by case, since a slow suite can belong in CI for one project and on every change for another. After that, each change loops on the gate and the driver until they pass, at no model cost. A check still failing after three rounds of fixes stops the loop and comes back to me as a question, with what was tried, so a stuck agent does not spend a window on guesses.
The driver's output is terse on purpose. A model reads it, and every extra line is paid for again on each later call. The driver also owns its instance: its own port, a refusal to start when the port is taken or a build is running, and cleanup of only the processes it started, so it never drives my own dev server.
When does a test prove something?
A test proves something only once it has been seen to fail with the change undone. When agents disagree, they run something instead of asking another model.
A test that passes either way checks nothing and is deleted rather than reported. Tests assert what a user or caller observes, so a refactor that keeps the behaviour keeps the tests passing. Journeys cover the empty, error and interrupted states as well as the happy path, because that is where a change breaks first.
When two agents disagree about whether something works, they run something, a test, a benchmark or a screenshot, rather than asking a third model. Each run says what it expects before it runs, so the result can prove it wrong.
Which test fits which change?
User flows run in the app driver, rules that must always hold get thousands of generated inputs, and rewrites are compared with the old code. Generated inputs reach the edge cases that an agent's own examples miss.
A driver journey proves a user flow from end to end, but many bugs sit where no journey looks. A property test states something that must always hold and lets a generator library, such as fast-check, Hypothesis or proptest, throw thousands of inputs at it: decoding what was encoded gives back the input, a balance never goes negative, running a migration twice leaves the same result as running it once, and an optimised path matches a slow one that is obviously correct. The inputs come from the library, not from the agent that wrote the code, so they do not share its assumptions.
A rewrite or a migration gets a differential test instead. The old code is the oracle: both versions take the same generated or sampled inputs, differences that do not matter, such as whitespace or ordering, are normalised away, and the differences that are meant to happen sit in a list of approved changes. Any other difference is a bug or a breaking change.
How do I keep an agent from weakening its own checks?
A change never loosens (makes easier to pass) the check that judges it, and a fresh agent reviewing the diff reads changed checks first. A flaky test, one that passes only sometimes, is fixed at its cause or deleted. It is never retried until it passes. Otherwise an agent learns to make a check easier to pass instead of fixing the code.
When a test fails, the cheapest way to make it pass is to change what the test expects, loosen a lint rule or drop a step from the gate. So a change never loosens the check that judges it: no changed expected value, disabled rule, grown baseline or relaxed gate. A test rewritten or deleted for a stated reason, or a baseline shrinking as fixes land, is named under Changed with that reason. The fresh verifier reads any changed check before the rest of the diff.
A flaky test does the same damage more slowly: an agent that sees it pass on a rerun learns to rerun rather than fix. So a flaky test is fixed at its cause, never skipped, padded with a sleep or retried until it passes, and when the cause cannot be found, the test is deleted and the reason goes in the report.
A review follows the same rule. It lists only what would block the change, and a problem the change did not introduce is marked pre-existing and reported under Found, so nobody is held to a bug that was already there.
These rules, with choosing the test by the change and stopping a stuck loop after three rounds, came from an article on how one coding-agent team verifies its work.
What happens when the same correction comes twice?
Correct an agent once and it fixes the case; correct it twice and it adds a check that makes the mistake impossible. The check goes as high as it can: architecture, then types, lint, tests and the app driver, with prose last.
The first time I correct an agent, it fixes the case at hand. The second time, the same session turns the correction into a check at the highest layer that can hold it: architecture that leaves one way to do the thing, then a type that will not compile the bad state, then a lint rule whose error names the fix, then a test, then a journey in the app driver. Prose comes last, for judgement calls, because every agent reads it and nothing enforces it.
Waiting for the second time keeps one-off preferences out of the rules, where they would be followed long after they stopped applying. /correct sweeps the whole repository now and then for kinds of mistake nobody flagged. It proves each new check on history, by running it against the version of a file from just before the commit that fixed the mistake. A pattern that is already common goes in a baseline that may only shrink. Every exception carries a reason, an expiry date and an approver, and a test checks all three.
A judgement call that a reviewer can still apply goes in REVIEW.md as one item: a trigger that can be read from a diff, what to check, and the correction behind it. The fresh verifier applies only the items the diff triggers, so nobody has to remember every past mistake. A new check that would block other work warns first, until each hit is fixed or listed, and every sweep deletes prose that a check now enforces, so the rules do not only grow.
Why fix the example an agent would copy?
Agents copy the nearest example in the files they opened, so an old pattern left in the next file gets copied back in.
Each agent sees only the files it opened, and copies the nearest example. A fix that leaves the old pattern standing in the next file has taught the next agent nothing, so fixing a pattern means fixing the examples it would copy, and deleting the old ways and dead code it could find.
A comment that justifies a workaround is the most copied example of all. No comment, doc or rule may justify one: the agent fixes the cause, or reports the workaround for me to decide.
How does a run hand its decisions back to me?
Every run ends with a section called Needs you, which lists each decision as one question, with options and a recommendation. I answer by number, without reading the run.
Every run ends with four headings: Needs you, Changed, Found and Not verified. Needs you comes first. Each decision in it is one question, with what waits on the answer and its options below, the recommended one first, each with one pro and one con, so I can answer by number without reading the run. A decision with a single option is an action instead, given as the exact command.
In a /scope run, a choice that can be undone and sits inside the request is the agent's: it takes its recommendation, logs it and carries on. A choice that widens scope, cannot be undone, or acts outside the workspace is mine, and work that depends on it waits while everything else continues. How a page looks is mine too, so visual work comes back as screenshots at 375, 768 and 1280 px, light and dark where the site has both, with a request to look.
The agent spends its tokens on exploring and checking. Judgement stays with the person who owns the result.
What does each estimate say, and how does it improve?
Each estimate gives a step's share of the usage limit and its run time, and logging it beside the actual cost improves the next one.
Every proposed step carries its share of the current usage window, low, likely and high, and names the plan the percentage is of: a stage that takes 10 % of a window on one plan takes 2 % on a plan with five times the limit. A set of steps adds where the window stands and when it resets, how many windows the set needs and which steps fit in this one, and a rough run time in hours and minutes.
Each estimate is written before the step starts and paired with what the step actually cost, in a log kept in a data folder outside every repository, so every project and every tool learns from the same history. Agents writing rows by hand let the log drift into about fifty spellings of the same few fields, so a command now appends the rows and refuses a bad one. Once three paired samples exist for a model and plan, a command prints how far its estimates run high or low, and the next estimate is scaled by that ratio.
The /scope run that built that command, and wrote this note, had ten stages. Its plan opened with the window and a table of every stage, each with its tier, the model and effort to run it at in each tool, and the estimate. Here it is in today's one-column format, cut to four of the ten stages:
Window 38 % used, resets 18:20 UTC. Estimates are on Max 5x and a guess: the log has no rows yet for this tool, model and plan.
| # | Step | Tier | Claude Code | Cursor | Codex | Estimate |
|---|---|---|---|---|---|---|
| 1 | Policy in the rules template: gate first, outcome tests, edge states, a fresh verifier | Standard | Opus 5.5 Medium | Opus 5.5 Medium · GPT-5.6 Sol Medium · Grok 4.7 Medium | gpt-6.2-sol Medium | 1 / 2 / 3 %, 30 min |
| 5 | Usage-log command: validated rows, run times, the data folder | Standard | Opus 5.5 Medium | Opus 5.5 Medium · GPT-5.6 Sol Medium · Grok 4.7 Medium | gpt-6.2-sol Medium | 3 / 6 / 10 %, 65 min |
| 7 | Second review by a fresh agent, then one round of fixes | Standard | Opus 5.5 Medium | Opus 5.5 Medium · GPT-5.6 Sol Medium · Grok 4.7 Medium | gpt-6.2-sol Medium | 1 / 2 / 4 %, 22 min |
| 9 | This note, with four diagrams | Standard | Opus 5.5 Medium | Opus 5.5 Medium · GPT-5.6 Sol Medium · Grok 4.7 Medium | gpt-6.2-sol Medium | 3 / 6 / 10 %, 90 min |
| All ten stages | 14 / 28 / 48 %, 4 h 20 min to 8 h |
The likely total fits in what is left of this window and the next one after the reset.
The tiers are what the plan recommended for each stage; this run did all ten in one session on the strongest tier at high effort.
Stages ran back to back with no reading between some of them, so the window was read three times, each reading covering a group of stages. Together they took 8 % of the window against a likely 28 %. calibration advise now prints scale estimates by 0.29 (3 samples, Max 5x, measured), so the next run on that model and plan starts from estimates under a third of these. Three samples is a thin start, and readings in whole percents make a small stage look free, so the ratio will move as the log grows.
What do the rules themselves cost?
With the core profile, every session reads about 4,550 tokens of rules before it does any work. That is about a tenth less than before I trimmed them. Nobody has measured yet whether they save more than that.
That fixed cost has three parts: the rules file, the list of which skill owns which kind of work, and a one-line description of each of my own skills. Skills from other sources add their own descriptions, which the script does not count. A script measures it for each profile, the set of skills a kind of repository installs, and a test fails when a profile goes over its budget. Listing only the owners of skills a repository actually installs cut the core profile from 5,058 to 4,339 tokens. Rules added since then brought it back to about 4,550, still about 10 % less than at the start. The web profile this site uses costs about 4,660. Moving thirteen animation skills into a profile of their own also took their descriptions out of this site's sessions. That is about 1,200 tokens more, but only a guess, because the script counts only my own skills' descriptions.
The first estimate of what the rules save is a guess too, written down in the plan that measures it. Fresh sessions, short pass-or-fail checks, a fresh review, plain wording and checking the window before a job may save about 6,800 tokens per task. The rules, with the reviews and estimates they ask for, cost about 5,200 per task. That leaves a likely net saving of about 1,600 tokens per task, in a range from a loss of 6,700 to a saving of 13,800. A session that holds only one task likely costs more than it saves, so the answer depends on how many tasks a session holds.
How will I know what the rules save?
The usage log will show it, once each finished task records which version of the rules it ran with. A trend from everyday work is only a hint, so a claim needs a study that runs the same tasks with and without the rules.
Each task's result row records the version of the rules and the profile, the task's size and kind, how many rounds of fixes it needed, and whether it passed. A command, calibration savings, groups those rows and prints the median share of the usage window that a finished task used. A change to the rules then shows up as a change in that share.
Everyday rows cannot prove a saving, because the tasks differ from one week to the next. The study picks 20 tasks in advance and runs each one twice from the same files, once with the rules and once with a minimal rules file. The order of the two runs is random, and both runs must pass the same check. The decision is made once, after all 40 runs, from the median difference and the range around it. The usage window is read in whole percents, so a saving counts only when even the low end of that range is more than two points. Otherwise the answer is "not proven".
Why keep contexts small?
A long context is re-read on every call, so past about 150 thousand tokens the work moves to a fresh session through the plan file. Reading fans out to parallel agents, and decisions stay in one place.
Past about 150 thousand tokens, or half the context window, the agent writes where it got to into the plan file and continues in a fresh session. Reading and searching fan out to fresh agents in parallel, each returning a conclusion rather than the files it read. Decisions, and edits to files more than one agent touches, stay in one place, one at a time.
Exploring or debugging stops once more of it would not change what happens next, and the report says what was tried and what would change the answer.
Who commits the work?
Agents print the git commands and never run them, so every commit is mine to review and make. Several agents can share one working tree because each names only its own files.
Agents print the commit, push and branch commands with explicit paths, and I run them under my own name. Several agents can share one working tree, so each names only its own task's files in the commands it prints and says which unrelated changes it left alone. The commands come in blocks I can paste whole: one command per line, each joined to the next so that a failed command stops the rest, and a branch switch in a block of its own. Everything an agent writes reads as my own work.
A wrong commit costs more to unwind than a diff costs to review, and the history stays mine.
Why does every step name a model for every tool?
Work moves between tools, so each step names its model and effort in all of them. A guard set up in one tool does nothing in another, so every rule is written in prose as well.
Work moves between tools often, so every proposed step names its tier and the model and effort to run it at in each tool, as well as in the one it was proposed in. Three tiers cover it: deep for architecture and debugging that resists a first guess, standard for feature work against a clear spec and for reviews, and mechanical for renames and executing a written plan. The expensive model decides, and the cheap one does.
Enforcement does not travel. A deny list in one tool's settings means nothing to another, which guards with its own allowlist or sandbox, so the rules file states every rule in prose as well, and a step that runs near git says which guard holds it.
Which skills are my own, and where do the others come from?
Six skills are mine, and the rest come from other people's repositories, chosen per project. Mine cover auditing, running large tasks in stages, measuring a choice, correcting, verifying and plain writing. Five of the six run only when named, and each domain has one owner.
Six skills are mine: three written from scratch and three patched forks. improve started as improve, and correct and drive as two skills from a plugin pack, where drive is called create-verification-skill. All but plain-english run only when they are named:
improveaudits a repository and writes numbered plan files for other sessions to execute. It only writes plans, defaults to a quick pass, and gives every plan an estimate and a Needs you section.scoperuns a task too large for one sitting inside the usage limits: stages, estimates against a reserve, a fresh verifier per stage, prompts for other tools, and a handoff before the window runs out. Its procedures for estimates, handoffs, unattended runs and prompts for other tools live in reference files it reads only when they apply, so a session pays for them only when it uses them.exploresettles a choice between approaches by building each one in a throwaway clone and measuring it.correctis the repository-wide sweep for repeated mistakes.driveproposes the toolset and builds the app driver, with a feature map written from the user's side.plain-englishsets the plain writing style an agent uses whenever it writes or reviews prose.
Everything else comes from upstream by role: writing and React guidelines, interface review, motion, and coding behaviour. Each domain has one owner, and where two skills share a trigger, the manifest says which one governs what.
What decides which skills are installed?
One file names every skill's source, and the reason each left-out skill is out, and an audit flags any new skill at those sources. The rules sync into every repository between markers, and local edits survive.
A single manifest names every skill's source, the profile that installs it, and, for every skill left out, the reason. An audit command lists any upstream skill the manifest has never ruled on, so a new skill arrives only by decision. A skill that tells an agent to commit or push stays out whatever its source, because the rule against agents committing outranks the order in which sources win a conflict.
The rules are not a skill, because a skill loads when a request matches its description and a rule has to hold on every turn. They live in the rules file, in sections between markers. An update replaces a section only when the repository has left it untouched, and leaves an edited one alone, stopping with a conflict when the template moved too, so the rules stay current everywhere and a repository's own changes survive.
How do I settle a choice between approaches?
/explore settles a choice between approaches by building each option in a local clone and measuring it. Every result is logged, failures included, so an idea is tried again only when the code it touched has changed.
When the task is a choice between approaches, each option is built in its own local clone of the last commit, outside the repository, and measured by a command rather than judged by opinion. Every result, failures included, goes into an experiment log in the repository, so a later session reads that an idea failed before it tries it again. The run stops once the remaining options could not change the pick, and asks me to choose, with the measured results as the pros and cons. The winner arrives as a patch on my working tree, for me to review and commit.