[FEATURE] Hook performance: persistent daemon eliminates process spawning overhead (112x faster)

Resolved 💬 2 comments Opened Mar 26, 2026 by mauribadnights Closed Apr 25, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Problem

Each hook invocation spawns a fresh process. For users with many hooks (15+), this adds ~4 seconds of overhead per session. The cost scales linearly with hook count and is felt on every prompt.

Proposed Solution

Proposed solution

A persistent HTTP daemon that handles hook dispatch. Claude Code already supports HTTP hooks natively, pointing them at a long-lived local server eliminates the spawning overhead entirely.
I built this as an open-source tool (clooks) and have been running it in production:

| | Command hooks | clooks daemon |
|---|---|---|
| Single invocation | ~34.6ms | ~0.31ms |
| Full session (120 calls) | ~3,986ms | ~23ms |

The architecture also enables features that are hard to do with per-invocation spawning:

  • Handler dependency resolution (topological execution waves)
  • LLM handler batching (multiple handlers share one API call)
  • Hot-reload on config changes
  • Metrics and hook cost tracking

GitHub: https://github.com/mauribadnights/clooks
Benchmarks: npm install -g @mauribadnights/clooks && npm run bench

Not suggesting you merge this, just sharing the approach and benchmarks in case it's useful for the hooks roadmap. Happy to discuss the architecture.

Alternative Solutions

The current workaround is exactly what clooks does, use the existing HTTP hook type to point at a local daemon instead of spawning command hooks. This works well today and requires no changes to Claude Code. The feature request is more about whether this pattern is worth adopting natively to benefit all users without requiring a third-party tool.

Priority

Medium - Would be very helpful

Feature Category

Performance and speed

Use Case Example

I run 15+ hooks across SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, and Stop — safety guards, frontmatter validation, git hygiene, ALM context injection, auto-rename, session tracking. Each prompt triggers 5-8 of these. At ~35ms per spawn, that's 175-280ms of dead time on every single interaction, adding up to ~4 seconds across a full session. With a persistent daemon, the same hooks complete in ~23ms total for the entire session.

Additional Context

_No response_

View original on GitHub ↗

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