Skip to main content
Hooks are shell commands that run automatically at specific points in the agent’s lifecycle — before or after tool calls, at session start, when a subagent finishes, and more. They provide deterministic control that doesn’t rely on the agent choosing to do something.
This page covers the ollim-bot-specific config location and a practical example. For the complete event list, input schemas, exit codes, and advanced patterns, see the Claude Code hooks reference.

Configuration location

Because ollim-bot uses setting_sources=["project"], hooks defined in ~/.ollim-bot/.claude/settings.json apply to the main agent session:
~/.ollim-bot/.claude/settings.json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r '.tool_input.file_path' | xargs -I{} sh -c 'cd $(dirname {}) && ruff format {} 2>/dev/null || true'"
          }
        ]
      }
    ]
  }
}
This hook runs ruff format on any file the agent edits, so formatting stays consistent without the agent having to remember.
Changes to settings.json require /restart to take effect.
Hooks can also be scoped narrower:
  • Per-subagent — define a hooks field in a subagent’s .md frontmatter. The hooks activate when that subagent starts and are cleaned up when it finishes.
  • Per-skill — define a hooks field in a skill’s SKILL.md frontmatter. Active only while that skill runs.

Full reference

Claude Code hooks reference

Complete event list, input JSON schemas, exit codes, matcher syntax, and advanced hook types (prompt-based, agent-based, HTTP).

Next steps