DEV Community

Anton Danilov
Anton Danilov

Posted on Originally published at treeyard.ru

How to make Claude Code and Codex limits last: fewer redos, not shorter prompts

When your Claude Code limit runs out by midweek, the first instinct is to trim prompts. But the prompt is a small part of the bill. Limits are eaten by redos, when the agent misread the task and did it twice. They're eaten by a session that took on three more things “while it was at it”, by a top model fixing a typo, and by five agents where two would do.

Treeyard is a free, open-source (Apache 2.0) terminal tool: you plan a project as a tree of goals and run Claude Code, Codex, Antigravity and OpenCode sessions right from its nodes. It plugs these leaks with the way the work is set up, not with willpower.

treeyard in a terminal: a coffee shop's goal tree with milestones, tasks, a node waiting for the bank and two ideas
A planted tree: the goal at the top, the first milestone with its tasks, a branch for repeat orders, a node that waits for the bank and two ideas parked for later.

In short

  • The most expensive work is work done twice. A criterion before the work and a plan before the code cost less than a second attempt.
  • One task, one session: a long conversation gets pricier with every turn.
  • Match the model and effort to the task, check with a command, cap parallelism.

Where the limit actually goes

We covered a short session start separately: a session opened from a node starts at about 3 thousand tokens instead of 65 thousand for the whole plan. But most tokens go into the work itself. Here's where they leak:

Where it leaks How Treeyard plugs it
The agent misread the task, so it starts over Every node has a “done when”, and the session starts with a plan
One session for three tasks A node is one session; a new idea is a new node
A top model fixing a typo Model and effort are picked for every launch
“Check that everything works” — another agent turn The node's check is a command, no agent involved
Five agents hit the window mid-task A queue with a cap that pauses when the window is full

A redo is the most expensive line on the bill

The agent takes a vague task, does its own thing, you explain, it redoes it. Every attempt pays for the whole context again. In Treeyard every node has a “done when”: one sentence you can see or run. Can't write it? The node menu has “Write a "done when"” and “Break into steps”: jobs for an agent without a session, read-only and offline.

Then there's the “plan” start. Claude Code opens in its plan mode and edits nothing until you agree. Fixing a five-line plan is cheaper than rolling back code.

The node's menu in treeyard: a new session of any CLI, and agent jobs without a session — break into steps, write a “done when”, run the check
The node's menu: start a session in plan mode, or let an agent break the node into steps or write its “done when” without opening a session.

Short sessions cost less than long ones

Every new turn carries the whole conversation. A session that spends three hours finishing “just one more” neighbouring thing pays for its entire history at every step. Treeyard's rule: a node is one session or one PR. More than about ten items inside, or “just a bit more” after it's closed, means the node needs splitting.

A new thought in the middle of the work becomes a node with the “idea” status, and the session goes back to its own node:

treeyard add "Coffee quiz: find your roast" --parent <id> --status idea
Enter fullscreen mode Exit fullscreen mode

The next session starts with a clean slate, but not from scratch: it gets the node's journal by itself.

Model and effort to fit the task

A top model on high effort burns through the limit faster, and there's no point spending it on small stuff. In Treeyard the model and effort are picked for every launch: the agent menu shows each CLI's start, model and effort, and each CLI's last launch is remembered separately. Planning a tricky node goes to the top model; renaming a button goes to a smaller one or to low effort. treeyard models lists the models and effort levels, and the project defaults are model and effort.

The agent menu in treeyard on the “Checkout with Stripe (test mode)” node: Claude Code · plan · opus · high, with Codex, Antigravity and OpenCode below, each with its own settings
The agent menu: every CLI shows how it starts (plan or do), its model and effort. The last launch, with the same settings, is on top.

Check with a command, not an agent turn

“Check that everything works” is one more agent turn, and what you get back is its word. A node has a “check” field: the command that proves the result — tests, curl, a script. The t key runs it without an agent, so it costs nothing from your limit. When the agent finishes, it also shows the command and its output instead of writing “done”.

How many agents at once

Parallel agents share one subscription window. Five at once drain it faster, and a session that hits the limit stops mid-task — until the window resets, you're left holding unfinished work.

Three agents at once in treeyard: Claude Code writes the checkout in a pane next to the tree, Codex waits for an answer, Claude Code works in the background
Three sessions: Claude Code in a pane next to the tree, Codex waiting for an answer, another Claude Code in the background. The header says “agents working: 2, waiting for you: 1”.

treeyard queue <id> --parallel 2 runs a branch's nodes in order, no more than two at a time. Before each launch the queue looks at the subscription window, using what the CLI saved itself, without a request to the model. If the window is 90% full (--limit), new sessions wait for the reset.

Treeyard itself doesn't spend your limit

The tree, the queue and the node's check run without a model. Tokens are spent only when you launch an agent: a session, a tree review, or “Break into steps”.

Try it on your project

  1. Install — npm install -g @antondanv/treeyard. You need Node.js 22 or newer and Claude Code, Codex, Antigravity or OpenCode.
  2. Plant a tree — run treeyard in the project folder. The wizard offers to plant it with an agent, which reads the code, docs and commit history itself, or from a template.
  3. Open a session from a node — c on a node. The agent gets the node, its criterion and its journal, not the whole plan.
treeyard models                                # models and effort levels per CLI
treeyard add "…" --parent <id> --status idea   # the idea goes to the tree, not this session
treeyard queue <id> --pane --parallel 2        # a branch in order, two sessions at a time
Enter fullscreen mode Exit fullscreen mode

Questions

When don't I need Treeyard?

When the task is single and small — a script, a bug, a quick question. Plain claude or codex is simpler there: the tree would take longer than the task. The same goes for a one-evening prototype.

Does it work with Codex too?

Yes. Claude Code, Codex, Antigravity and OpenCode launch from a node the same way, and each one's launch settings are remembered separately.

How much does it cost?

Nothing: Treeyard is open source under the Apache 2.0 license and installs from npm.


Treeyard is open source — Treeyard on GitHub. npm install -g @antondanv/treeyard, then treeyard in your project folder.

This article was created with the help of AI.

Top comments (5)

Collapse
 
dosaygo profile image
dosaygo •

When you launch separate Claude Code or Codex sessions from different Treeyard task nodes, how do you verify each session extends existing repository helpers instead of building a duplicate implementation that causes a redo?

Collapse
 
antondanv profile image
Anton Danilov •

Good question, thanks! Honestly, Treeyard doesn't scan the code for duplicates itself, but the workflow gives you a few places to prevent them or catch them.

  1. Decisions every session sees. treeyard decide "Money formatting only through lib/money.ts" goes into every node's context, so the agent knows the rule before it starts.

  2. Shared code first. If two tasks need the same helper, I make it its own node and the others depend on it (treeyard set <id> needs+=<helper id>). The queue won't start them until the helper is in review or done.

  3. An optional plan. Start a node with "plan" and Claude Code proposes a plan before touching the code, so you see early whether it reuses the helper. With the default "do" start, a duplicate gets caught later, at review.

  4. Review and merge. The agent sends its work to review instead of marking it done. In parallel runs each node has its own worktree and branch, so nothing reaches main until you (or a coordinator session) merge it after looking at the diff (V in the tree). You can also open a fresh session on the node just to review it: treeyard open <id> --task "does this diff reuse the existing helpers?"

  5. When an agent hands out the work. A coordinator session uses treeyard wait to wait for the sessions it started and read their last messages, and treeyard queue to run a branch in order with a limit on parallel sessions. Both check whether two active nodes really collide in the same file (with a trial merge) and tell both sessions, before it turns into a merge conflict.

You've got me thinking, though: catching duplicates more directly is worth working on, so I'll be looking into improvements here. If you hit a case this doesn't cover, I'd love to hear about it, here or in GitHub issues.

Collapse
 
dosaygo profile image
dosaygo •

Thanks for explaining the shared-helper dependency, trial merge and review steps, Anton. I build AI Lint: its architecture rejects flag parallel solutions as a review concern, so an agent or reviewer can check for an existing implementation before adding another; it does not automatically detect duplicate behavior. The free edition is for personal use, while company teams use paid packs or a Company license: ai-lint.dosaygo.com/go/forum-20261...

Collapse
 
userxnom profile image
Abdullah Naseer •

The reframe landed for me — it's not the prompt length, it's the redo. The 'done when' criterion before the work starts is the part I'd steal first; most of my agent sessions go sideways because the task was vague, not because the model was weak. The check-as-a-command idea is also sharp: asking the agent 'does it work?' just buys another expensive turn and its own word for it. One question: when a node grows mid-work and you split off an 'idea' node, how do you keep the journal from getting stale — does the next session actually read the full journal, or just the last entries, when the branch gets long?

Collapse
 
antondanv profile image
Anton Danilov •

Thanks for taking the time to write this, it really helps. Treeyard is mostly an idea I'm building on my own, so hearing what clicks for people (and what doesn't) is exactly what I need right now.

Totally agree about vague tasks. My rule of thumb: if I can't write the "done when" in one sentence, I don't understand the task yet, and that's the moment to split it instead of starting a session.

To your question: it's just the last entries. A session gets the last six journal entries of its own node, minus the noise like status changes and commits, which are in the node header anyway. If there are more, the context tells it how many and how to get the rest with treeyard show <id> --journal all. So it's a starting point, not a limit. If the agent needs more, it can read the full journal, look at any other node with treeyard show, or search the whole tree, finished nodes too, with treeyard find.

The journal stays short mostly because a node is one concrete task, roughly one session. Nodes get split up front while planning, not halfway through: you press S on a node, an agent suggests 3 to 7 steps, and you pick the ones you want. If something needs redoing later, you can make a new node or a whole new branch for it. Or just reopen the old node or start a new session in it, nothing forbids that or dictates how you do it. Smaller nodes with their own "done when" mean fewer tasks per session and a clearer target for the agent, and in my experience that means better code and fewer redos.

If a new idea pops up mid-work, it goes into its own idea node and the session keeps going on its task. The idea's session later gets the path above it (the parent's description and the criteria higher up), but not other nodes' journals. So if something from the parent's journal matters, put it in the idea's note right away: treeyard add "..." --status idea --note "...". And since every session ends with a "what's done, what's left" entry, the latest entries are always the current state. Decisions I don't want to argue about again go into the tree's Decisions list with the reason (treeyard decide), and every session sees those.

If you give it a try and something feels off, I'd really like to hear about it, here or in GitHub issues.