Ping Pong Pairing with Antigravity
“Loop Engineering” seems to be the nerd social media trend of the month.
“Stop prompting directly, write prompts or code that writes your prompts, and then loop over that code!”
This sounds like either programming or meta-programming to me, but sure, let’s take this loop engineering for a test drive with ping-pong pairing.
Ping-pong pairing is a technique I learned years ago to motivate myself to get through programming tasks I found undesirable or technically daunting. It is a programming technique, but it is easiest if you think of it as a game.
The rules are simple: Player One and Player Two agree on the larger task. Player One writes a minimal failing test and commits. Player Two makes the test pass, writes another failing test, and commits. Then it is Player One’s turn again. They make the failing test pass, do any necessary refactoring, and then write a failing test. You repeat those steps until both players agree the task is done.
Sounds like a loop, so let’s do some loop engineering.
Ping Pong Pairing Agent Skill
Step one was to set up the loop. I implemented my loop as an agent skill so I could use it across multiple projects. I built the agent skill with Antigravity, telling it directly that I wanted to write a new skill. Because the “game” of ping-pong pairing involves two separate people, I chose to recreate that dynamic using independent subagents. I prompted Antigravity to create the skill, directing it to use a subagent for each of the two players. I also clearly explained the “rules” of the “game” in my initial prompt.
While I often use one-shot prompts during demos, in reality, my typical workflow involves several back-and-forth steps refining the application I’m building. Writing this skill was no exception. The initial version of the skill planned out what each subagent would do on each turn ahead of time, which isn’t the spirit of the exercise. So I clarified that it shouldn’t plan everything in advance.
You can see the skill created here: GitHub. Note, this was a fun exercise and is not necessarily a recommended way to use an AI coding tool.
Testing the skill
Once I had the skill written I wanted to test it. My go-to app for learning new languages and frameworks is the game Mastermind. And a turn-based game seemed like the perfect way to test a turn-based approach to coding. I sent Antigravity off to the races with this prompt:
Use the ping-pong pairing skill to build the game mastermind. The implementation plan should contain the rules of the game, information on the tech stack, but not specific tasks for each subagent. Let each subagent determine the right thing to do next at the start of each turn based on the rules of the game and the tech stack.
I approved a few initial steps and then walked away. 10 minutes later, I came back to a working Mastermind game and this commit history:
ONE RED: Add failing test for initializing Mastermind game instance with a secret code
TWO GREEN: Implement Mastermind game initialization and getSecretCode
TWO RED: Add test for validating secret code length
ONE GREEN: Implement validation for secret code length
ONE RED: Add failing test for validating that secret code only contains valid colors
TWO GREEN: Implement validation for secret code colors
TWO RED: Failing test for game guess exact match feedback
ONE GREEN: Implement guess method for exact match feedback
ONE RED: Add test for guessing with correct colors in incorrect positions (white pegs)
TWO GREEN: Implement white pegs feedback scoring logic
TWO RED: Add failing test for remaining turns tracking
ONE GREEN: Implement turn tracking and remaining turns decrementation
ONE RED: Add failing test for guess length validation and turn tracking behavior
TWO GREEN: Implement guess length validation
TWO RED: Add failing test for guess validation with invalid colors
ONE GREEN: Implement validation for guess colors
ONE RED: Add failing test checking that the game is over and won when a guess matches the secret code exactly
TWO GREEN: Implement game over and win status tracking
TWO RED: Add failing test for guessing after game is over
ONE GREEN: Prevent guesses when game is over
ONE RED: Add failing test for guess history recording
TWO GREEN: Implement guess history tracking
TWO RED: Failing test for 10 incorrect guesses resulting in game over
ONE GREEN: Implement turn limit check for game over
Refactor: Remove unused @ts-expect-error annotations from tests
Add interactive Command Line Interface entrypoint in src/index.ts
ONE RED: Add test for secret code color normalization
TWO GREEN: Implement secret code case normalization
TWO RED: Add test for guess color normalization
ONE GREEN: Implement guess color normalization
ONE GREEN: Add duplicate matching edge case tests
The game wasn’t beautiful, and there were some clunky aspects to the UX, but that’s to be expected of a one-shot approach with such a short prompt. Especially when that one-shot prompt explicitly told the AI to ignore aspects of its default workflow, such as a planning stage, that are designed to improve the final application.
So what was the point?
The point of doing this wasn’t to build a just ok Mastermind game. The point also wasn’t to use ping-pong pairing in my regular AI-Assisted Coding workflow.
The point was to experiment with an AI-driven dev loop that required multiple subagents to act independently while passing information (e.g., failing tests) between them at key points in the cycle.
It was also a fast and amusing way for me to get more comfortable with setting up loops and subagents inside Antigravity. The next agent team I set up will definitely be more sophisticated. I want to experiment not just with multiple code-generation agents, but also with test and eval agents, security review agents, and more. There’s a lot of potential here, but sometimes the easiest way to get started is to take something familiar and do a new thing with it.
AI Usage Note: Google's image generation models were used to create the social card image for this post.