Analysis updated 2026-05-18
Run the same rewrite instruction across every subfolder in a directory, one at a time.
Apply one instruction to every line of a file, such as processing a list of items.
Keep each repeated AI run in its own conversation to avoid context drift over a long loop.
Automate a repetitive editing task without writing a custom script or agent.
| jejay/pi-for-each | aestheticsuraj234/chai-gpt-build | alexvilelabah/age-of-ai | |
|---|---|---|---|
| Stars | 15 | 15 | 15 |
| Language | TypeScript | TypeScript | TypeScript |
| Setup difficulty | easy | easy | moderate |
| Complexity | 2/5 | 2/5 | 4/5 |
| Audience | vibe coder | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Requires the pi coding assistant already set up, since this is an extension for it.
pi-for-each is an add-on for pi, a coding assistant tool, that lets you run the same instruction repeatedly over a list of files or folders, one at a time, without having to explain the loop to the AI itself. The idea is that if you already know exactly what you want repeated, you should not have to describe that repetition to the assistant in plain language and hope it follows your intent correctly. Instead, you write the loop directly. You trigger it with a new command called /for, combined with a special token that starts with a dollar sign, the word each, an at-sign, and then a file or folder path, for example $each@./skills/. If that path points to a folder, the extension runs your instruction once for every item inside that folder, such as every subfolder. If the path points to a file instead, it runs your instruction once for every line in that file. Each run happens one after another, never at the same time as another run. A useful design choice is how each repeated run is kept separate. The first run happens in your current conversation as normal, but every run after that is split off into its own new conversation file, so the assistant does not see all the previous individual instructions piling up in the same context. This is meant to avoid a problem where an AI's answers drift or degrade as a conversation grows longer and more repetitive. While the loop runs, the interface shows a small progress hint indicating which item out of the total is currently being processed. The README compares this approach to a more advanced technique called subagents, describing pi-for-each as simpler, strictly one-at-a-time rather than running things in parallel, and giving the person using it more direct control over exactly what gets repeated. It installs with a single command through pi's own package installer, or can be tried temporarily without installing by running it directly from a cloned copy of the code. It is released under the MIT license.
An add-on for the pi coding assistant that lets you repeat one instruction over every file, folder, or line in a file, one at a time, without explaining the loop to the AI.
Mainly TypeScript. The stack also includes TypeScript.
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly vibe coder.
This repo across BitVibe Labs
Verify against the repo before relying on details.