Files
ClawSkills/openclaw-plugin-dev/workflows/create-plugin.md
zhi 5a8f490cc2 feat: add openclaw-plugin-dev skill
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>
2026-04-18 17:25:07 +00:00

1.5 KiB

Create Plugin

When creating a new OpenClaw plugin from scratch.

See {baseDir}/docs/structure.md for directory layout and conventions.

Process

1. Scaffold

Create the project structure:

my-plugin/
  plugin/
    index.ts
    openclaw.plugin.json
    package.json
    core/
    hooks/
    tools/
  scripts/
    install.mjs
  routers/              # if applicable
  package.json          # dev dependencies (typescript, @types/node)
  tsconfig.plugin.json
  .gitignore

2. Define Config Schema

Write plugin/openclaw.plugin.json with additionalProperties: false. Only include fields the plugin actually uses.

3. Implement Entry Point

Follow the pattern in {baseDir}/docs/entry-point.md:

  • export default { id, name, register }
  • globalThis lifecycle protection
  • Hooks in separate files under hooks/
  • Tools in separate files under tools/
  • Business logic in core/ (no plugin-sdk imports)

4. Implement Hooks

Follow dedup patterns in {baseDir}/docs/hooks.md. Each hook gets its own file.

5. Implement Tools

Follow the interface in {baseDir}/docs/tools.md: inputSchema + execute.

6. Write Install Script

Follow {baseDir}/docs/config.md for install/uninstall conventions.

7. Build & Test

npm run build
node scripts/install.mjs --install
openclaw gateway restart
# Test via Discord or openclaw agent CLI

8. Push

Create a git repository and push:

git-ctrl repo create <plugin-name>
git add -A && git commit -m "init: <plugin-name>"
git push -u origin main