Clarification: Do custom hooks work in Routines cloud environment?

Resolved 💬 2 comments Opened Apr 24, 2026 by michaelhaizmann Closed May 28, 2026

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:

Use Case

We rely on custom hooks for:

  1. PreCompact hook: Serializes conversation state to a persistent markdown file before context compression, preventing loss of mid-session reasoning threads (Conversation State Bridge pattern).
  2. PostCompact hook: Re-injects the serialized state into the compressed context to maintain continuity.
  3. PreToolUse hook: Validates brain file edits against existing knowledge (prevents duplicates and contradictions).
  4. 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

  1. Do custom hooks (PreCompact, PostCompact, PreToolUse, Stop, SessionStart, etc.) fire in the Routines cloud environment?
  2. If yes, are there any limitations (allowed hook types, script requirements, file system access, network restrictions, timeout differences)?
  3. If no, is there a workaround or documented alternative for state preservation across compaction events in Routines?
  4. 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 -p in Docker container on VPS
  • Hooks config: ~/.claude/settings.json with 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗