A comprehensive, progressive learning guide for creating Pi coding agent extensions.
This is a Skill (Markdown documentation) that teaches you how to build Extensions (TypeScript code).
| Concept | Location | Purpose |
|---|---|---|
| Skill (this) | skills/ |
Markdown docs that tell Pi "how to do X" |
| Extension | extensions/ |
TypeScript code that runs at runtime |
# Install this skill to Pi's skills directory
git clone https://github.com/dwsy/pi-extensions-skill.git \
~/.pi/agent/skills/pi-extensions
# Or copy to project-level skills
cp -r ~/.pi/agent/skills/pi-extensions /path/to/project/.pi/skills/Pi auto-discovers skills. Once installed, it loads this skill when you mention "extension development".
| Level | Document | Description |
|---|---|---|
| 🌱 Beginner | Quickstart | First extension in 5 minutes |
| 🌿 Intermediate | Core Paradigms | Tools, Commands, Events, UI |
| 🌳 Advanced | State Management | Persistent and cross-session state |
| 🏔️ Expert | Production Patterns | Multi-mode, workflows, memory systems |
| 📚 Reference | API Reference | Complete API documentation |
| 🧩 Examples | Real Extensions | Annotated production code |
Pi extensions are TypeScript modules that hook into the Pi coding agent lifecycle:
- Tools: Let the LLM call custom functions
- Commands: User-triggered actions via
/command - Event Handlers: React to and intercept system events
- Custom UI: Build interactive terminal interfaces
Extensions you create go here (different from this skill!):
~/.pi/agent/extensions/ ← Global extensions (available to all projects)
.pi/extensions/ ← Project extensions (local to project)
Note: This creates an Extension, not a Skill. They are separate things.
# 1. Create the extension file
mkdir -p ~/.pi/agent/extensions
cat > ~/.pi/agent/extensions/hello.ts << 'EOF'
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export default function (pi: ExtensionAPI) {
pi.registerCommand("hello", {
description: "Say hello",
handler: async (_args, ctx) => {
ctx.ui.notify("Hello from Pi Extensions!", "success");
},
});
}
EOF
# 2. Test it (use -e for temporary load, or just restart Pi)
pi -e ~/.pi/agent/extensions/hello.ts
# Then type: /hellopi-extensions-skill/
├── SKILL.md # Skill entry point (this enables the skill)
├── README.md # This file
├── ARCHITECTURE.md # Extension architecture (required reading)
├── PATTERNS.md # 24 copy-paste patterns
├── ANTI-PATTERNS.md # 15 common mistakes with fixes
├── guides/
│ ├── 01-quickstart.md # Beginner tutorial
│ ├── 02-paradigms.md # Core paradigms
│ ├── 03-state.md # State management
│ ├── 04-production.md # Production architecture
│ └── ... # More guides
└── references/
└── api.md # API reference
From pi-interactive-shell: Managing subprocesses with interactive/hands-free/dispatch modes.
From pi-subagents: Chain and parallel execution with template variables.
From plan-mode: Strict mode isolation with progressive permission release.
From role-persona: Automated extraction, tagging, and contextual retrieval.
This skill is extracted from real production extensions. Contributions welcome:
- Add new patterns from your extensions
- Improve examples
- Fix bugs or clarify documentation
See CONTRIBUTING.md for details.
Patterns derived from studying these production extensions:
MIT © dwsy
The journey of a thousand miles begins with a single step. — Laozi