Building a factory
A homebrew orchestration and queuing system
I get the impression everyone eventually builds their AI development shop floor. As much as I’ve come to love Rex in a very short time, I didn’t have a way to manage work on my projects:
- Prompting in a new session involves setting up the session, wondering about what else is in progress, hoping Claude doesn’t decide to just start working.
- Agents collide with each other if I don’t tell them to watch out for each other.
- Decisions are recorded in the vagaries of Claude’s memory.
- Knowing what’s going on across all of it involves flipping around in tabs that are in varying states of either verbose build output or buried ledes.
My swing at solving this is “The Factory.”
- GitHub issues in each of my projects get picked up by a foreman.
- The foreman makes a worktree per issue, creates an agent in it, and hands the issue to it. It uses Rex’s tools to open a tab in the project’s standing Rex session vs. just making a random tab somewhere. It’s a small thing but it makes Rex easier to scan for WIP across projects.
- The agent develops an initial plan or asks questions in the issue comments and isn’t permitted to start work until it gets a 👍on its comment.
- The foreman lives in a session called The Office and offers status on everything in progress, telling me where my attention is needed to keep things moving. If I have a second thought about how to prioritize things, it checks what’s queued and what might conflict if I want a papercut fixed quickly.
The foreman understands a light taxonomy of work types: Features that require a chat session, bug fixes that require a chat session, and papercuts an agent is empowered to go fix at spawn (or go wait in line to do).
I made a Raycast extension that shows me the state of all the WIP, and an internal web page (The Office) that gives me status cards and provides dynamic buttons to pick from choices or send “go” on approved plans.
The Raycast extension can also capture issues using my work types taxonomy. It’s great for when I’m using one of my projects and come across a papercut or feature: Hit opt-i for “new issue,” fill out the form, and know the foreman will send an agent to go do discovery and queue up a proposed plan while I’m working. Much less context switching and session setup for me, and I know that even if I filed the thing as a papercut the agent can just go fix, it will wait in the queue.
The foreman is also working with Rex: It pays attention to which machine I’m at (Mac mini, where the actual Claude sessions run, or MacBook Air, where I tend to work on this stuff) and it manages tunneling and redirects so that Oauth flows and mockups are directed to the machine I’m sitting at instead of the mini.
A few other components support all this:
- “Corpus” is a repo with all the design docs, recorded decisions, and established processes. The agent managing Corpus understands which classes of information can be altered by a machine, and which require a PR I have to approve. Agent sessions start with a Corpus search before design work begins.
- Corpus agents and the foreman also talk to my Ref tool. When I’m curious about something, Ref is where I fire up a research agent to provide a cited brief on a given topic. It’s more human readable, and Ref has affordances to redirect the research or go more deeply on a piece of it. I could do this in regular chat sessions, but Ref just gives me a more focused UI. If I point the Foreman at “ref 973” it knows to go find that brief and make sure a new agent takes advantage of the research before designing.
- The Apple Factory is a build pipeline for macOS and iOS apps that handles the process of building and deploying notarized, TestFlight, and OTA ad hoc apps. I haven’t gotten rid of all the manual interaction there — I don’t think I understand Apple’s build APIs and haven’t made Claude go figure them out — but the Apple Factory is pretty reliable otherwise: Papercut fixes to my apps reliably turn up as Sparkle updates, and it can deliver an ad hoc install from nothing but a few turns with an agent about the app’s design.