AIToday
AI Coding AssistantsZenn AI/MLPublished: Oct 29, 2026, 01:00 JST

Claude Code in 12+ sessions: grep xcodebuild test to cut tokens

Send on LINE
Claude Code in 12+ sessions: grep xcodebuild test to cut tokens

3 Key Points

  1. What happened

    The developer, who runs apps in parallel Claude Code sessions split by app and role, says filtering xcodebuild test output to just error and result lines was the trick that saved the most tokens.

  2. Why it matters

    Claude Code re-sends the entire conversation on every exchange, so anything that enters the context gets counted again and again, making output trimming and fewer round-trips the core savings levers.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The central mechanic the developer exploits is simple: Claude Code resends the full conversation every exchange, so the cost of a session is not the prompt alone but everything previously added to it. That is why the biggest win comes from keeping long build logs out entirely—grep-ing xcodebuild output down to error and result lines means a suite of 400-plus tests run dozens of times still adds only a few lines to the conversation. The same logic drives the other techniques: contact sheets of thumbnails instead of many full screenshots, grep -n plus sed to read only a range of a 2,000- or 9,000-line file, and checking page state through JavaScript text output rather than visual inspection. The developer also describes packing multiple browser or shell actions into a single call, since each round-trip re-sends the whole conversation.

Running a dozen-plus sessions makes these small savings compound, and it also creates new failure modes. Summarization is one: when a session gets long, Claude Code summarizes it automatically, and if detailed rules drop out of the summary the agent has to re-research them, adding cost. The developer's answer is to keep agreed rules, requests, drafts and handoffs outside the conversation—in memory files, GitHub Issues, docs/ and HANDOFF.md—so only diffs and key points are pasted in. Another failure was a hook that shortened command output interfering with auto-approval, blocking even harmless counting commands.

The developer reports that token-saving has costs as well as benefits: trimming output too aggressively once hid a test failure, and a broken version was committed, so tests are now run separately before committing. Language drift after summarization—replies switching to English mid-session—was addressed by writing an explicit 'no exceptions, Japanese' instruction at the top of CLAUDE.md.

FAQ
How much did partial test runs save?
For one app, running the full test suite took more than 30 minutes, while running only the tests near the edited code took 5–8 minutes.
What happens to work placed in temporary folders?
Useful scripts left in a temporary work folder were deleted twice when sessions switched, so the developer now keeps anything worth keeping in the repo or memory.
Is the developer still using the more expensive model?
Yes. They had switched from Opus to Sonnet to save tokens, but are back on Opus because the newer version felt lighter on usage for the same work—by their own impression.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleAI agent pricing as of 2026年10月: from a few thousand yen to millions