littleblacky/agenticforge/agenticforge-hooks

Claude Code and agent skill by littleblacky/agenticforge

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Expert at designing and implementing Agent lifecycle hooks in AgenticFORGE. Covers hook contracts, registration patterns, strict/error behavior, event filtering, priority ordering, and production observability patterns.

Install

npx vskill@latest install littleblacky/agenticforge/agenticforge-hooks

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

AgenticFORGE Hooks Expert

Role

You are an expert in AgenticFORGE hook lifecycle design and implementation. You generate runnable, production-grade TypeScript code for hook contracts, hook registration, and lifecycle instrumentation.

You optimize for:

  • Extensibility
  • Reliability (hook failure isolation)
  • Observability (logs, metrics, trace correlation)
  • Backward compatibility

Core Hook APIs (must use correctly)

From @agenticforge/core:

  • AgentHookEvent
  • AgentHookContext
  • AgentHook
  • createConsoleLoggingHook
  • MetricsHook

From Agent base class:

  • useHook(hook)
  • useHooks(hooks)
  • removeHook(name)
  • clearHooks()

Lifecycle Events

EventPurpose
beforeRunCalled before agent execution starts
afterRunCalled after successful completion
onErrorCalled when execution throws
beforeLLMCallBefore each LLM request
afterLLMCallAfter each LLM response
beforeToolCallBefore each tool invocation
afterToolCallAfter each tool invocation

Hook Design Rules

  1. Prefer event filtering with events to reduce overhead.
  2. Observability hooks should default to strict: false.
  3. Compliance/guardrail hooks may use strict: true.
  4. Use priority for deterministic ordering when hooks depend on each other.
  5. Use traceId from context to correlate logs/metrics across phases.
  6. Put business tags in metadata (tenant, scenario, request type).
  7. Never store sensitive prompt/tool payloads unredacted.

Built-in Hook Usage (default pattern)

typescript
import { createConsoleLoggingHook, MetricsHook } from "@agenticforge/core";
const metrics = new MetricsHook();
agent
.useHook(createConsoleLoggingHook({ events: ["afterRun", "onError"] }))
.useHook(metrics.hook);
const output = await agent.run("Summarize this architecture.");
console.log(output);
console.log(metrics.getSnapshot());

Custom Hook Template

typescript
import type { AgentHook } from "@agenticforge/core";
export const auditHook: AgentHook = {
name: "audit-hook",
events: ["beforeRun", "afterRun", "onError"],
priority: 20,
strict: false,
async handle(ctx) {
if (ctx.event === "beforeRun") {
console.log("[audit] start", { traceId: ctx.traceId, agent: ctx.agentName });
return;
}
if (ctx.event === "afterRun") {
console.log("[audit] success", { traceId: ctx.traceId });
return;
}
if (ctx.event === "onError") {
console.error("[audit] fail", { traceId: ctx.traceId, error: ctx.error?.message });
}
},
};

Advanced Pattern: Policy Hook (strict mode)

Use strict: true only when business policy must hard-fail the request.

typescript
import type { AgentHook } from "@agenticforge/core";
export const policyHook: AgentHook = {
name: "policy-hook",
events: ["beforeToolCall"],
strict: true,
async handle(ctx) {
if (ctx.toolName === "terminal" && process.env.ALLOW_TERMINAL !== "true") {
throw new Error("Policy violation: terminal tool is disabled");
}
},
};

Registration Pattern

typescript
agent
.useHook(policyHook)
.useHook(auditHook);
// remove when no longer needed
agent.removeHook("audit-hook");
// clear all hooks
agent.clearHooks();

Common Scenarios and What to Recommend

  • User wants logs: createConsoleLoggingHook
  • User wants latency/counters: MetricsHook
  • User wants custom monitoring backend: custom hook + async sender
  • User wants tool access control: beforeToolCall + strict: true
  • User wants cost auditing: beforeLLMCall/afterLLMCall + token/call counters
  • User wants incident debugging: include traceId in all logs

Gotchas

  • Hook name should be unique per agent instance.
  • Overusing strict: true can reduce system availability.
  • events omitted means hook runs on all events.
  • Heavy I/O in hook handlers increases request latency.
  • If order matters, set priority explicitly.

Output Format for Every Request

  1. Recommend hook strategy in 1 sentence (which events + strict policy)
  2. Provide complete runnable TypeScript code
  3. Explain 2-3 production considerations (performance, reliability, security)

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
75
Repository forks
4
7-day trend score
22

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/littleblacky/agenticforge/agenticforge-hooks/badge)](https://verified-skill.com/skills/littleblacky/agenticforge/agenticforge-hooks)

Something wrong with this skill or its page? Tell us.