Pi Extension Development
Build production-grade customization for @mariozechner/pi-coding-agent without forking core internals.
This skill is organized for progressive disclosure:
- This file: execution workflow
references/: detailed technical guidancetemplates/: copy-paste starter files
When to use this skill
Use this skill when you need to:
- Build or modify an extension (tools, commands, events, UI, provider integrations)
- Configure resource loading (
settings.json, discovery paths, package sources) - Package and distribute reusable resources as a pi package (npm/git/local)
- Validate extension behavior across interactive, print, json, and rpc modes
- Update extension docs/skills after pi version changes
Quick workflow
-
Scope the request
- Identify target resource type(s): extension / skill / prompt / theme / package / settings
- Identify runtime mode(s): interactive, print, json, rpc
-
Pick implementation shape
- Small logic: single
*.tsextension file - Multi-module logic: extension directory with
index.ts - Team sharing: pi package with
pimanifest inpackage.json
Model selection policy: see
references/01-extension-api-cheatsheet.md(subagent model policy section). - Small logic: single
-
Implement safely
- Add tool output truncation
- Add guardrails for destructive operations (
tool_callgate) - Ensure non-interactive compatibility (
ctx.hasUIchecks)
-
Configure loading
- Wire
.pi/settings.json(project) and/or~/.pi/agent/settings.json(global) - Verify resource discovery and
/reloadbehavior
- Wire
-
Validate behavior
- Manual smoke checks for command/tool/event/UI paths
- Validate mode-specific behavior
- Check conflicts (tool/command/flag name collisions)
-
Package and publish (if needed)
- Add
keywords: ["pi-package"]andpimanifest - Validate dependency model (peerDependencies vs bundled dependencies)
- Install/test via
pi installandpi update
- Add
-
Record maintenance metadata
- Update skill/version notes
- Add or update migration guidance
Mandatory references to load
For any non-trivial task, read these first:
references/01-extension-api-cheatsheet.mdreferences/02-settings-and-loading.mdreferences/03-packaging-and-distribution.mdreferences/04-testing-and-debugging.mdreferences/05-skill-maintenance-playbook.mdreferences/06-provider-integrations.mdreferences/07-themes-prompts-skills.md
If task is extension-heavy, also read:
references/08-extensions-deep-dive.md
If task is package-heavy, also read:
references/09-packages-reference.md
If task is config-heavy, also read:
references/10-settings-reference.md
Execution policy
- Prefer extension APIs over patching pi core.
- Keep tool outputs bounded and informative.
- Never assume UI methods are available in non-interactive modes.
- Keep keybindings configurable (no hardcoded key checks).
- For path/tool policy enforcement, block in
tool_calland explain the reason.
Response contract
When delivering work, always provide:
- What changed (files + purpose)
- How to load/run it
- Validation results
- Known limitations / follow-ups
- If relevant: migration notes for existing setups
Fast start templates
Use these starter files:
templates/extension.index.tstemplates/extension.tool.tstemplates/extension.command.tstemplates/settings.project.jsontemplates/package.jsontemplates/prompt.mdtemplates/theme.json
Troubleshooting
- Extension not loading? Check path, run
/reload, check startup diagnostics. - Tool not appearing in system prompt? Add
promptSnippetto tool definition. - File mutation race conditions? Use
withFileMutationQueue()for file-modifying tools. getApiKey()errors? UsegetApiKeyAndHeaders()instead (removed in v0.63.0).session_switch/session_forkerrors? Usesession_startwithevent.reason(removed in v0.65.0).- UI crashes in print/json mode? Guard with
ctx.hasUIbefore allctx.ui.*calls.
Version History
- v3.0.0 (2026-04-04): Synced to pi v0.65.0. Removed
session_switch,session_fork,session_directoryevents. UpdatedgetApiKey()togetApiKeyAndHeaders(). AddeddefineTool(),withFileMutationQueue(),prepareArguments,promptSnippet/promptGuidelines,ctx.signal,resources_discoverevent,sourceInfoprovenance, namespaced keybinding ids, overlay mode,ctx.ui.setHiddenThinkingLabel(),getArgumentCompletions, gallery metadata,npmCommand/sessionDir/hideThinkingBlocksettings. Updated all references, templates, and examples catalog. - v2.1.0 (2026-03-09): Added provider/theme/prompt coverage, clarified extension events/context/tool overrides/truncation and message injection guidance, expanded settings/package discovery rules, added new templates, and refreshed debugging/update playbook references.
- v2.0.0 (2026-03-09): Rewritten in English, split into multi-file structure, expanded coverage for extension APIs, settings/resource loading, pi package distribution, mode-aware validation, and skill update playbook.
- v1.0.0 (2026-03-09): Initial single-file version.