A 40,000‑line pull request sounds like a nightmare, but Kyle Mistele shows a smarter way.
He borrows a control‑theory loop to make AI agents act incrementally.
The Simple Version
Think of a thermostat that constantly checks temperature, decides a small adjustment, and checks again.
In coding, a loop does the same: sense a piece, decide a tiny change, apply it, and repeat.
How It Actually Works
Sensor
In code, a sensor is often a Grep or structural search that finds the smallest unmigrated function.
Controller
The controller picks the next target based on priority and keeps only one change open at a time.
Actuator
An actuator agent applies the change against hand‑written golden patterns, then commits the PR.
Technical Deep Dive
The loop records each PR in Git, blocks new changes until the previous one merges, and runs a single CI job in CircleCI to validate the diff.
CI Integration
A deterministic CI pipeline runs after each actuator step, rejecting the change if tests fail, so only verified updates proceed.
Version‑Control Tracking
The system creates a dedicated branch per iteration, tags the PR, and uses branch protection to prevent stacking.
Golden Patterns
Patterns are stored as reusable snippets or tests that the actuator must match before applying a migration.
Why This Matters
Incremental loops prevent the ‘black‑box’ PR problem, letting teams trust each step and roll back easily.
It also scales AI agents across teams, because each iteration is small enough to be reviewed by anyone.
Key Takeaways
- Design loops that sense, decide, and act in tiny steps.
- Use a sensor like Grep to find the smallest target.
- Let a controller sequence changes and block stacking.
- Apply changes via an actuator that follows golden patterns.
- Tie each iteration to CI for automatic verification.
- Track PRs in version control to keep a clear history.
- Scale the approach by repeating the loop across codebases.