# 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 ```bash 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: ```bash git-ctrl repo create git add -A && git commit -m "init: " git push -u origin main ```