controller-patterns

Standardize ASP.NET Core API controllers with thin patterns and DTO responses.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Controllers in ASP.NET Core apps are often overloaded with business logic, making maintenance, testing, and evolution difficult. This Skill promotes thin controllers that delegate logic to services and adhere to consistent routing, parameter binding, and DTO-based responses.

Core Features & Use Cases

  • Thin Controller Pattern: keep controllers focused on HTTP concerns; move business logic to services.
  • Routing & Binding: standardizes route attributes, resource naming, and parameter binding (FromBody, FromQuery, FromRoute).
  • DTOs & Responses: encourages separate Create/Update/Response DTOs to avoid exposing domain models.
  • Real-World Use: when reviewing or implementing Task/Entity APIs, apply the patterns to ensure testability and clarity.

Quick Start

Refactor an existing API action to call a service and return a typed response using a DTO.

Frequently Asked Questions about controller-patterns

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

FAQPage Schema
How do I keep ASP.NET Core controllers thin and maintainable?

To keep ASP.NET Core controllers thin, move business logic to dedicated services and focus controllers on HTTP concerns like routing, parameter binding, and DTO-based responses. This separation improves testability and reduces fat controllers.

What is the best way to structure DTOs and responses in an ASP.NET Core API?

The best way to structure responses is using separate Create, Update, and Response DTOs rather than exposing domain models. Return typed ActionResult<T> objects to ensure consistent API contracts and clear validation.

How do I standardize routing and parameter binding in ASP.NET Core web APIs?

Standardize routing by applying consistent route attributes and resource naming. Use explicit parameter binding like FromBody, FromQuery, and FromRoute to enforce predictable API behavior across all controller actions.

Why should I separate business logic from my API controllers?

Separating business logic from API controllers prevents fat controllers, making maintenance and evolution easier. Delegating tasks to services enhances testability and keeps controllers focused strictly on HTTP concerns.

Does the thin controller pattern work for existing Task and Entity APIs?

Yes, the thin controller pattern works for existing Task and Entity APIs. You can refactor current API actions to delegate logic to services and return typed responses using DTOs, ensuring clarity and testability.