← ClaudeAtlas

hedera-hook-creationlisted

This skill should be used when the user asks to "create a hedera hook", "write an agent kit hook", "extend AbstractHook", "add a tool lifecycle hook", "log tool executions", "audit trail hook", "track tool calls", or needs guidance on building observation/logging/metrics extensions for Hedera Agent Kit tools. Hooks are non-blocking — for blocking validation rules use the policy skill instead.
nickthelegend/xorv · ★ 0 · AI & Automation · score 70
Install: claude install-skill nickthelegend/xorv
# Creating Hedera Agent Kit Hooks Hooks are non-blocking extensions that run around the `BaseTool` lifecycle. They observe and can enrich execution: log calls, write audit trails, track metrics, persist state on `Context`. They **do not block** tool execution — that's the job of policies (see `agent-kit-policy` skill). > Hooks fire **only** for tools that extend `BaseTool`. A tool that implements the `Tool` interface directly without extending `BaseTool` bypasses the hook system entirely. ## When to write a hook vs. a policy | If you want to… | Use | |---|---| | Log/audit/track tool calls | **Hook** | | Enrich `Context` (counters, session state) | **Hook** | | Stop a call from happening when a condition holds | **Policy** (see `agent-kit-policy`) | | Reject specific tool methods | **Policy** | Built-in hooks include `HcsAuditTrailHook` and `HolAuditTrailHook` (HCS-backed audit trails) — both live in `@hashgraph/hedera-agent-kit/hooks`. ## The 7-stage lifecycle `BaseTool.execute()` runs: ```text [1] preToolExecutionHook ← hook fires [2] normalizeParams (tool internal) [3] postParamsNormalizationHook ← hook fires [4] coreAction (tool internal) [5] postCoreActionHook ← hook fires [6] secondaryAction (tool internal) [7] postToolExecutionHook ← hook fires ``` Hooks tap into stages 1, 3, 5, 7. They never fire at stages 2, 4, 6. For full param shapes at each stage see `references/lifecycle.md`. ## `AbstractHoo