← Back to Plugins
Tools

Plugin Template

OpenClawHQ By OpenClawHQ 👁 4 views ▲ 0 votes

Quick start template for creating OpenClaw plugins

GitHub

Install

npm install

#

Configuration Example

{
  "name": "my-awesome-plugin",
  "version": "1.0.0",
  "description": "我的超棒插件"
}

README

# OpenClaw Plugin Template

> Quick start template for creating OpenClaw plugins

## 使用方法

```bash
# 克隆模板
git clone https://github.com/OpenClawHQ/plugin-template.git my-plugin
cd my-plugin

# 安装依赖
npm install

# 开始开发
npm run dev
```

## 项目结构

```
my-plugin/
├── README.md          # 插件说明
├── src/
│   └── index.ts      # 入口文件
├── tests/             # 测试
├── package.json       # 依赖
├── tsconfig.json      # TS配置
├── SPEC.md           # 插件规范
└── .github/
    └── workflows/     # CI/CD
```

## 快速开始

### 1. 修改插件信息

编辑 `package.json`:

```json
{
  "name": "my-awesome-plugin",
  "version": "1.0.0",
  "description": "我的超棒插件"
}
```

### 2. 实现功能

编辑 `src/index.ts`:

```typescript
export default {
  name: 'my-awesome-plugin',
  version: '1.0.0',
  
  init: async (config) => {
    // 初始化逻辑
  },
  execute: async (input) => {
    // 核心功能
    return result;
  }
};
```

### 3. 编写测试

编辑 `tests/index.test.ts`:

```typescript
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` | 代码检查 |

## 提交插件

1. 确保 README.md 和 SPEC.md 完整
2. 运行测试确保通过
3. 提交 PR 到 OpenClawHQ

---

*Built with 🦞 Every Claw Counts*
tools

Comments

Sign in to leave a comment

Loading comments...