add-hook

Register async lifecycle callbacks and context hooks for Renfield plugins.

34|5|Updated Jan 15, 2026
One-click install
npx skills add https://github.com/ebongard/renfield --skill add-hook
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-hook
Source: https://github.com/ebongard/renfield/tree/main/.claude/skills/add-hook
Command: npx skills add https://github.com/ebongard/renfield --skill add-hook

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Enables developers to extend Renfield by registering asynchronous callbacks at well-defined lifecycle and message insertion points so external packages can inject context, post-process messages, add API routes, or register agent tools without modifying core code.

Core Features & Use Cases

  • Async Hook Registration: Register async callbacks for events like startup, shutdown, register_routes, register_tools, post_message, post_document_ingest, and retrieve_context.
  • Context Injection & Post-Processing: Inject additional LLM context during retrieval and run fire-and-forget post-processing for analytics, knowledge extraction, or moderation.
  • Agent & API Extensions: Add custom agent tools to the Agent Loop and mount additional FastAPI routers for plugin functionality.
  • Use Case: Implement a plugin that extracts entities from every chat exchange, supplies context from an external knowledge graph, and registers a custom agent tool to act on user intents.

Quick Start

Create an async register() that calls register_hook for the events you need and set the PLUGIN_MODULE environment variable to my_plugin.hooks:register so Renfield loads your plugin at startup.

Frequently Asked Questions about add-hook

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add async plugin hooks to extend my FastAPI application?

To add async plugin hooks, register asynchronous callbacks at lifecycle events like startup or post_message so external packages can inject context and register tools without modifying core code. Use a module:callable loader to mount plugins dynamically.

Can I inject additional LLM context during chat retrieval without altering the core agent loop?

Injecting additional LLM context during chat retrieval is possible by registering a retrieve_context hook that returns a string or None, enabling external data sources to seamlessly augment the agent's prompt without core code modifications.

How do I register custom agent tools and mount API routes asynchronously?

Register custom agent tools and mount API routes asynchronously by hooking into the register_tools and register_routes lifecycle events, allowing external packages to extend FastAPI routers and agent capabilities through isolated async callbacks.

What is the best way to post-process chat messages for analytics in an async workflow?

The best way to post-process chat messages for analytics is using fire-and-forget post_message hooks, which execute asynchronously after message delivery to run knowledge extraction or moderation without blocking the primary chat response.

Do I need a specific environment variable to load async plugins?

You need to set the PLUGIN_MODULE environment variable to a module:callable format pointing to your async register function, ensuring the application loads your plugin and its hooks safely at startup with isolated error handling.

Why does my retrieve_context hook fail to inject context into the chat workflow?

Retrieve_context hooks fail to inject context if they do not return a string or None as required, or if underlying plugin errors are silently suppressed by the isolated error handling semantics designed to prevent core application crashes.