pi-reread-instructions

Pi extension that re-inserts AGENTS.md / CLAUDE.md every N completed final assistant replies

Package details

extension

Install pi-reread-instructions from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-reread-instructions
Package
pi-reread-instructions
Version
0.1.0
Published
Apr 6, 2026
Downloads
155/mo · 8/wk
Author
rawwerks
License
MIT
Types
extension
Size
16.8 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./agents-reread.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

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.md or CLAUDE.md
    • the current project and its ancestor directories
  • Writes proof markers into the session JSONL as custom entries:
    • agents-reread-delivery
    • agents-reread-payload-proof
  • Appends a hidden custom message of type agents-reread-context when it injects a refresh

Install

If you want to install from the public GitHub repo:

pi install git:github.com/rawwerks/pi-reread-instructions

If you want to install from npm after the package is published:

pi install npm:pi-reread-instructions

For a local checkout during development:

pi install /absolute/path/to/pi-reread-instructions

If you want a direct editable symlink instead of a package install:

cd /path/to/pi-reread-instructions
./install.sh

That creates this symlink:

~/.pi/agent/extensions/agents-reread.ts -> /path/to/pi-reread-instructions/agents-reread.ts

Configuration

Set the default interval with an environment variable:

export PI_AGENTS_REREAD_EVERY=3

The 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-reread without args shows status
  • /agents-reread <positive-integer> changes the interval for the current session
  • /agents-reread off disables refreshes for the current session
  • /agents-reread default resets 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/sessions

Notes

  • 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 pi manifest in package.json.
  • Maintainer workflow lives in DEVELOPING.md.