workflow-pi-extension
Skill0 starsChanged 4 months agoMITView on GitHub
Use this skill when creating, modifying, reviewing, debugging, or packaging Pi extensions, including custom tools, commands, event hooks, TUI components, model providers, extension packages, inter-extension communication, and reload behavior, even if the user only refers to a Pi tool or command. Routes to the bundled Pi docs and examples rather than restating the API.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- mcpSkill
- pattern-orchestration-complexSkill
- pattern-task-breakdownSkill
- role-architectSkill
- role-code-reviewSkill
- role-data-engineerSkill
- role-developerSkill
- role-orchestratorSkill
- role-product-engineerSkill
- role-qa-engineerSkill
- role-security-auditorSkill
- role-site-reliability-engineerSkill
- role-technical-writerSkill
- standards-analysisSkill
- standards-api-designSkill
- standards-codeSkill
- standards-databaseSkill
- standards-documentationSkill
- standards-go-concurrencySkill
- standards-go-performanceSkill
- standards-goSkill
- standards-go-testingSkill
- standards-markdownSkill
- standards-observabilitySkill
- standards-pulumi-typescriptSkill
- standards-pythonSkill
- standards-securitySkill
- standards-shellSkill
- standards-skill-authoringSkill
- standards-testingSkill
- standards-typescriptSkill
- tool-storeSkill
- workflow-debuggingSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 9 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Golden Rule: Read the bundled Pi docs before implementing.
- Very specific: line 26
Read docs/tui.md for custom UI, widgets, overlays, renderers, footers, or editor components.
- Very specific: line 27
Read docs/packages.md for package manifests, dependencies, distribution, or install and update behavior.
- Very specific: line 28
Read docs/custom-provider.md for model providers, OAuth, or custom streaming.
- Very specific: line 29
Read docs/keybindings.md for shortcuts or editor key handling.
- Distinctive: line 32
Prefer an official example over an invented pattern.
- Distinctive: line 38
Prefer composable, reusable extensions over one-off monoliths.
- Very specific: line 39
Prefer an extension directory with package.json over a loose .ts file once the extension has dependencies, helpers, tests, reusable …
- Distinctive: line 40
Keep extension dependencies self-contained in the extension package.
- Very specific: line 42
Prefer optional integration through pi.events, and direct imports only for hard dependencies.
- Distinctive: line 45
Keep event payloads JSON-serializable unless there is a specific reason not to.
- Very specific: line 85
Add "keywords": ["pi-package"] only when publishing or distributing.
- Distinctive: line 92
Read the matching Pi docs and the closest official example.
- Distinctive: line 93
Check whether an existing extension can be reused or extended instead.
- Very specific: line 97
If the extension should persist, place it under ~/.pi/agent/extensions/ or .pi/extensions/.
- Very specific: line 98
Verify /reload works from that auto-discovered location.
- Distinctive: line 104
Do not hardcode credentials or log secrets.
- Very specific: line 106
Avoid shell interpolation.
- Very specific: line 107
Check ctx.hasUI before requiring interactive UI, so the extension still works headless.
- Distinctive: line 108
Use abort signals for long-running work where available.
- Very specific: line 110
Use StringEnum from @earendil-works/pi-ai for tool string enums.
- Very specific: line 112
Use withFileMutationQueue() for file-mutating tools so concurrent writes serialize.
- Very specific: line 115
Treat ctx.reload() as terminal: await ctx.reload().
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Pi Extension Workflow
Provides: A routing map to the authoritative Pi docs, architecture preferences for composable extensions, a package layout, and a safety checklist.
Quick Reference
Golden Rule: Read the bundled Pi docs before implementing; do not invent API shapes
Flow: Identify type → Read docs and closest example → Check for reuse → Design contracts → Implement → Test with pi -e → Verify /reload
One owner per shared capability. Notifications, status widgets, path protection, configuration, and persistence should each live in exactly one extension.
Required References
This skill deliberately does not duplicate the Pi API. Read the relevant docs from the installed Pi package:
- Always read
docs/extensions.md. - Read
docs/tui.mdfor custom UI, widgets, overlays, renderers, footers, or editor components. - Read
docs/packages.mdfor package manifests, dependencies, distribution, or install and update behavior. - Read
docs/custom-provider.mdfor model providers, OAuth, or custom streaming. - Read
docs/keybindings.mdfor shortcuts or editor key handling. - Inspect the closest file under
examples/extensions/.
Prefer an official example over an invented pattern. The extension API surface changes between Pi versions, so a remembered signature is less reliable than the installed docs.
Design Preferences
- Prefer composable, reusable extensions over one-off monoliths.
- Prefer an extension directory with
package.jsonover a loose.tsfile once the extension has dependencies, helpers, tests, reusable contracts, or is expected to persist. - Keep extension dependencies self-contained in the extension package. Do not add extension-specific dependencies to the global Pi package unless there is no alternative.
- Factor shared behavior into reusable modules or explicit
pi.eventscontracts. - Prefer optional integration through
pi.events, and direct imports only for hard dependencies. Events let an extension work when its counterpart is absent; an import does not. - Namespace shared event names, for example
notifications:show. - Export constants and TypeScript types for shared event payloads so consumers do not hardcode strings.
- Keep event payloads JSON-serializable unless there is a specific reason not to.
Preferred Layout
For anything beyond a tiny experiment:
my-extension/
├── package.json
├── index.ts
├── src/
│ ├── events.ts
│ ├── state.ts
│ └── tools.ts
└── test/
└── smoke.test.tsMinimal local package.json:
{
"name": "my-pi-extension",
"private": true,
"type": "module",
"dependencies": {},
"peerDependencies": {
"@earendil-works/pi-ai": "*",
"@earendil-works/pi-coding-agent": "*",
"@earendil-works/pi-tui": "*",
"typebox": "*"
},
"pi": {
"extensions": ["./index.ts"]
}
}Add "keywords": ["pi-package"] only when publishing or distributing.
Workflow
- Identify the extension type: tool, command, event hook, shared service, UI, provider, or package.
- Read the matching Pi docs and the closest official example.
- Check whether an existing extension can be reused or extended instead.
- Design shared capabilities as modules or documented
pi.eventscontracts. - Implement using Pi's documented APIs and TypeScript types.
- Test with
pi -e ./path. - If the extension should persist, place it under
~/.pi/agent/extensions/or.pi/extensions/. - Verify
/reloadworks from that auto-discovered location.
Safety Checklist
- Do not hardcode credentials or log secrets.
- Validate paths and user input.
- Avoid shell interpolation. Use
pi.exec(command, args)so arguments are passed without a shell. - Check
ctx.hasUIbefore requiring interactive UI, so the extension still works headless. - Use abort signals for long-running work where available.
- Bound custom tool output. Unbounded output floods the agent's context.
- Use
StringEnumfrom@earendil-works/pi-aifor tool string enums. - Throw from a tool's
execute()to signal failure; do not return an error string. - Use
withFileMutationQueue()for file-mutating tools so concurrent writes serialize. - Restore state on
session_start. - Clean up watchers, intervals, sockets, and child processes on
session_shutdown. - Treat
ctx.reload()as terminal:await ctx.reload(); return;.
Checklist
Before finishing:
- The relevant Pi docs were read for this extension type
- The closest official example was inspected
- Existing extensions were checked for reuse opportunities
- Shared behavior is a reusable module or a documented event contract
- Shared event names are namespaced, with exported types for payloads
- Dependencies are local to the extension package
- The extension loads with
pi -e /reloadworks from an auto-discovered location- Watchers, intervals, and child processes are cleaned up on shutdown
See also
- Load
standards-typescriptwhen writing the extension implementation. - Load
standards-testingfor the extension's test coverage. - Load
standards-securitywhen the extension handles credentials, paths, or user input.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

