| name | pi-package |
| description | Pi package development best practices and patterns. Use when planning, editing, implementing, or reviewing pi package code — structuring a new package, writing extensions, registering tools, commands, events, skills, prompt templates, or themes. Also use when the user asks about package architecture, conventions, or "how should I implement" a pi package feature. Do not use for general TypeScript development unrelated to pi packages, or for running tests (use pi-test skill if it exists).
|
Pi Package Development
This skill provides patterns and best practices for building pi packages.
Read the reference files below on demand based on the current task.
Official Pi Documentation
For the complete and authoritative API reference, read pi's installed docs.
Locate them with:
npm root -g
Key documents (relative to that directory):
| Doc | Contents |
|---|
extensions.md | Full extension API: events, tools, commands, providers, rendering |
tui.md | TUI component API for custom UI |
skills.md | Skill authoring and the Agent Skills standard |
themes.md | Theme format and all color tokens |
keybindings.md | Keybinding IDs and shortcut registration |
packages.md | Package distribution and manifest |
session-format.md | SessionManager API and entry types |
compaction.md | Custom compaction handlers |
custom-provider.md | Advanced provider topics, OAuth, custom streaming |
models.md | Model configuration |
rpc.md | RPC mode and extension UI protocol |
When in doubt about an API, read the official doc first — it is the source of truth.
Reference Files
Read these on demand based on the task. Do NOT load all at once.
Each file has a table of contents at the top for navigation.
references/EXTENSIONS.md
Complete patterns for every extension capability.
- Extension Structure & Factory
- Custom Tools (registration, rendering, state, truncation)
- Slash Commands (registration, autocomplete, argument handling)
- Event Handlers (lifecycle, session, agent, tool, input events)
- User Interaction (dialogs, notifications, status, widgets)
- Custom UI Components (TUI, overlay, custom editor)
- State Management (session persistence, reconstruction)
- Custom Rendering (tool call/result, message renderers)
- Remote Execution (SSH, tool operations)
- Providers (custom models, OAuth)
- Anti-Patterns
references/SCHEMAS.md
Typebox schema patterns for tool parameters.
- Quick Start (minimum schemas every tool needs)
- Primitive Types
- String Enums (Google-compatible)
- Object & Nested Schemas
- Arrays & Tuples
- Optional Fields & Defaults
- Description Best Practices
- Reusable Sub-schemas
- Empty Parameters
- Common Parameter Patterns (paths, file patterns, modes)
references/THEMES.md
Theme creation reference with all 51 color tokens.
- Theme Structure (vars, colors, schema)
- Color Tokens Reference (core UI, backgrounds, markdown, diffs, syntax, thinking)
- Color Values (hex, 256-color, variables, default)
- Theme Creation Workflow
- Testing Themes
references/SKILLS.md
Skill authoring patterns for the Agent Skills standard.
- Skill Structure (SKILL.md, references, scripts, assets)
- Frontmatter (name, description, allowed-tools, disable-model-invocation)
- Progressive Disclosure Pattern
- Skill Naming & Triggering
- Reference File Organization
- Skills in Packages
references/PROMPTS.md
Prompt template authoring.
- Prompt Template Format (frontmatter, content)
- Template Variables
- Prompt Placement & Discovery
Working with existing packages
When modifying an existing package:
- Read the existing code first — match the project's conventions
- Check
AGENTS.md for project-specific rules
- Read
package.json to understand the pi manifest and dependencies
- Look at existing extensions/skills to match patterns
File locations in this project
- Extension source:
extensions/index.ts
- Skills:
skills/
- Prompt templates:
prompts/
- Themes:
themes/
- Package manifest:
package.json