diffloop is a Pi extension that slows down the agentic coding workflow on purpose by presenting each code change to the developer, with a reason attached to it.
This extension intercepts Pi edit and write tool calls and replaces the default fire-and-forget flow with an interactive review step.
For each proposed file change, diffloop:
- can require a reason (captured through
set_change_reason; optional via/diffloop-reason off) - shows a preview before execution
- lets you:
- approve the change
- steer the change with an inline prompt
- edit the proposal before execution
- deny the change
pi install npm:@lpirito/pi-diffloopWhen working with coding agents, I kept running into two extremes:
- I write a long markdown file full of rules, conventions, and constraints, hoping the agent will stay aligned.
- I prompt for a bugfix or feature and wait for the result, only to receive a large batch of changes all at once.
Both approaches can work, but they often come with the same problem: context loss.
The agent may go further than expected, touch more files than intended, or make reasonable local decisions that drift away from what you had in mind. By the time it returns, you are no longer reviewing a small decision, you are reconstructing a chain of reasoning that is not your own.
That is the problem diffloop is "meant" to solve.
It intentionally slows the workflow down so you can stay close to the agents decisions, review changes as they are proposed, and understand both what is changing and why before the change is applied.
diffloop is still an experiment for me, and Im grateful to Pi for providing such solid tools to explore ideas like this.
That said, constant review can become its own kind of fatigue. If every step requires approval, there is always the risk of falling into the habit of pressing "Accept" without really reviewing the change.
Im still exploring whether this kind of intentional slowness has a real place in agentic coding workflows, especially for developers who want to stay close to the code without losing context.
Ideas, feedback, and criticism are all welcome 😁
When the agent proposes an edit or write:
- diffloop intercepts the tool call
- it builds a preview of the change
- it opens a review UI
- you choose one of the available actions
diffloop supports configuration via a global config file and a module-level fallback.
| Location | Path | Purpose |
|---|---|---|
| Global | ~/.pi/agent/extensions/diffloop-config.json |
User-wide defaults (applied first) |
| Module | diffloop-config.json next to the installed package |
Overrides global config |
Global config is loaded first, then module config is shallow-merged on top (module wins for any key it contains). The reviewScope key is replaced entirely if both files define it. If neither file exists, diffloop uses its built-in defaults.
| Key | Type | Default | Description |
|---|---|---|---|
enabled |
boolean |
true |
Whether review is enabled |
requireReason |
boolean |
true |
Whether the agent must call set_change_reason before each edit/write |
diffViewMode |
"split" or "inline" |
"split" |
How the diff preview is rendered |
reviewScope |
object |
{} |
Scope review to specific files/patterns |
When present, reviewScope controls which files are reviewed:
{
"enabled": true,
"requireReason": false,
"diffViewMode": "inline",
"reviewScope": {
"includePatterns": ["*.ts", "*.tsx"],
"excludePatterns": ["**/*.snap"],
"includeExtensions": [".ts", ".tsx"],
"excludeExtensions": [".lock"]
}
}Out-of-scope paths bypass diffloop review and run through Pi's normal tool execution.
This extension does not re-register the edit and write tools.
Instead, it registers a small helper tool called set_change_reason and prompts the agent to call it before each edit/write proposal.
It pushes the agent to provide reasons that are:
- specific
- grounded in existing code or repository patterns
- explicit about behavior impact
- not generic prose
/diffloop off
/diffloop on
/diffloop toggle
/diffloop status
/diffloop-reason off
/diffloop-reason on
/diffloop-reason toggle
/diffloop-reason status
/diffloop-reason controls whether the agent must call set_change_reason before each edit/write. It defaults to on. Turn it off when using local models that struggle with the extra tool step.
npm install
npm run build
npm run typecheck