Ant Farm
Watch your subagents work, and what they cost, live.
The prompt
ant-farm / prompt
Build me a Claude Code mod called "ant-farm" that makes subagent work visible. What it does- While a turn runs, a slim band above my prompt shows elapsed time, subagents running vs done, and the estimated spend so far.- /antfarm opens a side pane listing every subagent this session: its task, model, a progress bar, tokens used, estimated cost, elapsed time and status (running, done, failed). Running ones on top, finished ones collapsed below.- Each subagent gets a small pixel-art ant that walks while it works and stops when it is done. One ant colour per model.- Header totals: total cost, total tokens, wall time. What is new here- Budget alarm: a budgetUsd setting (default 2.00). When the session estimate crosses it, show a toast and turn the status line amber; past 2x the budget, red.- ETA: once a running subagent has made 3 model requests, estimate its time left from its pace so far ("~1m left").- Narrow terminals: if the pane cannot open (under 144 columns), show a compact list inside the band instead of nothing. How it works- Track subagents through the agent spawn and turn step events and count tokens per model request.- Estimate cost from a small built-in price table per model and mark every cost as an estimate (≈).Details
Ant Farm
Watch your subagents work, and what they cost, live.
Use it
- The band. While a turn runs, a slim line above the prompt shows the elapsed time, how many subagents are running and done, and the session's spend so far. It stays while background subagents still run.
- The pane.
/antfarmopens the Ant farm pane (it also works mid-turn). At the top: the subagents' total estimated cost, total tokens and wall time, then the session's spend against your budget. Below, one card per running subagent: its task, model, status, elapsed time, a progress bar, requests, tokens and estimated cost. Finished subagents fold into one line each under Finished; Expand shows them as full cards again. - The ants. Every subagent gets a small pixel-art ant, one colour per model. It walks while its subagent works, stands still when it is done, and lies on its back if it failed.
- ETA. Once a running subagent has made 3 model requests, its card shows an estimate of the time left ("~1m left"). It uses the subagent's own pace (time per request so far) and how many requests finished subagents of the same type needed this session. With nothing finished yet, it assumes the subagent is halfway.
- Opens itself where it fits, once. When the first subagent starts on a
surface that docks panes beside the transcript (the fullscreen terminal, the
desktop app), the pane opens on its own, at most once a session and never
after you closed it by hand. Under 144 columns the engine holds such a pane
back, so the band lists the subagents instead (one line each, with a
Hide button).
/antfarmopens it any time. - Two kinds of money. The session's spend (the band, the pane's budget
line, the status line and the alarm) is Claude Code's own total, the figure
/costshows, labelled "Claude Code total" and drawn without≈. Where Claude Code gives no total, the price-table estimate stands in, marked≈. Each subagent's cost is always the price-table estimate (≈): Claude Code does not total cost per subagent. - Budget alarm. The mod's status line under the prompt shows the session's spend against your budget. When it reaches the budget you get a toast and the budget mark beside the prompt footer turns amber; at twice the budget, another toast and red. Each crossing toasts once.
/clearstarts the farm over, as it does/cost.
Settings
| Setting | Default | What it does |
|---|---|---|
budgetUsd | 2 | Session budget in US dollars for the alarm, checked against Claude Code's own total. 0 turns the alarm off. |
What it can touch
- Files: none. Processes: none. Network: none.
- Model calls: none. Everything is counted from the usage the engine reports for each model request; nothing is sent anywhere.
- Engine calls: reads Claude Code's cost total for the session (after each model request and turn end), reads the session's agent list (to pick up a subagent that started before the mod loaded, and to settle one that ended without saying so), opens and lists its own pane, sets its status line, shows toasts.
- Memory: its counts live in session state and are gone when the session ends. Nothing is written to disk.
Limits
- Per-subagent costs are estimates. They come from a small built-in table
of Anthropic's published API list prices (cached 2026-10-06), marked with
≈. The table cannot see fast mode, batch pricing, partner clouds (Bedrock, Vertex) or negotiated rates, and it prices every cache write at the 5-minute rate. A model missing from the table shows its tokens and a cost of?. The subagents' sum can therefore differ from Claude Code's total. - Claude Code's total is read after each model request and turn end, so
the alarm can trip one request after the real crossing. A resumed session's
total includes its earlier runs, as
/costdoes. - The fallback estimate counts only model requests of a turn. Side
requests outside a turn (titles, safety checks) do not pass through
turn.step, so when Claude Code gives no total the estimate misses them. - The status line cannot be coloured. Claude Code's plugin status line takes text only, so the amber and red of the alarm are drawn on the budget mark beside the prompt footer, the band and the pane header; the status line itself says "over budget" or "past 2x the budget".
- The ETA is a heuristic. Subagents do not announce how long they will take. Treat "~1m left" as a rough guide, most useful once a few subagents of the same type have finished.
- The pane opens unasked only where it would be a sidebar. On the
terminal's main screen (no fullscreen layout) use
/antfarm. - The band and the footer mark draw on the terminal and the desktop app, the surfaces that have them. The pane draws wherever panes are placed.
- A subagent that runs in a remote cloud session (
isolation: 'remote', internal builds only) has no local loop: ant-farm sees it start but none of its requests, and cannot tell exactly when it ends. - A background subagent stopped from outside may never report its end; the mod checks the engine's agent list about every 10 seconds and settles it from there.
Built from a prompt
This mod was built from the ant-farm prompt.