pi-snippets
v1.0.3
Published
Zero-keystroke snippet auto-expander for pi — type a trigger word and it expands
Maintainers
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-snippetsGetting 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 : [email protected]
/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)
- Project (
.pi/snippets.json, trusted projects only) — highest priority - User global (
~/.pi/agent/snippets.json) - 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
siginsidedesignwon't trigger expansion becausesigis 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
