What problem does it solve? Building custom middleware in ASP.NET Core is error-prone: incorrect pipeline ordering causes subtle bugs, scoped services fail in singleton middleware, and response manipulation breaks downstream components. This Skill provides tested patterns for creating, ordering, and testing middleware correctly. ## Core Features & Use Cases - Pipeline Ordering Guidance: Documents the correct registration order for exception handling, routing, CORS, authentication, and authorization, with a table of common ordering mistakes and their consequences. - Ten Middleware Patterns: Covers convention-based middleware, factory-based IMiddleware, inline app.Use/app.Run/app.Map, short-circuit logic, request/response body manipulation, IExceptionHandler (.NET 8+), conditional branching with UseWhen/MapWhen, options-based configuration, and unit testing. - Use Case: When adding API key authentication to an ASP.NET Core API, use the short-circuit pattern to reject unauthorized requests with a 401 JSON response before they reach your controllers, and place it after UseAuthorization in the pipeline. ## Quick Start Ask the agent to create a custom ASP.NET Core middleware that logs request timing and explain where to register it in the pipeline.