agents/dot-agents/skills/pi-extension/SKILL.md
Build or modify a Pi extension. Use this whenever the user wants a custom slash command, extension tool, lifecycle hook, context filtering, session persistence, UI prompt, model/provider integration, or anything placed in ~/.pi/agent/extensions/. This skill is especially relevant when the user says “create a pi extension”, mentions /reload, wants custom command behavior, or needs extension code that uses Pi APIs rather than app code.
npx skillsauth add nathankoerschner/dotfiles pi-extensionInstall 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 a Pi extension for: $ARGUMENTS
Implement the extension itself, not just a vague plan. Default to a working minimal extension and add complexity only when the request truly needs it.
This skill is tailored for Nat's setup and should assume:
~/.pi/agent/extensions//reloadClarify missing requirements first.
Choose the simplest viable extension shape.
.ts file for small commands, hooks, or tools.index.ts only when the extension has helper modules, assets, or npm dependencies.package.json only when dependencies are actually needed.Place the extension globally unless the user explicitly asks otherwise.
~/.pi/agent/extensions/<name>.ts~/.pi/agent/extensions/<name>/index.tsImplement, then explain how to test it.
/reload in Pi.Choose the mechanism that best matches the request:
pi.registerCommand()pi.registerTool()pi.on("input", ...)pi.on("context", ...)pi.on("before_agent_start", ...)pi.on("tool_call"), pi.on("tool_result"), or execution lifecycle eventspi.appendEntry() or custom session entries that do not participate in LLM contextctx.ui.confirm, ctx.ui.input, ctx.ui.select, or custom UI only if necessaryWhen several approaches could work, prefer the one that is:
Default to global extension paths:
~/.pi/agent/extensions/<name>.ts~/.pi/agent/extensions/<name>/index.tsFor quick experiments, Pi can also run pi -e ./path.ts, but for the user's normal workflow prefer the global extension path so /reload works naturally.
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
export default function (pi: ExtensionAPI) {
pi.registerCommand("hello", {
description: "Example command",
handler: async (args, ctx) => {
ctx.ui.notify(`Hello ${args || "world"}`, "info");
},
});
}
If the user wants something to be saved but not automatically sent back to the main agent in later turns, do not store it as a normal user/assistant message that remains in context by default.
Prefer one of these:
pi.appendEntry() for extension-owned statecontext handler that filters it out from future LLM callsBe explicit about which data is:
/something, implement a command first.If the extension should use the active Pi model or thinking level, prefer Pi APIs for the current runtime state rather than hardcoding a provider/model.
If the task requires a direct provider-level LLM call, verify the exact API shape in docs before writing code.
You do not need to re-read docs for basic command/tool/event work that is already well-covered here.
Read the docs when the request depends on less-common or easy-to-misremember APIs, especially:
streamSimpleRelevant docs:
~/.local/.npm-global/lib/node_modules/@mariozechner/pi-coding-agent/docs/extensions.md~/.local/.npm-global/lib/node_modules/@mariozechner/pi-coding-agent/docs/custom-provider.md~/.local/.npm-global/lib/node_modules/@mariozechner/pi-coding-agent/docs/tui.md~/.local/.npm-global/lib/node_modules/@mariozechner/pi-coding-agent/docs/session.mdRelevant examples:
.../examples/extensions/send-user-message.ts.../examples/extensions/input-transform.ts.../examples/extensions/dynamic-tools.ts.../examples/extensions/custom-provider-*/.../examples/extensions/README.mdExtract the essentials:
If the request mentions a command, identify:
Before coding, briefly decide:
Create or edit the extension files.
Favor code that is:
/reload cycles.Mentally check:
Always end with:
/reload,Use this structure when delivering the work:
Built:
- ~/.pi/agent/extensions/<path>
What it does:
- ...
How to test:
1. Run /reload in Pi
2. ...
3. ...
Notes:
- Mention any assumptions or follow-up questions
/reload instructions over elaborate test harnesses unless the user asks for them.development
Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Use when asked to simplify, refactor lightly, clean up, or improve recently modified code without behavior changes.
tools
Write a path-free, clipboard-ready handoff prompt that lets another agent investigate, discuss, or pick up a specific task.
testing
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
development
Run a Pi-based structured code review as a closeout check on local, branch, PR, or commit changes before commit or ship.