We reached the next milestone of AI coding: loops πͺ
But I would argue the naming is bad, and it doesn't sell that well π
It has not much to do with older "Ralph loops", and no manual configuration.
It's mostly a prompting "trick", that will change how you structure tasks π
History of AI coding (until today)
It was a long time ago (like a few months, maybe 1 year?) when AI was mostly okay-ish only for "smart" autosuggestions.
No major change, you write your code, sometimes the AI predicted what you were about to write.
Check "Walking your code with AI" for my first newsletter about this (8 months ago).
Then, fast as lighting, a few weeks later AI started to take over code β‘οΈ
Tweet not found
The embedded tweet could not be foundβ¦
"How to write maintainable code with AI" was the first instance of this in the newsletter.
Since then the newsletter shifted a lot into AI-related topics, as new trends came and went:
- Maintain code with AI
- Ralph loops
- Review AI code
However, all these practices relied on a shared assumption:
You know what to do and prompt an AI for it (1 or 20 at the times), the AI does it, and you review π
Well, the new "loops" iteration looks different π
Loops, aka subagents
Here is the new game:
Instead of prompting 20 AIs yourself, you prompt 1, and tell it to spawn and orchestrate the work of 20 others ποΈ
With Codex, this is a only a matter of changing your prompts (and your mental model).
How to trigger subagents
Here is my most recent concrete example of how to rewire your prompting:
I had an app working on web, and I wanted to implement it them same on mobile (Expo) π€
What I used to do was:
- Prompt the AI to scaffold the mobile project
- Prompt another AI to implement the routes
- Prompt another AI to implement the styles
Basically, I would spin up one or more AI at the time myself, each prompted by me, and manually manage parallelisms and dependencies.
This was a decent workflow, reliable, but slow π
Now the game changes:
You prompt 1 AI, plan the full migration with it, define how many subagents are needed and in which order, and let that single AI manage it all the way to the end π
How subagents look like
An single image tells all the whole story:
The mental shift:
Instead of thinking about how to manage multiple agents, teach 1 agents the plan, and let it manage the full platoon π«‘
In practice: add "spawn subagents to manage each separate part of the plan" to your prompt. Codex knows, and the AI will just do it ππΌββοΈ
Review is still on ya
This is great and all (and fun to watch ππΌββοΈ).
But code review awaits you on the other side of all those subagents π¬
But wait! Also here you may consider another huge mental shift:
Manual coding required you to gradually build the app, AI coding instead is more like a book: write the full draft, and then refine π
In my case: let the AI(s) implement the full migration, and then review and refine it (remove and refactor).
Note: not all tasks benefit from this constraint. "Loops" are just another tool, not required ππΌββοΈ
Important caveat (trap): AI is making easier to build all the projects that you didn't have time to do before.
But, if those were not priorities, probably it meant that they were not that important. Don't prompt AI all the time just for the sake of it ππΌββοΈ
See you next π
