knowledge/pi-extension-creator/SKILL.md
Create, review, package, and troubleshoot Pi coding-agent extensions and Pi packages. Use when asked to build TypeScript extensions for Pi, register tools with pi.registerTool, subscribe to pi.on lifecycle/tool/input/session events, add slash commands, custom UI/widgets/renderers, package resources through package.json pi.extensions/skills/prompts/themes, define custom subagent markdown agents/chains for pi-subagents, install via pi -e or pi install, or adapt examples such as pi-fork, pi-minimal-subagent, Hypa pi-hypa, permission gates, protected paths, subagents, command rewriters, custom providers, and dynamic resources.
npx skillsauth add aeondave/malskill pi-extension-creatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Build Pi extensions as TypeScript modules that export a default factory receiving ExtensionAPI.
Use current Pi imports for new work:
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { Type } from "typebox";
Some older public examples use @mariozechner/* or @sinclair/typebox. Preserve those only when maintaining that codebase. For new code, follow the current docs and local package conventions.
pi.registerTool.pi.registerCommand.pi.on.ctx.ui.setStatus, ctx.ui.setWidget, ctx.ui.setHeader, or ctx.ui.setFooter.renderCall, renderResult, or pi.registerMessageRenderer.package.json pi manifest..ts file for one tool, one command, or a simple event gate.index.ts plus sibling modules for stateful tools, subprocess runners, renderers, or policies.pi install.session_start, a command, a tool call, or the exact event that needs them.session_shutdown; make cleanup idempotent.ctx.hasUI before confirm/select/input/notify flows.ctx.mode === "tui" before custom TUI components or editor replacement.print, JSON, and CI usage.details when it affects future behavior.ctx.sessionManager.getBranch() on session_start.pi.appendEntry() for custom persistent entries that are not natural tool results.node --test, tsx --test, or the project toolchain.tsc --noEmit.pi -e ./path/to/index.ts.~/.pi/agent/extensions/ or .pi/extensions/, then use /reload.pi install ./package or pi -e ./package.Load references/api-surface.md when writing handler signatures, event returns, tool result shapes, UI behavior, rendering, or provider/resource integration.
Use these defaults:
| Goal | API |
|---|---|
| Add a model-callable operation | pi.registerTool({ name, label, description, parameters, execute }) |
| Block or rewrite a tool call | pi.on("tool_call", handler) |
| Modify per-turn system context | pi.on("before_agent_start", handler) or pi.on("context", handler) |
| Add /command | pi.registerCommand("name", { description, handler }) |
| Add keyboard shortcut | pi.registerShortcut("ctrl+x", { description, handler }) |
| Add CLI flag | pi.registerFlag("name", { type, default, description }) |
| Run a shell command | pi.exec("git", ["status"], { signal, timeout }) |
| Inject a user message or trigger a turn | pi.sendUserMessage(text, { deliverAs }) |
| Enable/disable tools at runtime | pi.setActiveTools(names) / pi.getAllTools() |
| Ask the user | ctx.ui.confirm, ctx.ui.select, ctx.ui.input; guard with ctx.hasUI |
| Show status or dashboard text | ctx.ui.setStatus, ctx.ui.setWidget |
| Override a built-in tool | Register a tool with the same name, then preserve expected args/rendering |
| Contribute skills/prompts/themes dynamically | pi.on("resources_discover", handler) |
| Communicate across extensions | pi.events |
| Add a provider/model source | pi.registerProvider |
description text that tells the model when to use them.StringEnum([...]) from @earendil-works/pi-ai for enum-like string parameters when Google-compatible schemas matter.isError: true; throw only when the tool execution itself should be reported as a failed tool call.signal and pass it to subprocesses, fetches, timers, and long work.onUpdate only for meaningful state changes./reload, /resume, /fork, or restart.node:path, and normalize only at module boundaries.Load references/patterns-and-examples.md when choosing structure from real examples:
pi-fork: subprocess runner, context snapshot, effort config, cost footer, custom rendering.pi-minimal-subagent: named agent discovery, simple subagent tool, config tri-state for child extensions.Hypa pi-hypa: command rewrite gate, diagnostics command, package subdirectory, external runtime dependency.Load references/advanced-redesign.md when the request says redesign, advanced theme, UI chrome, statusline, powerline footer, hide/show Pi UI, replace footer/header/editor, or combine a JSON theme with extension behavior.
Load references/custom-subagent-agents.md when the request says custom agent, subagent persona, supervisor, planner/reviewer/worker/oracle, .pi/agents, ~/.pi/agent/agents, agentOverrides, chain, fanout, fork-vs-fresh context, or packaging agents for pi-subagents.
Load references/package-and-release.md before publishing, installing, adding dependencies, or wiring a repo as a Pi package.
Minimum package manifest:
{
"name": "my-pi-extension",
"type": "module",
"keywords": ["pi-package"],
"pi": {
"extensions": ["./src/index.ts"]
}
}
Use peer dependencies for Pi-provided packages and runtime dependencies for everything your extension imports at runtime.
pi-fork, pi-minimal-subagent, and Hypa. Load when choosing a design or reviewing an existing extension.src/index.ts, package.json, tsconfig.json, and a small test.pi-subagents custom agent. Copy when creating an agent file.development
Auth/lab ref: Unicorn Engine CPU-only emulation for shellcode, decryptors, custom VM handlers, instruction tracing, memory hooks, and register-level experiments.
development
Auth/lab ref: Renode board and SoC simulation for MCU/RTOS firmware, UART/GPIO/peripheral modeling, GDB remote debugging, REPL platforms, and RESC scripts.
development
Auth/lab ref: Qiling OS-layer binary emulation for PE/ELF/Mach-O/UEFI/shellcode with rootfs, syscall/API hooks, filesystem mapping, and runtime patching.
databases
Auth/lab ref: QEMU user-mode and full-system emulation for cross-arch binaries, firmware, kernels, disks, serial consoles, networking, and GDB stubs.