Plugin development reference and workflows based on real development experience (Dirigent, ContractorAgent, PrismFacet). Docs: structure, entry-point, hooks, tools, state, config, debugging Workflows: create-plugin, add-hook Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.6 KiB
1.6 KiB
Config Schema & Install Scripts
openclaw.plugin.json
{
"$schema": "https://openclaw.ai/schemas/plugin-config.json",
"configSchema": {
"type": "object",
"additionalProperties": false,
"properties": {
"myToken": { "type": "string" },
"myFlag": { "type": "boolean", "default": false }
}
}
}
Rules
additionalProperties: falseis mandatory — OpenClaw validates config against schema- Removing a config field requires removing it from schema too (or gateway fails to start)
- Sensitive fields (tokens, keys): no
default, user must configure manually
Install Script (scripts/install.mjs)
Install does:
- Build dist (compile TypeScript)
- Clean and copy to
~/.openclaw/plugins/<id>/ - Update
openclaw.json:- Add to
plugins.allow - Add to
plugins.load.paths - Set
plugins.entries.<id>.enabled = true - Set default config via
setIfMissing(never overwrite existing values)
- Add to
- Never set sensitive fields (tokens) — add comments for manual configuration
Uninstall does:
- Remove from
plugins.allow - Delete
plugins.entries.<id> - Remove from
plugins.load.paths - Delete install directory
setIfMissing pattern
function setIfMissing(obj, key, value) {
if (obj[key] === undefined || obj[key] === null) {
obj[key] = value;
}
}
Config field changes
When renaming or removing config fields:
- Update
openclaw.plugin.jsonschema first (source of truth) - Update
normalizeConfig()in index.ts - Update install script
setIfMissingcalls - Document migration steps for users