pi-prompt-lens

A quiet prompt review sidecar for pi: highlights prompt gaps and suggests an actionable rewrite after the agent finishes answering.

Packages

Package details

extension

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

$ pi install npm:pi-prompt-lens
Package
pi-prompt-lens
Version
0.1.0
Published
Sep 18, 2026
Downloads
188/mo · 15/wk
Author
xtnntn
License
MIT
Types
extension
Size
33.9 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./prompt-lens.ts"
  ]
}

Security note

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

README

pi-prompt-lens


What is Pi Prompt Lens?

When asking coding assistants to solve problems, small omissions in prompt scope, context, or validation criteria often lead to wasted round-trips.

Pi Prompt Lens watches your prompt while the agent works. Once the response finishes settling, it displays a Prompt Lens widget above the editor with 1–3 concrete gaps in your request and a structured rewrite.

  • Zero Blocking: Your message is sent to the agent immediately. The review evaluates concurrently.
  • Context-Isolated: Review widgets exist only in the terminal UI; they are never sent back to the LLM, avoiding context bloat.
  • Noise-Free: If your prompt was already clear, specific, and bounded, no widget is shown.
  • Language Aware: Explanations and rewrites match the language you typed in.

Installation

pi install npm:pi-prompt-lens

Or install from git:

pi install git:github.com/xtnntn/pi-prompt-lens

For local development or testing:

git clone https://github.com/xtnntn/pi-prompt-lens.git
ln -s "$(pwd)/pi-prompt-lens" ~/.pi/agent/extensions/pi-prompt-lens

How It Works

  1. Send an instruction to the coding agent as usual:

    refactor the database query
  2. The agent executes your task immediately.

  3. When the agent finishes, a widget appears above the editor:

    🔎 Prompt Lens
    
    [SCOPE] Unbounded query target
    - Issue: Does not state which query, file, or table needs refactoring.
    - Suggestion: Specify the database function name and target table.
    
    [VALIDATION] Missing acceptance criteria
    - Issue: The agent cannot know if performance, readability, or typing is the goal.
    - Suggestion: State the optimization goal (e.g. index usage, query latency, or clean types).
    
    ---
    Suggested Rewrite:
    > Refactor the getUserOrders query in src/db/orders.ts to optimize latency and add index hints. Ensure existing tests pass.
  4. If your prompt is already clear and specific, Prompt Lens quietly skips rendering.

Commands & Settings

Type /lens to open the interactive settings menu, or configure directly:

Command Action
/lens Interactive TUI settings menu
/lens on Enable background prompt reviews
/lens off Disable background prompt reviews
/lens model Interactive model picker for reviews
/lens model <provider/id> Set a dedicated model for reviews (e.g. anthropic/claude-3-5-haiku)
/lens model default Follow the active session model

Settings persist in ~/.pi/agent/prompt-lens.json.

Principles

  1. Independent Evaluation: Reviews inspect only your prompt—never the assistant's output and never past conversation history.
  2. Never Waste Agent Time: The review runs parallel to the agent and settles after the response is rendered.
  3. Keep Chat History Clean: Review widgets live strictly in the terminal UI and do not cost tokens in subsequent turns.

Development

npm install
npm run check      # typecheck (tsc --noEmit)
npm test           # unit tests (vitest)
npm run lint       # oxlint
npm run fmt:check  # formatting check

License

MIT © 2026 xtnntn