Skip to main content
This guide walks you through creating your first OpenClaw plugin. We’ll build a simple plugin that adds a custom agent tool.

Prerequisites

  • OpenClaw installed (Node 22+)
  • TypeScript knowledge
  • Basic understanding of OpenClaw concepts (agents, tools, sessions)

Project Setup

1

Create plugin directory

Create a directory for your plugin:
2

Initialize package.json

Create a package.json:
Note: If you plan to publish to npm, use the @openclaw/ scope: @openclaw/my-plugin.
3

Create plugin entry point

Create index.ts:
4

Add the plugin to OpenClaw

Edit your ~/.openclaw/config.json:
Or install from a local directory:
5

Verify the plugin loads

Restart the gateway and check logs:
You should see: Hello plugin registered

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:
The agent should use the greet tool and respond with the generated greeting.

Add Tool Options

You can mark tools as optional (requiring explicit allowlisting):
Then allowlist in agent config:

Add Configuration

Plugins can define configuration schemas:
Configure via config.json:

Directory Structure

For larger plugins, organize code into modules:

Next Steps

Now that you’ve built a basic plugin, explore advanced features: