patternschain-of-responsibility

Chain of Responsibility Pattern pattern for C development

⭐1stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026

When & Why to Use This Skill

This Claude skill provides a robust implementation of the Chain of Responsibility design pattern specifically tailored for C development. It enables developers to build highly modular and extensible systems by decoupling request senders from receivers, allowing multiple handlers to process a request sequentially without tight coupling.

Use Cases

  • Input Processing Pipelines: Efficiently routing raw bytes through sequential stages such as escape sequence detection, UTF-8 assembly, and action mapping.
  • Command Dispatch Systems: Implementing flexible command handling where multiple potential handlers are checked in order until a match is found, ideal for CLI or REPL environments.
  • Middleware Integration: Creating a processing chain for tool execution that handles cross-cutting concerns like authentication, logging, and rate limiting.
  • Error Recovery Chains: Establishing a sequence of fallback strategies to handle system errors or exceptions in a structured, maintainable way.
namepatterns/chain-of-responsibility
descriptionChain of Responsibility Pattern pattern for C development

Chain of Responsibility Pattern

Pass request along a chain of handlers until one handles it. Each handler decides to process or pass to next. In C, linked list of handler functions.

ikigai Application

Input processing: Bytes flow through: escape sequence detector → UTF-8 assembler → action mapper → REPL handler.

Command dispatch: Try slash command handlers in order until one matches.

Future uses:

  • Middleware for tool execution (auth, logging, rate limiting)
  • Message preprocessing pipeline
  • Error recovery chain

Implementation:

typedef res_t (*handler_fn)(void *ctx, request_t *req, handler_fn next);

Benefit: Add/remove processing steps without modifying existing handlers.