handler

Implement Handler layers coordinating repositories with Result Pattern error handling.

Updated Dec 23, 2025
One-click install
npx skills add https://github.com/yaochangyu/ai-dev-toolkit --skill handler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: handler
Source: https://github.com/yaochangyu/ai-dev-toolkit/tree/main/.github/skills/handler
Command: npx skills add https://github.com/yaochangyu/ai-dev-toolkit --skill handler

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve?

This Skill provides a structured approach to implementing a consistent Handler layer that encapsulates business logic, coordinates across repositories, and applies the Result Pattern for error handling without throwing exceptions.

Core Features & Use Cases

  • Business logic implementation: Encapsulates rules, validation, and orchestration across repositories.
  • Error handling with Result Pattern: Returns Result<T, Failure> and preserves original exceptions for observability.
  • Async execution and cancellation: All I/O operations use async/await with CancellationToken support.
  • Cross-repository transactions: Coordinates multiple repositories within a transactional boundary when needed.

Quick Start

Use this skill to implement a Handler that coordinates two repositories within a transaction and returns a Result as the outcome.

Frequently Asked Questions about handler

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

FAQPage Schema
How do I implement a business logic handler that coordinates cross-repository transactions asynchronously?

Build a handler layer using the Result Pattern to encapsulate business logic and coordinate repositories within a transactional boundary. All I/O operations use async/await with CancellationToken support to ensure safe asynchronous workflows.

Why does the Result Pattern help with non-throwing error handling in backend services?

The Result Pattern returns Result<T, Failure> instead of throwing exceptions, preserving original exceptions inside the Failure object. This approach provides clean error handling and maintains observability through integrated TraceContext without disrupting async execution flows.

What's the best way to separate controllers from data access using a handler layer?

Implement a handler layer to orchestrate business rules, validation, and repository interactions between controllers and data access. This enforces a clean separation of concerns while supporting dependency injection and cancellation tokens for responsive backend services.

Does this handler pattern support dependency injection and cancellation tokens for async workflows?

Yes, the handler pattern fully supports dependency injection and CancellationToken for asynchronous workflows. It applies to backend services requiring safe, async flow management with non-throwing error handling and integrated TraceContext observability.

Can I manage transactions across multiple repositories without throwing exceptions in my business logic?

Yes, coordinate multiple repositories within a transactional boundary using the Result Pattern to return Result<T, Failure>. This non-throwing approach preserves original exceptions for observability while maintaining clean separation between controllers and data access.