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 usessetting_sources=["project"], hooks defined in ~/.ollim-bot/.claude/settings.json apply to the main agent session:
~/.ollim-bot/.claude/settings.json
ruff format on any file the agent edits, so formatting stays consistent without the agent having to remember.
Hooks can also be scoped narrower:
- Per-subagent — define a
hooksfield in a subagent’s.mdfrontmatter. The hooks activate when that subagent starts and are cleaned up when it finishes. - Per-skill — define a
hooksfield in a skill’sSKILL.mdfrontmatter. Active only while that skill runs.
Built-in hooks
ollim-bot registers its own hooks on the main session via the SDKhooks parameter — separate from the settings.json hooks above. These run for every session automatically.
| Hook | Event | Matcher | Purpose |
|---|---|---|---|
state_dir_guard | PreToolUse | Write|Edit | Blocks writes targeting paths inside state/. See state directory write-protection. |
routine_validator | PreToolUse | Write|Edit | Validates routine .md files before they’re written. |
auto_commit_hook | PostToolUse | Write|Edit | Auto-commits markdown writes inside the data directory. |
tool_error_hook | PostToolUse | any | Marks a tool label as errored when the tool returns is_error: true. |
tool_failure_hook | PostToolUseFailure | any | Marks a tool label as errored on hard execution failure. |
require_report_hook | Stop | any | Enforces the background fork report contract. |
Routine validator
When the agent writes or edits a file inside~/.ollim-bot/routines/, the routine_validator hook simulates the resulting content and runs it through validate_routine() before the write lands on disk.
Blocks (the write is denied):
- Missing frontmatter — routine files require YAML between
---markers - Missing
id— required for scheduler job registration - Missing
cron— required for scheduling - Invalid cron — must have exactly 5 whitespace-separated fields
- Malformed YAML — unclosed frontmatter or lines that don’t parse
- Missing
descriptionorbackground— degrades schedule display and defaults - Unscoped
Bash,Write,Edit, orMultiEditinallowed-tools— should be restricted with a path pattern likeBash(ollim-bot cal *) - Delegation (
Task/Agent) combined with unscopedWrite/Edit— subagent output may land in shared files without verification - Underscore keys where canonical form is hyphenated (
allowed_toolsvsallowed-tools) - Unknown frontmatter keys
- Routine longer than 200 lines
Write and Edit — for Edit, it simulates the string replacement against the current file contents. When it rejects a write, the denial reason is prefixed with routine-validator: so you can find it in the permission surface.
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
Subagents
Per-subagent hooks in frontmatter — scoped to a single subagent’s lifecycle.
Skills
Per-skill hooks in frontmatter — active only while a skill runs.
