r/ClaudeCode • u/ScarcityOrdinary6877 • 2d ago
Help/Question How do you run long Claude Code builds on one machine without everything waiting in line?
I run all my projects with Claude Code on one home server: 6 cores, 15 GB RAM, Debian 13, no GPU. /tmp is tmpfs, so it eats RAM too. Right now that's a few web apps (Next.js 16 + Supabase + Vercel), a Shopify store, a browser game and a mobile app (Expo, Android emulator for testing). Often 2 or 3 projects have sessions running at the same time.
THE SETUP
- Sessions run in tmux via a session manager, and I follow them from my phone with Remote Control
- Each project has one lead session (Opus) that works through a task list on its own, often all night
- The lead starts up to 2 builder subagents, each in its own git worktree. Merges go back to main
- Reviews: 1 to 3 reviewer agents per task depending on size, max 2 review rounds. Small findings go into one "sweep" task instead of a new task each
- Agents talk to each other through a mail/file-reservation tool so they don't edit the same files
- I wrote my own Claude Code plugin with all the rules, gates and scripts, so every project works the same way
THE CHECKS EVERY TASK HAS TO PASS
- tsc --noEmit, lint (Biome), Vitest, next build, pnpm audit
- Playwright e2e, but only the specs the change touches. I keep a map of source files to test areas (55 areas), and a new file must join an area in the same commit
- e2e stops at the first failure while iterating. The full suite runs once per batch, before main
- UI tasks: screenshot check against the approved design mockups at 390 and 1440 px, on a production build on its own port
- Mobile screens: every state (5 to 25 per screen) on the Android emulator with Maestro flows, and screenshots compared to the mockups
- DB changes: pgTAP tests on a throwaway local Supabase in Docker
HOW HEAVY JOBS ARE SHARED
- Every heavy step (build, test suite, e2e, emulator flows) from every project goes through one machine-wide queue. Each job has a cost (1 or 2 units) and the queue only lets so many units run at once
- Test runners read their worker count from the queue (3 workers)
- e2e has its own lock with priority, so a run someone waits for goes before background runs
- The lead rotates to a fresh session at 3 compactions, after 8 hours, or when its pace drops below half its own average. It writes a handover file and starts its successor itself
THE NUMBERS
- Fresh lead on web work: about 9 tasks/hour for the first 3 hours, then down to about 5/hour
- Last night, mostly app screens: 12 tasks in 8.8 hours, and 5.6 of those hours were spent waiting in the queue
- Emulator alone is about 2.2 GB RAM. Add two builders with their own Metro bundlers (one per worktree, different ports), a Next build and Playwright from another project, and the machine runs low
- When memory gets low, Claude Code kills idle background shells, so my watcher scripts die quietly
THE PROBLEMS
- Queue time. The bottleneck isn't the model, it's waiting for CPU/RAM
- One emulator. Every app screen state goes through it, one flow at a time
- Memory. 15 GB isn't enough for emulator + 2 worktrees with Metro + builds + e2e across projects
- Sessions wear out. Context fills, pace drops, so I rotate every few hours
WHAT I'D LIKE TO KNOW
- What does your setup look like for long autonomous runs across several projects? One big machine, several machines, or cloud (and roughly what does it cost)?
- How do you share CPU and RAM between projects so one doesn't block the others?
- How do you test mobile screens without one emulator being the bottleneck? More emulators, cloud devices (Firebase Test Lab, BrowserStack, EAS), or fewer states per task?
- Do you run the full checks on every task, or batch them? Where did you draw the line?
- Any tricks for keeping Metro/emulator/Playwright memory down?
- What made the biggest difference in speed for you?
Thanks.
•
u/AutoModerator 2d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Painter_new8 2d ago
Did you set a limit for the emulator? Like 2-3 cores max. It will take longer but it could help running simultaneously.
1
u/MikeWise1618 2d ago edited 7h ago
In today's world that is a very small machine. Sessions need memory to run their tools. Its fine for 1 or 2 sessions, but If you want to do a lot in parallel you will need far more memory, like 64 gb at a minimum, and probably 12 cores.
I have 192 GB and 16 cores, but 128 would probably be enough for most things.
1
u/AgentYurt 2d ago
Two things from running a setup like this. First, the handover file is where the rotation lives or dies — I write it as what the session was trying to do, what actually changed, the calls I made and the reasoning behind them, what's still open, and what happens next. And the next session doesn't take any of that on faith; it checks the diff or the test behind a decision before building on it.
Second, your own numbers say the lead isn't the bottleneck: 5.6 of 8.8 hours was queue time. Rotating earlier won't buy you much there. The single emulator and the checks waiting on it are doing the damage — that's where I'd spend the effort.
1
u/shetritr 2d ago
on 6 cores the fix is usually one lock, not more scheduling. wrap next build and the playwright runs in flock /var/lock/heavy.lock so only one heavy job runs across all projects and the rest wait their turn, while tsc/lint/vitest stay parallel. and with /tmp on tmpfs, point the build caches at disk so three next builds aren't eating your 15 GB
1
u/bornmix_dev 2d ago
your own numbers answer half of it: 5.6 of 8.8 hours in the queue means you're short on hardware, not on model. cheapest win is probably moving the emulator off that box. an old android phone over adb or a small mini pc that only runs the emulator frees 2+ gb and stops it blocking web work. second, I'd treat next build like your full e2e: tsc, lint and the touched tests per task, the full build once per batch. and only start metro for the worktree whose task actually needs the device. rotating the lead on pace drop with a handover file is smart, I'd keep that
1
u/SirRobinBlibs 2d ago
If /tmp is tmpfs, parallel agents aren't only competing for CPU. Their tarballs and test artifacts are competing for RAM, and that's often what makes the next build wait.
I'd point TMPDIR at a disk-backed directory per worktree, and keep the flock around the heavy compile or test step, not around the whole session. Light work can overlap; the lock only has to serialize the part that blows up memory.
1
u/Traditional-Diver160 2d ago
One more angle - I set the depth of the check by risk, not by task. Simple changes (texts/layouts) the agent just rereads, if this is new logic - one independent review, and only things that can delete or damage user files get the full review. And my agents do not build or run tests without my explicit go-ahead (this is a strict rule).
1
u/vladmvp 1d ago
If you want the projects to stop competing for those 6 cores, you could move the heavy sessions to Cobalt (cobaltcode.ai), which gives each task its own persistent cloud computer, so a Next.js build in one project doesn't slow down another. You can keep using Claude Code with your Anthropic API key, and it can run Playwright checks and show a live preview of the app when you review. The flock idea above is a good cheap fix if you'd rather stay on the one server. There's a free account to try it, and I'm the founder, so happy to help you get started.
1
u/Seerix 2d ago
Im making a game with bevy so uh.... I wait a lot
1
u/PilotLost404 1d ago
Batch the checks. Per task, run only type check, lint and the tests the change touches. Run the full suite and e2e once before merge. Full checks on every task are why you spend 5.6 of 8.8 hours in the queue. Cut the number of agents running at once before you buy more RAM, since two builders plus an emulator is already past what 15 GB handles.
1
u/No-Drawing9451 1d ago
I can't speak to the emulator side, but two things helped on the queue.
I wouldn't run more than 3 or 4 agents at once on a machine like that, even if the queue can hold more. Past that I can't actually look at what came back overnight.
And I don't let a builder take a test slot just because it said it finished. I check whether it touched the files I expected. If the change set is wider than the task, I send it back before it sits in the queue for hours.
1
u/vr6wannabe 17h ago
full disclosure i'm the founder of groundbox. we make sandboxes for agents, so each session can send its builds and tests to its own vm instead of all of them fighting over your 6 cores
https://groundbox.dev/docs/sandboxes