Building a Regex Engine with a team of parallel Claudes
Inspired by Nicholas Carlini’s C compiler agent team experiment.
TL;DR
I tasked two Opus 4.6 agents to build a regex engine, then walked away. Here is the repo.
Over 14 Claude Code sessions, the agent team wrote ~1700 lines of code, and now I have a working Rust regex engine:
kian@Kian regex % cargo run -- "a+b*" "xxaaabbbzz"
Compiling regex-engine v0.1.0 (/Users/kian/Developer/regex)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.06s
Running `target/debug/regex-engine 'a+b*' xxaaabbbzz`
MATCH:aaabbb
Setup
This experiment required three separate pieces:
-
A remote which the agents could push to and build their work
-
A server for running the agents on the cloned remote (the original experiment uses Docker containers; I do not)
-
A third directory (which is my main contribution) called regex that with the harnessing not provided by the original post, namely:
- AGENT_PROMPT.md
- launch_agents.sh
- agent_loop.sh
Workflow
I ran two agents in parallel with a loop script.
Each agent loop does:
- Clone the repo into
workspace-<agent_id>if not already. git pull --rebase origin main.- Run Claude on yolo mode with the shared prompt.
- Append session output to per-agent log files.
- Sleep briefly and repeat.
Coordination primitives in the repo:
current_tasks/for lock files (task claiming)notes/for handoffs and caveatsPROGRESS.mdfor shared status updates
Analysis
Where the real work happened
The implementation progress came from a small number of successful sessions:
- bootstrap to 37/38 tests
- harness fix and edge tests to 54/54
- optimization and robustness to 69/69
- hardening and expanded coverage to 159/159
Session count is not commit count
- some sessions produced lock-only commits
- some sessions produced multiple commits
- some sessions produced no commit
Coordination
- The lock-file mechanism using
current_tasks/was generally effective, but there were a few cases where stale locks required cleanup.
Two things that helped
- using oracle-based testing against the Python
relibrary - preserving modular boundaries (parser → abstract syntax tree → compiler → virtual machine)
Replication
If you would like to replicate these results, it suffices to:
git clone git@github.com:kiankyars/parallel-ralph.git
mv parallel-ralph/regex .
# rm -rf parallel-ralph
chmod 700 regex/*.sh
./regex/launch_agents.sh 2
The above assumes you have the Claude Code CLI installed on your machine, along with screen and a few other standard Linux packages.
Future Work
Today I am building SQLite from scratch, but this time I’m going to use both Codex and Claude on the same project to see how heterogeneous agents interact with each other. I considered using a lock TTL (time to live) and automatic stale-lock cleanup to prevent agents from being blocked by abandoned lock files.
Multi-agent
I’m thinking of having specialized agent roles as well. Here is what Carlini did:
I tasked one agent with coalescing any duplicate code it found. I put another in charge of improving the performance of the compiler itself, and a third I made responsible for outputting efficient compiled code. I asked another agent to critique the design of the project from the perspective of a Rust developer, and make structural changes to the project to improve the overall code quality, and another to work on documentation.
Appendix
Code size
- Counted files: 6 (
.rs+.sh) - Total lines: 1,680
- Approx. code lines (non-blank, non-comment): 1,331
- Rust: 1,328 total / 1,091 code lines
- Shell: 352 total / 240 code lines
Agent sessions
- Total logged sessions: 1,273
- Agent 1 sessions: 519
- Agent 2 sessions: 754
- Rate-limit-only sessions: 1,259
- Non-rate-limited sessions: 14
Model usage snapshot
- Tokens: In 9.4k / Out 6.5k
- Used ~30% of my Claude Pro weekly limit
Notes on the Anthropic approach
- For context, this is the initial commit on the Anthropic repo, and this is the first page of commits.
Citation
@misc{kyars2026regex,
author = {Kian Kyars},
title = {Building a Regex Engine with a team of parallel Claudes},
year = {2026},
month = feb,
day = {10},
howpublished = {\url{https://kiankyars.github.io/machine_learning/2026/02/10/regex.html}},
note = {Blog post}
}