Predictable work → code
Loading files, applying fixed rules, tracking state, calling tools, validating results, and deciding when the workflow is complete.
Why this works
When an agent does the same kind of task again and again, it often starts from scratch each time: rereading context, planning the steps, choosing tools, and checking the same rules.
Past agent sessions are execution traces. Look across enough of them and the repeated path becomes visible.
Once the repeated path is clear, rewrite the workflow so each part is handled by the right tool.
Loading files, applying fixed rules, tracking state, calling tools, validating results, and deciding when the workflow is complete.
Understanding meaning, resolving ambiguity, choosing among valid options, and producing useful language.
The shared prompt asks your agent to perform the whole optimization in a separate folder before changing anything you already use.
Examine historical sessions for a workflow that repeats often.
Identify the deterministic steps and the steps that need judgment.
Turn repeated procedure into code and keep focused model calls where needed.
Replay old tasks and compare tokens, time, calls, and useful output.
Vivek Haldar explains the idea and its implementation.
The case for purpose-built agent workflows.
How repeated reasoning becomes a smaller, faster system.
Try it on your own agent history
Copy the prompt and drop it into Codex, Claude Code, or your agent of choice.
Get the optimization prompt →