Managing Agent Hooks with OpenClaw
Hooks let OpenClaw react to events like gateway startup, /new, and /reset without you triggering every step manually. Run openclaw hooks with no subcommand and it behaves the same as openclaw hooks list.
Related:
List All Hooks
Section titled “List All Hooks”openclaw hooks listLists every discovered hook from workspace, managed, extra, and bundled directories. Gateway startup does not load internal hook handlers until at least one internal hook is configured.
Options:
--eligible: Show only eligible hooks (requirements met)--json: Output as JSON-v, --verbose: Show detailed information including missing requirements
Example output:
Hooks (4/4 ready)
Ready: 🚀 boot-md ✓ - Run BOOT.md on gateway startup 📎 bootstrap-extra-files ✓ - Inject extra workspace bootstrap files during agent bootstrap 📝 command-logger ✓ - Log all command events to a centralized audit file 💾 session-memory ✓ - Save session context to memory when /new or /reset command is issuedopenclaw hooks list --verboseShows missing requirements for ineligible hooks.
openclaw hooks list --jsonReturns structured JSON for programmatic use.
Get Hook Information
Section titled “Get Hook Information”openclaw hooks info <name>Show detailed information about a specific hook.
Arguments:
<name>: Hook name or hook key (e.g.,session-memory)
Options:
--json: Output as JSON
Example:
openclaw hooks info session-memoryOutput:
💾 session-memory ✓ Ready
Save session context to memory when /new or /reset command is issued
Details: Source: openclaw-bundled Path: /path/to/openclaw/hooks/bundled/session-memory/HOOK.md Handler: /path/to/openclaw/hooks/bundled/session-memory/handler.ts Homepage: https://docs.openclaw.ai/tools/automation/hooks#session-memory Events: command:new, command:reset
Requirements: Config: ✓ workspace.dirCheck Hooks Eligibility
Section titled “Check Hooks Eligibility”openclaw hooks checkShow a summary of hook eligibility status (how many are ready vs. not ready).
Options:
--json: Output as JSON
Example output:
Hooks Status
Total hooks: 4Ready: 4Not ready: 0Enable a Hook
Section titled “Enable a Hook”openclaw hooks enable <name>Enable a specific hook by adding it to your config (~/.openclaw/openclaw.json by default).
Workspace hooks are disabled by default until you enable them here or in config. Hooks managed by plugins show plugin:<id> in openclaw hooks list and can’t be enabled or disabled here — enable or disable the plugin instead.
Arguments:
<name>: Hook name (e.g.,session-memory)
Example:
openclaw hooks enable session-memoryOutput:
✓ Enabled hook: 💾 session-memoryWhat it does:
- Checks whether the hook exists and is eligible
- Updates
hooks.internal.entries.<name>.enabled = truein your config - Saves the config to disk
If the hook came from <workspace>/hooks/, this opt-in step is required before the Gateway will load it.
After enabling: restart the gateway so hooks reload (menu bar app restart on macOS, or restart your gateway process in dev).
Disable a Hook
Section titled “Disable a Hook”openclaw hooks disable <name>Disable a specific hook by updating your config.
Arguments:
<name>: Hook name (e.g.,command-logger)
Example:
openclaw hooks disable command-loggerOutput:
⏸ Disabled hook: 📝 command-loggerAfter disabling: restart the gateway so hooks reload.
openclaw hooks list --json,info --json, andcheck --jsonwrite structured JSON directly to stdout.- Plugin-managed hooks cannot be enabled or disabled with the
hookscommand. Enable or disable the owning plugin instead.
Install Hook Packs
Section titled “Install Hook Packs”openclaw plugins install <package> # ClawHub first, then npmopenclaw plugins install <package> --pin # pin versionopenclaw plugins install <path> # local pathInstall hook packs through the unified plugins installer. openclaw hooks install still works as a compatibility alias, but it prints a deprecation warning and forwards to openclaw plugins install.
npm specs are registry-only (package name + optional exact version or dist-tag). Git, URL, and file specs and semver ranges are rejected. Dependency installs run with --ignore-scripts for safety.
Bare specs and @latest stay on the stable track. If npm resolves either of those to a prerelease, OpenClaw stops and asks you to opt in explicitly with a prerelease tag such as @beta/@rc or an exact prerelease version.
What it does:
- Copies the hook pack into
~/.openclaw/hooks/<id> - Enables the installed hooks in
hooks.internal.entries.* - Records the install under
hooks.internal.installs
Options:
-l, --link: Link a local directory instead of copying (adds it tohooks.internal.load.extraDirs)--pin: Record npm installs as exact resolvedname@versioninhooks.internal.installs
Supported archives: .zip, .tgz, .tar.gz, .tar
Examples:
# Local directoryopenclaw plugins install ./my-hook-pack
# Local archiveopenclaw plugins install ./my-hook-pack.zip
# NPM packageopenclaw plugins install @openclaw/my-hook-pack
# Link a local directory without copyingopenclaw plugins install -l ./my-hook-packLinked hook packs are treated as managed hooks from an operator-configured directory, not as workspace hooks.
Update Hook Packs
Section titled “Update Hook Packs”openclaw plugins update <id>openclaw plugins update --allUpdate tracked npm-based hook packs through the unified plugins updater. openclaw hooks update still works as a compatibility alias, but it prints a deprecation warning and forwards to openclaw plugins update.
Options:
--all: Update all tracked hook packs--dry-run: Show what would change without writing
When a stored integrity hash exists and the fetched artifact hash changes, OpenClaw prints a warning and asks for confirmation before proceeding. Use the global --yes to bypass prompts in CI or non-interactive runs.
Bundled Hooks
Section titled “Bundled Hooks”OpenClaw ships a small set of bundled hooks you can enable right away.
session-memory
Section titled “session-memory”Saves session context to memory when you issue /new or /reset.
Enable:
openclaw hooks enable session-memoryOutput: ~/.openclaw/workspace/memory/YYYY-MM-DD-slug.md
See: session-memory documentation
bootstrap-extra-files
Section titled “bootstrap-extra-files”Injects additional bootstrap files (for example monorepo-local AGENTS.md / TOOLS.md) during agent:bootstrap.
Enable:
openclaw hooks enable bootstrap-extra-filesSee: bootstrap-extra-files documentation
command-logger
Section titled “command-logger”Logs all command events to a centralized audit file.
Enable:
openclaw hooks enable command-loggerOutput: ~/.openclaw/logs/commands.log
View logs:
# Recent commandstail -n 20 ~/.openclaw/logs/commands.log
# Pretty-printcat ~/.openclaw/logs/commands.log | jq .
# Filter by actiongrep '"action":"new"' ~/.openclaw/logs/commands.log | jq .See: command-logger documentation
boot-md
Section titled “boot-md”Runs BOOT.md when the gateway starts (after channels start).
Events: gateway:startup
Enable:
openclaw hooks enable boot-mdOpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.