MeowKit

Middleware Layer

The shell hooks that intercept between model and tools — build verify, loop detection, pre-completion gate, project context loader.

See also: Hooks Reference — the full hooks table with events and matchers.

Middleware hooks are thin shell scripts between the model and its tools. They intercept Claude Code events (file writes, session start/stop, prompt submissions) and inject feedback or context — without any agent or skill involvement.

Why middleware exists

Agents write code, re-read their own code, declare it good, stop.

This is the failure mode the middleware layer was built to interrupt. Without external feedback, an agent edits a file, reads it back, decides it looks correct, and stops — without running tests or verification.

The four hooks

HookEventPurpose
post-write-build-verify.shPostToolUse (Edit|Write)Compile/lint on source writes; hash-cached to skip unchanged files. Never blocks — feedback only.
post-write-loop-detection.shPostToolUse (Edit|Write)Warns at 4 edits to same file, escalates at 8. Cleared per session.
pre-completion-check.shStopBlocks session end without verification evidence. 3-attempt guard. LEAN: soft nudge only. MINIMAL: skipped.
project-context-loader.shSessionStartInjects directory tree, tool availability, package scripts. Resets per-session state.

Key properties

  • Cheap — each hook runs in milliseconds.
  • Composable — hooks are independent. Adding or removing one doesn't affect others.
  • Pruneable — measured via dead-weight audit. If a hook stops paying its delta, it can be removed.
  • Zero awareness — agents have no awareness of middleware. They see feedback in context but don't know its source.

Opt-out matrix

Env varEffect
MEOWKIT_BUILD_VERIFY=offSkip build verify
MEOWKIT_LOOP_DETECT=offSkip loop detection
MEOWKIT_PRECOMPLETION=offSkip pre-completion check
MEOWKIT_AUTOBUILD_MODE=LEANPreCompletion: soft nudge; BuildVerify: still runs
MEOWKIT_AUTOBUILD_MODE=MINIMALSkip BuildVerify + PreCompletion

Next steps

On this page