service-patterns

Standardize .NET backend business logic into interfaces, services, and structured logging.

Updated Dec 8, 2025
One-click install
npx skills add https://github.com/Joshua-Palamuttam/claude-code-presentation --skill service-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: service-patterns
Source: https://github.com/Joshua-Palamuttam/claude-code-presentation/tree/main/marketplace/plugins/dotnet-backend/skills/service-patterns
Command: npx skills add https://github.com/Joshua-Palamuttam/claude-code-presentation --skill service-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Services contain all business logic. They are the heart of the application, orchestrating operations between controllers and data access.

Core Features & Use Cases

  • Interface-Based Design: Always define an interface for each service
  • ServiceResult Pattern: Use a result wrapper that indicates success/failure and error type
  • Business Logic Encapsulation: Place all business rules in services, not controllers
  • Structured Logging: Employ semantic logging with named parameters and appropriate levels
  • Error Handling: Let unexpected exceptions bubble to a global handler
  • Mapping & Registration: Map domain models to responses and register services in DI

Quick Start

Register the service in your DI container and begin using the service methods in your controllers

Frequently Asked Questions about service-patterns

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

FAQPage Schema
What is the ServiceResult pattern for backend error handling?

The ServiceResult pattern is a result wrapper that indicates success or failure and error type. It standardizes backend error handling by returning structured responses from services instead of throwing exceptions for expected business logic failures.

How do I structure business logic in .NET backend services?

Structure .NET backend services by encapsulating all business rules in service implementations rather than controllers. Always define an interface for each service and register them in the dependency injection container to ensure clean separation of concerns.

How does semantic logging work with structured service patterns?

Semantic logging uses named parameters and appropriate log levels to provide structured context. It records service operations predictably, improving maintainability and testability across backend data access and controller interactions.

Can I use dependency injection for mapping domain models to responses?

Yes, you can use dependency injection for mapping. Register mapping services in your DI container alongside other services to map domain models to responses, ensuring predictable behavior and clean composition within your .NET backend.

When should unexpected exceptions bubble up in backend service design?

Unexpected exceptions should bubble to a global handler in backend service design. Letting them propagate avoids masking critical failures, while expected business logic failures return structured ServiceResult wrappers for predictable application behavior.

What's the best way to separate concerns between controllers and data access?

The best way to separate concerns is using interface-based service patterns. Services orchestrate operations between controllers and data access, containing all business logic, while controllers handle request mapping and response formatting.