pi-extension-starter is a starter kit for developers who want to build extensions for the pi CLI.
If your question is "what does this repository actually do?", the short answer is: it gives you a ready-to-clone, source-first npm package that already behaves like a real pi extension. You replace the sample command, tool, and UI with your own feature instead of wiring the package from zero.
pi already provides the extension APIs. This repository exists to show how to put those APIs together in a practical package structure that is easy to develop, test, and publish.
- A starter template for authoring
piextensions - A working example of recommended
piextension patterns - A publishable npm package with TypeScript as the extension entrypoint
- Not a finished end-user extension by itself
- Not a replacement for built-in
pifeatures - Not a framework on top of
pi
The included settings panel and checklist tool are sample features. Their job is to demonstrate the extension APIs in a realistic way. You are expected to rename or replace them in your own package.
package.json > pi.extensionspointing to./src/index.ts- A source-first TypeScript entrypoint with no mandatory build step
- An example slash command:
/starter-settings - An example tool:
starter_checklist - Persisted session settings via
pi.appendEntry() - Branch-aware tool state stored in tool result
details - An interactive
SettingsListpanel built withctx.ui.custom() - Lifecycle hooks for
session_start,session_tree, andmodel_select - Custom status and footer rendering
- Reusable test helpers in
test/helpers/ - Local validation scripts and automated release workflows
/starter-settingsopens an interactive settings panelstarter_checklistmanages a small sample checklist- The footer and status reflect the current settings and checklist summary
- Model changes can trigger a notification
- State is restored on session reloads and branch changes
Those behaviors are examples, not the point of the project. The point is the starter structure around them.
Use it when you want to:
- Create a new
piextension package quickly - Follow the current
pipatterns instead of inventing your own wiring - Keep extension state working across reloads,
fork, andtree - Start from a repo that is already set up for tests, packaging, and release
npm install
npm run check
pi -e ./src/index.tsThen:
- Update the package metadata in
package.json. - Rename the public identifiers in
src/types.ts. - Replace the sample command, tool, and UI with your own extension behavior.
- Optionally test package installation with
pi install ..
src/
index.ts
commands/
settings-command.ts
state/
session-state.ts
tools/
starter-checklist-tool.ts
ui/
footer.ts
settings-panel.ts
types.ts
test/
helpers/
mock-command-context.ts
mock-extension-api.ts
mock-extension-context.ts
mock-footer-data.ts
index.test.ts
docs/
pi-guide-1-base.md
pi-guide-2-runtime.md
pi-guide-3-release.md
src/index.ts: registers the command, tool, and lifecycle hookssrc/commands/settings-command.ts: example interactive command usingSettingsListsrc/state/session-state.ts: session persistence and rehydrationsrc/tools/starter-checklist-tool.ts: example tool usingdefineTool()and typeddetailssrc/ui/footer.ts: status and footer renderingsrc/ui/settings-panel.ts: interactive TUI paneltest/helpers/: mocks for extension tests
npm run check runs:
- TypeScript typecheck
- lint
- format check
- tests
npm pack --dry-run
Before publishing, confirm:
npm run check
npm run pack:checkThe repository also includes:
validate.ymlto run validation on pushes and pull requestsrelease.ymlto manage releases withrelease-pleaseand publish to npm
package.jsonnamedescriptionauthorrepositorybugshomepage
src/types.ts- command name
- tool name
- session entry type
- default settings
- Sample settings and checklist behavior
LICENSE
This starter treats the following files as the local implementation contract:
AGENTS.mddocs/pi-guide-1-base.mddocs/pi-guide-2-runtime.mddocs/pi-guide-3-release.md
Those guides were derived from the official pi docs and examples in:
packages/coding-agent/docs/extensions.mdpackages/coding-agent/docs/packages.mdpackages/coding-agent/examples/extensions/README.md
- The package stays source-first, so
piloads the extension directly from TypeScript. - Core
pidependencies stay inpeerDependencieswith"*". @mariozechner/pi-aiis included becauseStringEnum()is part of the recommended enum pattern.