claude-code - 💡(How to fix) Fix Clarification: Do custom hooks work in Routines cloud environment? [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52941Fetched 2026-04-25 06:16:38
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3subscribed ×1

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.

Root Cause

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.

Fix Action

Fix / Workaround

  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?
RAW_BUFFERClick to expand / collapse

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.

extent analysis

TL;DR

The issue can be resolved by clarifying whether custom hooks are supported in Routines and understanding any limitations or workarounds for state preservation across compaction events.

Guidance

  • Review the Routines documentation and search for any mentions of custom hook support or limitations.
  • Investigate the SessionStart workaround described in the Better Stack community guide and determine if it can be adapted for custom hooks.
  • Reach out to the Claude Code community or support team to request clarification on custom hook support in Routines.
  • Consider contributing to the documentation or sharing hook configurations to help resolve the ambiguity.

Example

No code snippet is provided as the issue is focused on documentation and support clarification.

Notes

The solution relies on clarifying the support and limitations of custom hooks in Routines, which may require input from the Claude Code team or community.

Recommendation

Apply workaround: Until official clarification is provided, explore adapting the SessionStart workaround or other creative solutions to achieve the desired functionality, while also reaching out to the Claude Code team for official support and documentation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Clarification: Do custom hooks work in Routines cloud environment? [1 participants]