pi-snippets

Zero-keystroke snippet auto-expander for pi — type a trigger word and it expands

Packages

Package details

extension

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

$ pi install npm:pi-snippets
Package
pi-snippets
Version
1.0.3
Published
Jul 4, 2026
Downloads
609/mo · 24/wk
Author
raunak07
License
MIT
Types
extension
Size
17.3 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions"
  ]
}

Security note

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

README

Pi Snippets

Zero-keystroke snippet auto-expander for pi.

Type a trigger word and it instantly expands on the last keystroke — no delimiter, no confirmation needed. Just natural typing flow.

Quick Start

pi install npm:pi-snippets

Getting Started

No snippets are bundled. You start with a blank slate and add exactly what you need.

Adding Snippets

Using /add (recommended)

Add snippets directly from inside pi — no file editing, no /reload:

/add eml : user@example.com
/add lgtm : Looks good to me! 👍
/add sum : Summarize the following:

Remove snippets with the interactive /remove command — a TUI picker lets you check off which ones to delete.

The snippet takes effect instantly — start typing the trigger immediately. Saved to ~/.pi/agent/snippets.json so it persists across sessions.

Editing the file directly

You can also edit ~/.pi/agent/snippets.json directly:

{
  "sig": "Best regards,\nJane Doe",
  "sum": "Summarize the following:\n\n",
  "lgtm": "Looks good to me! 👍"
}

Then /reload inside pi (or restart).

Project-level (shared with your team)

Create .pi/snippets.json in your project root and commit it to git. Project snippets only load when the project is trusted.

Priority (later sources override earlier ones)

  1. Project (.pi/snippets.json, trusted projects only) — highest priority
  2. User global (~/.pi/agent/snippets.json)
  3. Bundled defaults (shipped with this package) — lowest priority (fallback)

How It Works

The extension replaces pi's input editor with a custom editor that intercepts every keystroke. As soon as you finish typing a trigger word, it expands instantly — the last character of the trigger itself fires the expansion.

  • Instant expansion: No delimiter required — the moment you type the final character of a trigger word, it expands to your defined text.
  • Word-boundary safe: The trigger must be a complete whitespace-delimited token (or at the very start of input). Typing sig inside design won't trigger expansion because sig is not at a word boundary.
  • Compatible: Works alongside other extensions. Wraps any existing custom editor via getEditorComponent() to preserve composability.

Trigger Guidelines

Choose triggers that are not common English words or prefixes of other triggers to avoid accidental or premature expansion:

  • sig, tpl, dbg — abbreviation-like, unlikely to be typed by accident
  • ⚠️ fix, todo, bug — common words that might trigger mid-sentence
  • ⚠️ db / dbg — overlapping prefixes can cause the shorter trigger to fire early
  • a, i, q — single-letter triggers are very prone to false positives

Multi-character, abbreviation-style triggers work best. Avoid triggers that are prefixes of each other.

License

MIT