概述
openclaw hooks 管理 Agent hook(事件驱动自动化,响应 /new、/reset、gateway 启动等命令)。无子命令时等同于 hooks list。
openclaw hooks list [--eligible] [--verbose] [--json]
openclaw hooks info <name> [--json]
openclaw hooks check [--json]
openclaw hooks enable <name>
openclaw hooks disable <name>插件管理的 hook 显示为
plugin:<id>,不能用enable/disable控制,需启用/禁用对应插件。
子命令
hooks list
列出所有已发现的 hook(来自 workspace、managed、extra、bundled 目录)。
| 选项 | 说明 |
|---|---|
--eligible | 仅显示满足条件的 hook |
--verbose | 显示详细信息,含未满足的依赖 |
--json | JSON 输出 |
hooks info <name>
显示指定 hook 的详细信息(来源、路径、handler、事件、依赖)。
hooks check
显示 hook 就绪状态摘要(总数、就绪数、未就绪数)。
hooks enable <name>
启用 hook,写入 hooks.internal.entries.<name>.enabled = true。
- workspace hook(
<workspace>/hooks/)默认禁用,需手动启用 - 启用后需重启 Gateway 才生效
hooks disable <name>
禁用 hook,更新配置文件。禁用后需重启 Gateway。
内置 Hook
| Hook | 触发事件 | 说明 |
|---|---|---|
session-memory | command:new、command:reset | 发出 /new//reset 时将会话上下文保存到 memory/YYYY-MM-DD-HHMM.md |
bootstrap-extra-files | agent:bootstrap | 注入额外 bootstrap 文件(如 monorepo 本地的 AGENTS.md/TOOLS.md) |
command-logger | 所有命令事件 | 记录所有命令到 ~/.openclaw/logs/commands.log |
boot-md | gateway:startup | Gateway 启动后运行 BOOT.md |
启用示例:
openclaw hooks enable session-memory
openclaw hooks enable bootstrap-extra-files
openclaw hooks enable command-logger
openclaw hooks enable boot-mdsession-memory 配置项:hooks.internal.entries.session-memory.llmSlug: true 可启用模型生成的文件名 slug。
Hook Pack 安装与更新
Hook pack 通过统一的 plugins 安装器管理(openclaw hooks install 已废弃,转发到 openclaw plugins install):
openclaw plugins install <package> # npm
openclaw plugins install ./my-hook-pack # 本地目录
openclaw plugins install -l ./my-hook-pack # 链接模式
openclaw plugins update <id>
openclaw plugins update --all安装后:
- hook pack 复制到
~/.openclaw/hooks/<id> - 已安装的 hook 写入
hooks.internal.entries.* - 安装记录写入
hooks.internal.installs
相关页面
- concepts/plugin-hooks — 插件 hook 系统(完整 hook 目录)
- concepts/cli-plugins —
openclaw plugins(安装/更新 hook pack)