rajivmehtaflex/power-utility/pi-extension-authoring
Claude Code and agent skill by rajivmehtaflex/power-utility
- community
Checking that the SKILL.md file is still in the repository.
Use when authoring TypeScript Pi extensions.
Install
npx vskill@latest install rajivmehtaflex/power-utility/pi-extension-authoringSKILL.md
The same SKILL.md was published earlier as rajivmehtaflex/power-utility/pi-extension-authoring.
Pi Extension Authoring
Author and edit Pi coding-agent extension packages (packages/<name>/ layout, entry src/index.ts with export default function (pi: ExtensionAPI)). Covers tool registration, slash-command prompts, ctx.ui dialog primitives, dashboard widgets, and the port-a-pattern workflow for lifting features from reference repos into a local package without importing their dependencies.
When to Use
- Adding or changing a tool (
pi.registerTool), slash prompt (prompts/*.md), custom
command (pi.registerCommand), or widget in a Pi extension package.
- Building a model-invoked interactive dialog (ask-the-user tools) on
ctx.uiprimitives. - Studying another Pi extension repo to port a pattern into the local package.
- Wiring new modules into a package's
src/index.ts(register*(pi, state)functions).
Codebase conventions (verified in pi-local-dev packages)
- Zero runtime npm deps. JSON-Schema tool args use the hand-rolled TypeBox-compatible
Type builder in src/types.ts — never add @sinclair/typebox for this.
- Tool result envelope:
{ content: [{ type: "text", text }] }(see plan-mode.ts). - Types are re-exported locally: import
ExtensionAPI,ExtensionContext,
WorkflowState from ./types.js, not from @earendil-works/pi directly.
- `ctx.ui` primitives:
confirm(title, msg) → Promise<boolean>,
select(title, options[]) → Promise<string | undefined>, input(title, placeholder?) → Promise<string | undefined>. A resolved undefined from select/input means the user dismissed the dialog — treat as cancel, never as an answer. Gate all UI tools on ctx.hasUI (headless/--no-session runs have no UI).
- Slash prompts auto-bind: every
prompts/*.mdbecomes/<filename>— a name
shared with registerCommand(...) silently collides (two behaviors, one slash string).
- Module shape: each feature module exports
registerX(pi: ExtensionAPI, state);
src/index.ts calls them in order and owns the shared mutable state object.
Port-a-pattern workflow (from a reference repo)
git clone --depth 1 <repo> /tmp/<repo>— read-only study, never run its scripts.- Locate the package (
packages/<name>/), read its entry*.tsregisterToolblock,
then find the simple path — repos often ship a huge TUI overlay plus a small fallback (e.g. rpiv-ask-user-question: 9.8k-LOC overlay vs 166-line rpc-fallback.ts walker on ctx.ui.select/input). Port the fallback-shaped core.
- Re-express in local conventions (local
Typebuilder, local result envelope,
local imports). Keep logic pure where possible: validate params → pure dialog walker (inject ui for testability) → envelope.
- Add
*.test.tsundernode:testwith a fakeuiobject — this also fixes the
zero-tests false-green (see Pitfalls).
Pitfalls
npm test(node --test) passes with 0 test files — green proves nothing until
at least one *.test.ts exists.
- Stale
dist/: runnpm run buildafter editingsrc/*.tsbefore loading in Pi. .pi/settings.jsonpackage paths resolve relative to.pi/— use
../packages/<name>.
- Widgets/dialogs render only in a live TTY: verify via tmux (`tmux new-session -d -s
piui -x 150 -y 45 "pi" then tmux capture-pane -p), not headless -p` runs.
- Authoring question tools: reject reserved option labels (
"Other", `"Type
something."`) at validation time — the free-text row is appended by the runtime.
- When a tool's dialog can't render, tell the model the user **never saw the
questions** and to re-ask in plain chat — never frame it as a user decline.
- Terminal hardline block on "oversized/unparseable inline command payloads": complex
sed -n "$(grep ...)" one-liners can trip it — split into read_file/search_files tool calls instead of shell text-processing pipelines.
Verification
npm run buildexit 0 (tsc).npm test— real test count > 0, all passing.- Load and exercise:
pi -e ./packages/<name>/src/index.ts(or via
.pi/settings.json), confirm the tool in pi list, drive it in tmux for anything visual.
References
references/rpiv-ask-user-question.md— architecture study of the
juicesharp/rpiv-mono ask-user-question extension: schema constraints, dialog walker algorithm, answer union, no-UI fallback messaging.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingprofile/software-development/pi-extension-authoring/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rajivmehtaflex/power-utility/pi-extension-authoring)