dvcrn/openclaw-skills-marketplace/openclaw-hook
- community
Checking that the SKILL.md file is still in the repository.
Create, debug, and maintain OpenClaw Gateway internal hooks. Use when: (1) creating new hooks for agent events like bootstrap, (2) debugging hook execution issues, (3) understanding hook configuration and event structure, (4) injecting virtual bootstrap files, (5) fixing issues like Telegram notifications not sending, Content-Length errors, or context access problems. Triggers on phrases like \"create a hook\", \"fix hook\", \"debug hook\", \"hook not working\", \"internal hook\".
Install
npx vskill@latest install dvcrn/openclaw-skills-marketplace/openclaw-hookSKILL.md
OpenClaw Internal Hook 开发指南
什么是 Internal Hook?
Internal Hook 是 OpenClaw Gateway 内部的事件处理器,在 agent 生命周期事件(如 agent:bootstrap)触发时执行 JavaScript/TypeScript 代码。
用途:
- 在会话启动时注入上下文文件
- 检查和提醒用户待处理的事项
- 发送通知(Telegram、Webhook 等)
- 记录日志和审计
快速开始
1. 创建 Hook 目录
2. 编写 Handler
3. 注册 Hook
在 ~/.openclaw/openclaw.json 中添加:
4. 重启 Gateway
事件结构
agent:bootstrap 事件
上下文字段
| 字段 | 类型 | 说明 | |
|---|---|---|---|
workspaceDir | string | 工作区目录路径 | |
bootstrapFiles | array | 要注入的文件列表 | |
cfg | object | Gateway 配置(可能不完整) | |
sessionId | string | 会话 UUID | |
agentId | string | Agent ID(如 'main', 'baixiaosheng') |
HOOK.md 元数据
核心模式
1. 安全检查(必须!)
2. 注入虚拟文件
3. 读取工作区文件
4. 发送 HTTP 请求(如 Telegram)
5. 获取配置(从文件读取更可靠)
调试方法
1. 添加日志
2. 查看日志
3. 独立测试发送逻辑
4. 测试 Hook 执行
发送 /new 命令触发 bootstrap 事件,然后检查日志。
常见陷阱
1. Content-Length 字节计算
问题:发送中文时 Telegram 返回 message text is empty
原因:data.length 是字符数,不是字节数。中文字符在 UTF-8 中占 3 字节。
2. Markdown 解析问题
Telegram Markdown 解析很严格,特殊字符会导致失败。
解决方案:不使用 parse_mode,发送纯文本。
3. cfg 对象不完整
event.context.cfg 可能不包含完整配置。
解决方案:直接从配置文件读取。
4. 忘记导出 handler
5. 忘记重启 Gateway
修改 hook 后必须重启:
完整示例
参见 references/complete-example.js 获取包含所有功能的完整 hook 示例。
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/cbd2020--openclaw-hook/skills/openclaw-hook/SKILL.md
Popularity
- Repository stars
- 24
- Repository forks
- 9
- 7-day trend score
- 16
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dvcrn/openclaw-skills-marketplace/openclaw-hook)