explaingit

jejay/pi-for-each

Analysis updated 2026-05-18

15TypeScriptAudience · vibe coderComplexity · 2/5LicenseSetup · easy

TLDR

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.

Mindmap

A visual breakdown will appear here once this repo is fully enriched.

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run the same rewrite instruction across every subfolder in a directory, one at a time.

USE CASE 2

Apply one instruction to every line of a file, such as processing a list of items.

USE CASE 3

Keep each repeated AI run in its own conversation to avoid context drift over a long loop.

USE CASE 4

Automate a repetitive editing task without writing a custom script or agent.

What is it built with?

TypeScript

How does it compare?

jejay/pi-for-eachaestheticsuraj234/chai-gpt-buildalexvilelabah/age-of-ai
Stars151515
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyeasymoderate
Complexity2/52/54/5
Audiencevibe coderdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Requires the pi coding assistant already set up, since this is an extension for it.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

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.

Copy-paste prompts

Prompt 1
Install pi-for-each and show me how to run /for with a $each@ directory token.
Prompt 2
Use pi-for-each to reword every skill file inside ./skills/ and make each one more polite.
Prompt 3
Explain how pi-for-each's line iteration mode works when I point $each@ at a file instead of a folder.
Prompt 4
Walk me through trying pi-for-each without installing it, running it from a cloned copy.
Prompt 5
How does pi-for-each keep each loop iteration's context separate from the others?

Frequently asked questions

What is pi-for-each?

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.

What language is pi-for-each written in?

Mainly TypeScript. The stack also includes TypeScript.

What license does pi-for-each use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is pi-for-each to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is pi-for-each for?

Mainly vibe coder.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.