Quick start template for creating OpenClaw plugins
# 克隆模板
git clone https://github.com/OpenClawHQ/plugin-template.git my-plugin
cd my-plugin
# 安装依赖
npm install
# 开始开发
npm run devmy-plugin/
├── README.md # 插件说明
├── src/
│ └── index.ts # 入口文件
├── tests/ # 测试
├── package.json # 依赖
├── tsconfig.json # TS配置
├── SPEC.md # 插件规范
└── .github/
└── workflows/ # CI/CD
编辑 package.json:
{
"name": "my-awesome-plugin",
"version": "1.0.0",
"description": "我的超棒插件"
}编辑 src/index.ts:
export default {
name: 'my-awesome-plugin',
version: '1.0.0',
init: async (config) => {
// 初始化逻辑
},
execute: async (input) => {
// 核心功能
return result;
}
};编辑 tests/index.test.ts:
import { describe, it, expect } from 'vitest';
import plugin from '../src/index';
describe('my-plugin', () => {
it('should work', () => {
expect(plugin.name).toBe('my-awesome-plugin');
});
});| 命令 | 描述 |
|---|---|
npm run dev |
开发模式 |
npm run build |
构建 |
npm run test |
测试 |
npm run lint |
代码检查 |
- 确保 README.md 和 SPEC.md 完整
- 运行测试确保通过
- 提交 PR 到 OpenClawHQ
Built with 🦞 Every Claw Counts