Skip to main content

Module hook

Module hook 

Source
Expand description

Hook binary logic — reads .symforge/sidecar.port, calls sidecar over sync HTTP, and outputs a single JSON line to stdout.

Design constraints (HOOK-10):

  • The ONLY thing written to stdout is the final JSON line.
  • No tokio runtime. No tracing to stdout. No eprintln except for genuine errors.
  • Sync I/O throughout — hooks must complete in well under 100 ms.
  • Fail-open: if the sidecar is unreachable for any reason, output empty additionalContext JSON so Claude Code continues normally.

Functions§

event_name_for
Returns the hookEventName string for a given subcommand.
fail_open_json
Returns the fail-open JSON: empty additionalContext.
run_hook
Entry point called by main.rs for symforge hook [subcommand].
success_json
Returns the success JSON with context as the additionalContext value.