Prerequisites
- OpenClaw installed (Node 22+)
- TypeScript knowledge
- Basic understanding of OpenClaw concepts (agents, tools, sessions)
Project Setup
Initialize package.json
Create a Note: If you plan to publish to npm, use the
package.json:@openclaw/ scope: @openclaw/my-plugin.Add a Custom Tool
Let’s add an agent tool that generates greetings:Tool Schema with TypeBox
OpenClaw uses @sinclair/typebox for tool schemas. Common patterns:Test Your Tool
Restart the gateway and send a message:greet tool and respond with the generated greeting.
Add Tool Options
You can mark tools as optional (requiring explicit allowlisting):Add Configuration
Plugins can define configuration schemas:config.json:
Directory Structure
For larger plugins, organize code into modules:Next Steps
Now that you’ve built a basic plugin, explore advanced features:- Plugin SDK Reference - Complete API documentation
- Hooks - Intercept lifecycle events
- Channels - Build messaging integrations
- Examples - Real-world plugin examples
- Publishing - Share your plugin on npm

