The session-memory hook saves session context to memory files when /new is run, which is useful internal housekeeping. However, the confirmation message that was displayed to users (showing the file path) leaked implementation details. This change removes the user-visible message while keeping the console.log for debugging purposes. The hook continues to save session context silently.
Bundled Hooks
This directory contains hooks that ship with Clawdbot. These hooks are automatically discovered and can be enabled/disabled via CLI or configuration.
Available Hooks
💾 session-memory
Automatically saves session context to memory when you issue /new.
Events: command:new
What it does: Creates a dated memory file with LLM-generated slug based on conversation content.
Output: <workspace>/memory/YYYY-MM-DD-slug.md (defaults to ~/clawd)
Enable:
clawdbot hooks enable session-memory
📝 command-logger
Logs all command events to a centralized audit file.
Events: command (all commands)
What it does: Appends JSONL entries to command log file.
Output: ~/.clawdbot/logs/commands.log
Enable:
clawdbot hooks enable command-logger
😈 soul-evil
Swaps injected SOUL.md content with SOUL_EVIL.md during a purge window or by random chance.
Events: agent:bootstrap
What it does: Overrides the injected SOUL content before the system prompt is built.
Output: No files written; swaps happen in-memory only.
Docs: https://docs.clawd.bot/hooks/soul-evil
Enable:
clawdbot hooks enable soul-evil
🚀 boot-md
Runs BOOT.md whenever the gateway starts (after channels start).
Events: gateway:startup
What it does: Executes BOOT.md instructions via the agent runner.
Output: Whatever the instructions request (for example, outbound messages).
Enable:
clawdbot hooks enable boot-md
Hook Structure
Each hook is a directory containing:
- HOOK.md: Metadata and documentation in YAML frontmatter + Markdown
- handler.ts: The hook handler function (default export)
Example structure:
session-memory/
├── HOOK.md # Metadata + docs
└── handler.ts # Handler implementation
HOOK.md Format
---
name: my-hook
description: "Short description"
homepage: https://docs.clawd.bot/hooks#my-hook
metadata:
{ "clawdbot": { "emoji": "🔗", "events": ["command:new"], "requires": { "bins": ["node"] } } }
---
# Hook Title
Documentation goes here...
Metadata Fields
- emoji: Display emoji for CLI
- events: Array of events to listen for (e.g.,
["command:new", "session:start"]) - requires: Optional requirements
- bins: Required binaries on PATH
- anyBins: At least one of these binaries must be present
- env: Required environment variables
- config: Required config paths (e.g.,
["workspace.dir"]) - os: Required platforms (e.g.,
["darwin", "linux"])
- install: Installation methods (for bundled hooks:
[{"id":"bundled","kind":"bundled"}])
Creating Custom Hooks
To create your own hooks, place them in:
- Workspace hooks:
<workspace>/hooks/(highest precedence) - Managed hooks:
~/.clawdbot/hooks/(shared across workspaces)
Custom hooks follow the same structure as bundled hooks.
Managing Hooks
List all hooks:
clawdbot hooks list
Show hook details:
clawdbot hooks info session-memory
Check hook status:
clawdbot hooks check
Enable/disable:
clawdbot hooks enable session-memory
clawdbot hooks disable command-logger
Configuration
Hooks can be configured in ~/.clawdbot/clawdbot.json:
{
"hooks": {
"internal": {
"enabled": true,
"entries": {
"session-memory": {
"enabled": true
},
"command-logger": {
"enabled": false
}
}
}
}
}
Event Types
Currently supported events:
- command: All command events
- command:new:
/newcommand specifically - command:reset:
/resetcommand - command:stop:
/stopcommand - agent:bootstrap: Before workspace bootstrap files are injected
- gateway:startup: Gateway startup (after channels start)
More event types coming soon (session lifecycle, agent errors, etc.).
Handler API
Hook handlers receive an InternalHookEvent object:
interface InternalHookEvent {
type: "command" | "session" | "agent" | "gateway";
action: string; // e.g., 'new', 'reset', 'stop'
sessionKey: string;
context: Record<string, unknown>;
timestamp: Date;
messages: string[]; // Push messages here to send to user
}
Example handler:
import type { HookHandler } from "../../src/hooks/hooks.js";
const myHandler: HookHandler = async (event) => {
if (event.type !== "command" || event.action !== "new") {
return;
}
// Your logic here
console.log("New command triggered!");
// Optionally send message to user
event.messages.push("✨ Hook executed!");
};
export default myHandler;
Testing
Test your hooks by:
- Place hook in workspace hooks directory
- Restart gateway:
pkill -9 -f 'clawdbot.*gateway' && pnpm clawdbot gateway - Enable the hook:
clawdbot hooks enable my-hook - Trigger the event (e.g., send
/newcommand) - Check gateway logs for hook execution
Documentation
Full documentation: https://docs.clawd.bot/hooks