pi-reread-instructions
v0.1.0
Published
Pi extension that re-inserts AGENTS.md / CLAUDE.md every N completed final assistant replies
Maintainers
Readme
pi-reread-instructions
Pi extension package that re-inserts AGENTS.md / CLAUDE.md into context every N completed final assistant replies.
Why
This was inspired by recent Claude Code leak analysis suggesting that CLAUDE.md is re-included during prompt assembly:
If that helps Claude Code stay anchored to project instructions, it may be useful for pi too.
Behavior
- Default interval:
3 - Configurable via
PI_AGENTS_REREAD_EVERY - Counts only assistant messages with
stopReason: "stop" - Tool-use substeps do not increment the counter
- Reinsertion happens after the matching final assistant reply and before the next user message
- Searches for context files in:
~/.pi/agent/AGENTS.mdorCLAUDE.md- the current project and its ancestor directories
- Writes proof markers into the session JSONL as custom entries:
agents-reread-deliveryagents-reread-payload-proof
- Appends a hidden custom message of type
agents-reread-contextwhen it injects a refresh
Install
If you want to install from the public GitHub repo:
pi install git:github.com/rawwerks/pi-reread-instructionsIf you want to install from npm after the package is published:
pi install npm:pi-reread-instructionsFor a local checkout during development:
pi install /absolute/path/to/pi-reread-instructionsIf you want a direct editable symlink instead of a package install:
cd /path/to/pi-reread-instructions
./install.shThat creates this symlink:
~/.pi/agent/extensions/agents-reread.ts -> /path/to/pi-reread-instructions/agents-reread.tsConfiguration
Set the default interval with an environment variable:
export PI_AGENTS_REREAD_EVERY=3The extension also accepts AGENTS_REREAD_EVERY as a fallback.
Set it to any positive integer. 0 or a negative number disables the refresh.
Slash command
The extension registers:
/agents-reread
/agents-reread status
/agents-reread off
/agents-reread default
/agents-reread <positive-integer>Notes:
/agents-rereadwithout args shows status/agents-reread <positive-integer>changes the interval for the current session/agents-reread offdisables refreshes for the current session/agents-reread defaultresets the current session back to the env/default interval
Session-log proof
When a refresh is injected, the extension records custom entries in the session JSONL. You can inspect them with:
rg -n 'agents-reread-(delivery|payload-proof)|agents-reread-context' ~/.pi/agent/sessionsNotes
- This repo is intentionally standalone and uses only Node built-ins.
- The extension does not require editing or vendoring pi upstream.
- The package exposes the extension through the
pimanifest inpackage.json. - Maintainer workflow lives in DEVELOPING.md.
