/pocketone:pocketone-extensionsfrom pocketone
Guides writing PocketOne extensions as Go modules in ext/<name>/, including contract design, conformance testing, and contributing via pull requests to github.com/pocketonehq/pocketone.
Ships in pocketone. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
PocketOne is PocketBase plus extensions. Every feature is an extension: its own Go module in ext/<name>/ of
github.com/pocketonehq/pocketone, compiled into the binary. An outside
extension arrives as a pull request that adds ext/<name>/. Whoever submits it owns it: later pull requests to
it need your approval (or a maintainer's).
Words: everything in ext/ is an extension, never a "plugin". Standard extensions ship in every pocketone
binary (listed in ext/standard); the rest are community extensions, which is what yours will be.
Read these before writing code (in a checkout they are docs/contracts.md and docs/extensions.md):
ext/<name>/, its own Go module, touching nothing outside that folder (and
ext/contracts/<id path>/ for a new contract).A contract is a named, versioned promise (restore/v1): a Go interface in ext/contracts/<id path>/vN/
(mail.fallback/v1 lives in ext/contracts/mail/fallback/v1/). PocketOne turns a contract's interface into its HTTP
API at /api/_c/<id>/<op>, a pocketone remote command per operation, an MCP tool per JSON operation, Go and JS
hooks, and a client. Extensions never talk to each other directly; they meet through contracts.
Choose in this order:
Requires or WorksWith. If one promises what you offer, provide it: your extension then stands in for
the current provider (a default steps aside; otherwise providers: in pocketone.yaml picks).mail.fallback/v1), decorate whatever provides it
(Contract.Wrap, declared in Wraps), add or replace pocketone commands (cli.commands/v1), or give it an
admin screen (Contract.UI).restore/v1), never for your extension. A
new optional ability beside an existing contract is a small companion contract (mail.suppression/v1 beside
bulkmail/v1), not a modified copy. It goes in the same pull request, in ext/contracts/<id path>/v1/, with a
README: front matter owners and summary, then ## Use, ## Provide, ## Extensions, ## License (MIT).
You own the contract you create. In the pull request, name the contracts you checked and why none fits.A published vN never changes what it promises. A changed promise is a new vN+1 beside it, reviewed with the
contract's owners.
After adding or changing a contract interface, from the repo root:
(cd ext/contracts && go generate ./...)
go run ./.github/extensions check
/api/_c/<id>/. Only paths a
standard fixes stay at the root (/.well-known/*, /mcp), and those belong to existing extensions.Contracts(): Implements, Defaults, Wraps,
Requires, WorksWith.Register (Provide / ProvideDefault); look contracts up only later (Of, Must, in hooks
or at serve time). A lookup inside Register panics._<name>_<table>, hyphens in the name as underscores (_agent_chat_messages);
never change PocketBase's own collections.Migrations() []extkit.Migration method; extkit applies them at
bootstrap and records them in _extension_migrations), never copied into an app's pb_migrations.extkit.CacheDir(app, name) (pb_cache/<name>/): never backed up or deployed, and
deletable at any time.go.mod, never core's. A module that reaches another ext/ module (a contract
package, extkit) adds a replace for it.P1_<NAME> (extkit.EnvVar("TOKEN") is P1_TOKEN). PB_ is
PocketBase's.extkit.Command (default pocketone), never a literal.Core is every path outside ext/, site/, examples/pocketone/, docs/ and the repo's own docs and CI files. Most
extensions need no core change: use OnServe, the record and request hooks, the JS engine's extension methods
(OnInit, ...), OnFilesystemCreate, BaseAppConfig.AppMigrations / OnLog / DBConnect, UIExtensions.
If you truly need something core doesn't offer, add the smallest generic hook (a nil-checked function field, a
list callers append to, or an event), named for what it allows, not for your extension, with upstream behavior
unchanged when nothing uses it. Mark every changed line // PocketOne: with a few words on why, put it in its own
commit with a test, ahead of the extension, and say in the pull request why it can't live in ext/. A maintainer
reviews and audits every core change. Ask the user before making one; never change core casually.
ext/<name>/
go.mod module pocketone.dev/ext/<name>
README.md its docs and its page on pocketone.dev
CHANGELOG.md required
TODO.md optional: work that waits on something else existing first
<name>.go, <name>_test.go
conformance_test.go required
modes_test.go the feature on the real binary, in every mode it runs in
example/main.go required: the smallest program that shows it working
ui/ optional: admin screens (embedded main.js)
site/ optional: more docs pages, served under its pocketone.dev page
type Extension struct{ cfg Config }
func New(cfg Config) *Extension { return &Extension{cfg: cfg} }
func (e *Extension) Name() string { return "hello" } // its pocketone.yaml key, `_hello` collections, log lines
func (e *Extension) Contracts() extkit.Contracts {
return extkit.Contracts{
Implements: extkit.IDs("deploy/v1"),
Defaults: extkit.IDs("deploy/v1"), // steps aside if another extension provides it
WorksWith: extkit.IDs("api-tokens/v1"),
}
}
func (e *Extension) Register(app core.App, cfg extkit.Config) error {
c := e.cfg
if err := cfg.Decode(&c); err != nil { // this app's settings over the defaults
return err
}
deployv1.Contract.ProvideDefault(app, myDeployer{})
return nil
}
pocketone.yaml: extkit.NewSection(name, defaults, doc), with a doc:"…" struct tag on each
key (it feeds pocketone config --json and the key table on your page). An empty section means all defaults.settings/v1 (settingsv1.Add).app.Store(); shared resources close through extkit.Closer (Close(ctx) error).extkit.AppID(app); never build paths from request
input. One extension value serves many apps on a multisite host.pb_hooks: BindJS(app, rt) sets globals, and a TypeScript() method declares their types.core.UIExtension{Name, FS} to se.UIExtensions in OnServe.<name>_<verb>_<noun> (pb_ is reserved).multisite.Extensions with Name()
and RegisterHost(h).set.Add(myext.New(...)) on the standard set, as in ext/standard/example/main.go.ext/bulkmail/extension.go (an app extension), ext/pitr/README.md (the README).func TestConformance(t *testing.T) {
conformance.Run(t, func() extkit.Extension { return myext.New(myext.Config{}) })
}
The conformance test checks that the extension registers, migrates, serves and shuts down with no goroutines left
behind, has only contract routes, names its collections right, and serves several apps from one value. Pass
conformance.Options{Deps: ...} for extensions it requires and Setup when it adds MCP tools.
modes_test.go runs the same test body on the real pocketone binary in each mode with ext/extkit/modetest:
modetest.AllApp (one app, and a multisite host) for an app extension; Host and/or Fleet for a host extension.
example/main.go calls devusers.Register(app) right after creating the app, so a fresh data dir has superuser
[email protected] and user [email protected], both password password. Never in a production build.
Tests that need an external tool (MinIO, Docker) skip themselves when it isn't installed.
The README is also the extension's page on pocketone.dev. Front matter, then five sections in this order:
---
owners: ["@your-github-handle"]
version: 0.1.0
title: "My Extension"
group: services
summary: "One line: what it does for someone running an app."
---
group is one of binary, many, services, saas, authors (from site/extensions.json).## Install: how to get it (the lines to add to a Go build).## Configure: its pocketone.yaml section, flags and settings screens.## Use: day to day: screens, commands.## Integrations: the extensions and contracts it works with, and how others can build on it.## Example: a sentence, then the whole example/main.go in a go block, exactly as it is
(go run ./.github/extensions examples copies it in; CI fails when they differ).Write Install, Configure and Use for someone running one app, not for a Go developer. Extra sections (how it works,
limits) come after. The README ends with ## License and the line MIT.
CHANGELOG.md: every user-visible change adds one line under ## Unreleased, grouped under ### Upgrading
(steps for anything breaking), ### Added, ### Changed or ### Fixed. Don't raise version: yourself: each
PocketOne release does it for every extension with unreleased lines.
TODO.md (optional): only work that waits for something else to exist first, each item under a **Waits on:** line
naming what it waits for. It isn't published.
From the repository root:
go build -o /dev/null ./... # a plain `go build` writes a binary into the tree
go run ./.github/extensions test ext/<name> # everything CI runs on your pull request; ends with `ok`
cd site/sync && go run . --validate # your README builds into a page
llms.txt, contract indexes and the skills'
reference/ folders are rebuilt on main after your pull request merges. To preview your page, run
cd site/sync && go run ., then discard what it writes outside your folder.go run ./.github/extensions approvers origin/main HEAD lists who may approve each part of a change.Plain-Markdown copies of pocketone.dev, regenerated by site/sync.
reference/docs/contracts/<id>/index.mdreference/docs/extensions/<name>/index.md; pitr is the model READMEpocketone skill. Building pb_pages sites: also the pocketone skill.reference/docs/config-reference.md (opens in a new tab)reference/docs/contracts/api-tokens.verify/v1/index.md (opens in a new tab)reference/docs/contracts/api-tokens/v1/index.md (opens in a new tab)reference/docs/contracts/bulkmail/v1/index.md (opens in a new tab)reference/docs/contracts/cache.clear/v1/index.md (opens in a new tab)reference/docs/contracts/cache/v1/index.md (opens in a new tab)reference/docs/contracts/cli.commands/v1/index.md (opens in a new tab)reference/docs/contracts/deploy/v1/index.md (opens in a new tab)reference/docs/contracts/gate/v1/index.md (opens in a new tab)reference/docs/contracts/http.wrap/v1/index.md (opens in a new tab)reference/docs/contracts/index.md (opens in a new tab)reference/docs/contracts/instance.fs/v1/index.md (opens in a new tab)reference/docs/contracts/instance.lookup/v1/index.md (opens in a new tab)reference/docs/contracts/instance.resolve/v1/index.md (opens in a new tab)reference/docs/contracts/instance.source/v1/index.md (opens in a new tab)reference/docs/contracts/instance.status/v1/index.md (opens in a new tab)reference/docs/contracts/instance.tokens/v1/index.md (opens in a new tab)reference/docs/contracts/instance.watch/v1/index.md (opens in a new tab)reference/docs/contracts/kv/v1/index.md (opens in a new tab)reference/docs/contracts/llm.align/v1/index.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub pocketonehq/pocketone --plugin pocketone2 skills in this plugin
Other plugins' skills for the same job