pi-refactor-loop
Iterative refactoring pipeline for pi. Runs analyze → refactor → verify cycles with a TUI progress widget, git commit-and-push per pass, and a bundled SKILL.md guide.
Package details
Install pi-refactor-loop from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-refactor-loop- Package
pi-refactor-loop- Version
0.1.1- Published
- Mar 13, 2026
- Downloads
- 39/mo · 12/wk
- Author
- pierre-mike
- License
- MIT
- Types
- extension, skill
- Size
- 26.7 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"."
],
"skills": [
"./refactor-loop"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
♻️ Refactor Loop
Iterative refactoring pipeline for pi. Runs analyze → refactor → verify cycles with a TUI progress widget, optional git commit-and-push per completion, and a bundled skill that guides the model through each pass.
Install
pi install npm:pi-refactor-loop
What it does
Registers a /refactor command that walks you through a setup dialog, then drives the agent through up to N simplification passes on a target (file, function, module, etc.). Each pass the agent:
- Analyses the target and identifies one focused simplification
- Applies the change
- Runs your test command (if provided)
- Calls the
refactor_passtool to report results and continue
The loop stops when the agent declares the code clean (done: true) or the pass limit is reached.
Commands
| Command | Description |
|---|---|
/refactor [target] |
Start a refactoring pipeline. Prompts for target, test command, pass limit, and auto-commit if no args given |
/refactor-stop |
Stop the active pipeline immediately |
Setup dialog
On /refactor, you are prompted for:
| Prompt | Description |
|---|---|
| Target | File path, function name, or module to refactor |
| Test command | Shell command to run after each pass (e.g. bun test, pytest) — leave empty to skip |
| Max passes | 3 / 5 / 10 / 20 |
| Auto commit & push | Automatically git commit and git push when the pipeline completes |
Tool: refactor_pass
The agent calls this after each pass to report what changed.
| Parameter | Type | Description |
|---|---|---|
change |
string |
What was changed in this pass |
reason |
string |
Why this simplification improves the code |
remaining |
string |
What simplification opportunities remain (empty if done) |
done |
boolean |
true if the code is clean and no more passes are needed |
Bundled skill
The extension ships with a SKILL.md that is automatically loaded into the session. It provides detailed instructions on the analyze → refactor → verify cycle, what counts as a good simplification, and when to stop.
TUI widget
While the pipeline is active, a widget shows the current pass, target, and completed changes.