Pikku addon

From pikkujs/pikku · View interactive version

Pikku addon is an AI agent skill from the GitHub repository pikkujs/pikku. Reusable Pikku function packages (addons): wireAddon, ref(), pikkuAddonServices, shipping DB tables, sharing functions across projects, generating an addon from an OpenAPI/Swagger spec.

How to use this skill

Skill file

Pikku Addons

What to reach for and why. For how to call it, run this once, from the addon with yarn pikku (there is usually no global pikku): yarn pikku doc addon wireAddon wireRemoteAddon ref refHTTP refChannel refCLI pikkuAddonServices pikkuAddonWireServices pikkuAddonConfig defineHTTPRoutes wireHTTPRoutes. Depth: references/openapi.md, references/addon-package-manifest.md.

An addon is a reusable function package shared across projects: functions, services, secrets and variables in one self-contained NPM package. See pikku-concepts for the core mental model.

Is it an addon?

Working on one

Discover first (pikku meta … --json, pikku info functions --verbose, pikku info tags --verbose). Find the source that owns the behaviour; do not start from generated output, .pikku, node_modules, vendored packages or build artifacts. Make the smallest source change, never hand-edit SDKs, schema output or typegen, validate narrowly first, then pikku all when functions, wirings, schemas or clients may have changed. If validation fails, fix the source cause and rerun.

Security rules

What an addon must not do

pikku validate fails an addon that reaches past the services it is given. An addon is installed into other people's apps, so the host, not the addon, decides where files live, which processes run and what the environment holds. Each of these is a validate error with a fix that stays inside Pikku:

start.ts, server.ts, **/bin/**, **/scripts/** and tests are exempt. Anywhere else, a one-line // oxlint-disable-next-line <rule> -- reason is the only way out. Do not set lint.enforce* to "off" to make an addon pass. These keys apply to apps and addons, not to library packages: a library or developer-tool package that pikku validate checks sets the key it cannot meet to "off" in its own pikku.config.json.

Writing an addon

Building

Calling another addon

| Code | pikku all fails when |

| ------ | ------------------------------------------------------------------- |

| PKU338 | the workspace SDK is missing |

| PKU354 | the version or mapped instance is outside the range |

| PKU348 | an alias the addon declared is not mapped |

| PKU347 | it is mapped to a name not wired, or wired from another package |

| PKU355 | uses maps a name the addon did not declare |

| PKU356 | the addon's pikku.uses entry is malformed (alias, type, no range) |

Database tables

An addon may ship tables. It must never create them: it runs inside the consumer, against the consumer's database, so a boot-time CREATE TABLE puts a second authority on a schema the consumer's migrations own. It declares instead, and the consumer's pikku db generate creates them with its own.

Consuming an addon

Studio screens

An addon declares the screens it adds to Pikku Studio with definePlugin, in src/screens.ts (npx @pikku/cli new addon <name> --ui scaffolds one). It replaces defineScreens, which no longer exists.

| Code | pikku all fails when |

| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| PKU345 | a field is not a literal (call, import, a variable other than a same-file top-level const, bad value), a malformed RPC or go: name, or a destructive action without confirm |

| PKU357 | two screens of the addon use the same path |

| PKU358 | a title, agent frontmatter, widget, thing, arranged screen, slot copy (nested, $, figure) or action key is missing from messages/en.json |

| PKU359 | nav.badge names no function of the addon |

| PKU365 | agent is neither a name nor studio:<name>, or a name has no non-empty agents/<name>.md, or no frontmatter title and description |

| PKU366 | package.json files leaves out agents/ while a screen names a valid (no PKU365) non-studio: agent, or skills/ while the addon has a skills/<name>/SKILL.md |

Not in `pikku doc` yet

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.