In My AI Workflow Part 1 - PLAN we used Wayfinder to plan all the details of the feature and store the context in tickets. In this post, we'll continue where we left off by splitting the context into implementation tickets, and then generating the pull requests using sandcastle.
First I run /to-spec to generate a single ticket with the full design. This spec will help keep the implementation consistent, as all future implementation tickets will refer back to it. Generally it's important to run this in the same claude where you did the grilling, but since we've created the plan across multiple grilling sessions I just run /to-spec https://github.com/Equal-Vote/bettervoting/issues/1701 to refer back to the root of the Wayfinder planning tickets. That produced Spec: Voter Groups · Issue #1711 · Equal-Vote/bettervoting · GitHub.
Then I run with the spec issue /to-tickets https://github.com/Equal-Vote/bettervoting/issues/1711 to split the spec into sub issues that are each scoped to be resolved in a single context window. I get a preview of 9 tickets, and their blocking relationships as follows:

Then I gave some feedback before starting the implementation, in this case it suggested that 3/4 and 5/6 are mergeable so I opted for the merge.

And then the agent created 7 tickets as sub-issues on the spec, and now we're ready to implement.

From here, we could copy each issue into a claude session and then create more sessions as tickets get unblocked, but Matt's Sandcastle Tool is designed to streamline this process.
Sandcastle is built on the idea of a ralph loop, which is a bash loop that runs claude sessions on issues until all issues are resolved. Ralph loops were a game changer since you could reliably implement complicated features while you sleep. Sandcastle handles the ralph logic, and also takes it a step further by sandboxing your sessions, and using git worktrees so that multiple tickets can be implemented in parallel.
I just ran "npm run sandcastle", then it knew to look for the tickets I had tagged with "Sandcastle", and I just went to bed. In theory it could be done in the morning, but in this case I had to fiddle with it since I was using some new settings.
Sandcastle is super flexible, which is both a blessing and a curse, since it took some trial and error for me to get settings just right. I currently have mine setup to implement all unblocked issues in parallel, and then run a reviewer agent on each of them before they get merged into my local main. From there I push them into a stacked PR in github. For some projects, I've also had sandcastle output a QA ticket with a checklist for me to manually walk through so I can confirm the change.
Sandcastle is extra effective when you have backpressure setup in your project. This includes linters, unit testing, and more. I use commit hooks to run these tests on every commit. The tests along with the reviewer agent help ensure that output can be trusted.
Pull Requests are ripe for innovation, for many teams it's the final frontier where there's still a human bottleneck. I wrote a post about 5 solutions to AI driven Pull Request load and stacked PRs was one of them. The PRs are stacked with each PR built onto the one before, and GitHub allows you to visualize it as follows.

Our team is still new to stacked PRs but so far I'm finding them very promising. It lets me do all the work upfront, and then I can babysit the stack from there. I have each PR starting out as a draft so that I can do the first reviews and mark each one as ready. If a change is requested, I just make the change to the specific PR, and then I ask claude to rebase all the PRs on top of it. Once approved, the PRs can be merged independently, and then we're done!
And that's my workflow! There's a lot of design decisions upfront, but it feels great to see the code "one-shotted", and the reduced iterations in the implementation phase is definitely a time saver overall. I built this feature over the course of a weekend, and it could have easily taken me several weeks with the previous approach.
In the future I'd like to checkout Matt's Retro skill to review my sessions and see if they're being inefficient. I'm also interested to learn more about Lauren 'poteto' Tan's skills and see how those can enhance my workflow further.