Matt Pocock

내 AFK 소프트웨어 공장을 오픈소스로 — 샌드박스 에이전트 오케스트레이션 라이브러리 Sandcastle

Matt Pocock

Matt Pocock이 6개월간 굴려온 AFK 에이전트 셋업을 Sandcastle이라는 TypeScript 라이브러리로 오픈소스 공개. Yolo mode의 위험 대신 샌드박스 격리·GitHub issues 백로그·planner→implementer→reviewer→merger 파이프라인으로 병렬 에이전트가 무인으로 일하게 만든다. agent-agnostic 설계·마크다운 프롬프트·Claude Skills에서 가져온 ! 백틱 문법·'it's just code'라는 결론까지.

I Open-Sourced My Own AFK Software Factory

생각 덩어리

6개월의 목표 — 백로그·기능·QA를 병렬로 처리하는 totally AFK 에이전트

One of my goals for the last 6 months have been trying to get my agents, my coding agents to run totally AFK. These AFK agents have been picking up backlog tasks, have been implementing features for me, have been doing QA, and crucially they have been running in parallel.

A question that you probably have right now is how do I get my agent to run without it constantly battering me with requests for permissions.

Yolo mode의 함정 — 홈 디렉토리 삭제와 데이터 유출, 답은 샌드박스

You could just go into Yolo mode and have it totally bypass any permissions requests. But, if you do that, Claude will do mad things on your system like delete your home directory.

Or, if you're in an enterprise setup, then it might be concerned about, you know, it exfiltrating data or sending your code off to a random third party. So, in order to get agents to run properly AFK, you need them to be sandboxed.

도구 쇼핑의 실패 — 원한 건 "이 샌드박스에서 이 에이전트로 이 프롬프트를" 함수 하나

The one I really tried to use and try to make work was Docker sandboxes. However, there were just so many problems with running it AFK that I won't bore you with now.

What I wanted was a simple TypeScript function that I could run and just say, "Run this prompt inside this sandbox using this agent." And all the tools that I found were trying to sell me some third party service. So, I realized I needed to build something here. And that thing is Sandcastle, a TypeScript library for orchestrating AI coding agents in isolated sandboxes.

With this simple function, you can build really, really complex systems. You can build systems that parallelize agents running side by side. You can have systems that review their own code and then merge it in.

셋업 — Docker 컨테이너 안에 뭐든 설치, 백로그는 GitHub issues

Sandcastle also uses a backlog manager because AFK agents need some way of picking up tickets and knowing what to do next. My preferred way of doing this is GitHub issues.

Since we've chosen GitHub issues, we're going to create a Sandcastle GitHub label. The issues will be filtered by this label and it means that only things with the Sandcastle label on our GitHub issue list will be picked up by the agents.

Sandcastle runs inside this Docker container and it means that you can just install anything you like inside here. We're installing some important system dependencies. We're installing the GitHub CLI. ... We're installing Claude code and then we're just ready to go.

If you want to use your Claude subscription instead of an API key, then you can head to this issue here that will tell you more about it. If you don't know, Anthropic is a little bit funny about people using their subscription for these kind of things, and so there's some up-to-date advice there.

첫 가동 — issue 하나가 planner와 implementer를 깨운다

Let's say, "Scaffold me a basic TypeScript template in the repo. Give me a basic TypeScript application that uses Vitest, that uses type checking, that has a very very simple CLI that I can call. Use Commander for the CLI. Add a CI script that does type checking and runs the tests."

We can see immediately that it's kicked off a planner agent here, and we can control-click these logs to see what it's up to. We can see that it's successfully set up the sandbox. ... It then spits out this plan here, which is a set of issues which are going to be worked on.

I've even got it prompted so it's doing a little bit of red green refactor here where it's writing the test first ... we can sit and watch this if we want to or, you know, we can go and have a cup of tea, we can relax and this will just do its work without us.

main.mts 해부 — agent-agnostic, 템플릿은 처방이 아니다

We have a sandcastle.run command that takes in a name of planner. It takes in an agent here so we can just change this if we want to. If we want to do planning with Codex, let's say, instead of Claude code, we totally can.

This one is taking all of the open issues from the repo that have the label sandcastle. ... And then it's working out which ones can be done right now. So it's only looking for unblocked issues here.

Again, all of this is just a setup that I cooked up, really. This is not Sandcastle giving you any kind of prescription on how you want to run it. This is just a really cool workflow that I tend to use in my repos, so I figured it belonged in a template.

implementer 뒤의 reviewer — 실수는 리뷰어가 잡고, 프롬프트 문법은 Claude Skills에서 훔쳤다

If there are more than one commits here, we then run a reviewer. This pattern has been incredibly powerful because the implementer can make mistakes, but the reviewer generally picks it up.

If you want to have multiple different agents spawn at the same time, come up with an implementation, and then some other reviewer takes all of those branches, chooses the best one, or makes a like a mix of them, you can. That's the power of having a totally agnostic setup to what agent you're running. That's the power of ... owning your own process.

This is something I copied from Claude Skills, where if you specify an exclamation mark before a bunch of backticks here, it will run this when it's resolving the prompt. And so it will actually execute git diff source branch branch here.

It's a great step for like adding your own project standards. So for instance, I've added this coding standards in here that you can fill in with any project standards that you want to be added.

merger agent — 머지 컨플릭트는 시니어 머저 개발자에게

The reason we use an agent for this is that there might be merge conflicts between them. And I usually like to have a really powerful agent handling those merge conflicts for me because they can sometimes be pretty gnarly.

At the end of this, we have had multiple agents running at the same time, all committing to their branches, and then we get a like a senior merger developer to pull them back into main. Just this setup has massively increased my velocity, and it works super duper well.

It's just code — 워크플로우가 미니 소프트웨어 공장이 된다

You can build these relatively complicated flows using really nice ergonomic markdown prompts. You can get it to run on different branches, and just merge that back into main, or you can get it to do really nice PR flows as well. You know, it's just code. It is a programmatic way to run Claude code, to run Codex, and to build these workflows that turn into these mini software factories.

I think it's going to be a really nice contribution to the ecosystem, and I've been loving using it.

YouTube 원본 →원본 사이트 →