Skip to content

Hooks & Event Automation

Automate your AI coding workflow with 10 event hooks. Run shell scripts or HTTP calls on SessionStart, PreToolUse, PostToolUse and more. GDPR-compliant.

11 Event Types

SessionStart/End, Pre/PostToolUse, and more, hook precisely into the lifecycle.

Command Hooks

Attach shell commands to events, lint, test, notify.

HTTP Hooks

Webhooks to internal or external services, CI, ChatOps, monitoring.

Plugin Hooks

Plugins react to the same events, extend without patching core.

Hook Validation

Validate configuration before it goes live, fewer surprises in production.

Hook Templates (/create-hook)

Quick start with `/create-hook`, boilerplate for common automation.

The 10 Hook Events

Every significant moment in the agent lifecycle has a corresponding hook event. Subscribe to one or many.

Event When Use Case
SessionStart Session opens Check environment, load secrets, notify team
SessionEnd Session closes Summarize work, post summary to Slack
PreToolUse Before any tool call Logging, rate limiting, input validation
PostToolUse After successful tool call Audit trail, metrics, test runner
PostToolUseFailure After failed tool call Alert, fallback, error reporting
UserPromptSubmit User sends a message Input filtering, profanity guard
SubagentStart Subagent spawned Resource tracking, cost monitoring
Stop Agent stops Cleanup, git commit, deploy trigger
PreCompact Before context compaction Save important context to file
Notification Agent sends notification Route to preferred channel

Create a Hook

Use /create-hook to scaffold a hook file. The AI generates the boilerplate for Shell or TypeScript hooks.

/create-hook PreToolUse my-logger Shell hook — runs before every tool call
/create-hook PostToolUse audit --ts TypeScript hook — after every tool call
/create-hook SessionEnd notify Hook runs when the session ends

Example: Audit-Log Hook

Log every tool call to a file — useful for compliance, debugging, and tracking AI actions.

.lurus/hooks/pre-tool-use.sh
#!/bin/bash
# .lurus/hooks/pre-tool-use.sh
# Logs every tool call with timestamp

echo "$(date -u +'%Y-%m-%dT%H:%M:%SZ') [TOOL] $TOOL_NAME $TOOL_INPUT" >> .lurus/audit.log

Ready to code smarter?

Get started and automate Lurus Code with hooks and events.

Get started