Clarification: Do custom hooks work in Routines cloud environment?
Summary
The hooks documentation confirms that hooks work in headless mode (claude -p), but makes no explicit statement about Routines (cloud-scheduled Claude Code runs). This ambiguity blocks production adoption of Routines for workflows that depend on PreCompact, PostCompact, PreToolUse, or similar custom hooks.
Context
Research over several weeks could not find a definitive answer:
- Official hooks docs: https://code.claude.com/docs/en/hooks — confirms headless mode parity
- Routines docs: https://code.claude.com/docs/en/routines — no mention of hook support
- Better Stack community guide (https://betterstack.com/community/guides/ai/claude-code-routines/) describes a SessionStart workaround for skills injection in Routines, but does not address custom hooks
- GitHub issues search: no matching open issue
Use Case
We rely on custom hooks for:
- PreCompact hook: Serializes conversation state to a persistent markdown file before context compression, preventing loss of mid-session reasoning threads (Conversation State Bridge pattern).
- PostCompact hook: Re-injects the serialized state into the compressed context to maintain continuity.
- PreToolUse hook: Validates brain file edits against existing knowledge (prevents duplicates and contradictions).
- SessionStart hook: Loads project-specific context and agent routing logic.
All four currently work in interactive and headless modes. We are evaluating Routines for scheduled autonomous research loops (Karpathy autoresearch pattern, adapted to knowledge work).
Specific Questions
- Do custom hooks (PreCompact, PostCompact, PreToolUse, Stop, SessionStart, etc.) fire in the Routines cloud environment?
- If yes, are there any limitations (allowed hook types, script requirements, file system access, network restrictions, timeout differences)?
- If no, is there a workaround or documented alternative for state preservation across compaction events in Routines?
- Is the behavior documented anywhere, or planned to be documented?
Environment
- Claude Code version: v2.1.118+
- Current setup: headless mode via launchd on macOS +
claude -pin Docker container on VPS - Hooks config:
~/.claude/settings.jsonwith custom bash scripts for all four hook types - Use case: Production autonomous research loops + PKM compilation automation
Why This Matters
Without clarity on hook support, we cannot evaluate whether Routines is production-ready for workflows that depend on hooks. An explicit yes/no (and any limitations) would unblock adoption decisions for many power-user setups.
Happy to provide more context, share hook configurations, or contribute to docs if that helps.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗