/backend-csharp:csharp-mvcfrom backend-csharp
Use when implementing ASP.NET Core MVC controllers, actions, views, model binding, filters, and routing. Triggers when creating or modifying controller classes, action methods, view models, or MVC middleware in a C# project.
Ships in backend-csharp. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Implement correct, idiomatic ASP.NET Core MVC patterns — controllers, actions, model binding, validation, routing, and filters — following .NET 8 conventions.
Controller suffix: OrdersController, UsersControllerProcessPayment, CancelOrderViewModel or Dto: CreateOrderViewModel, OrderSummaryDto[ApiController] // for Web API — enables automatic model validation + 400 responses
[Route("api/[controller]")]
public class OrdersController : ControllerBase { }
// For MVC with views:
[Route("[controller]/[action]")]
public class OrdersController : Controller { }
| Scenario | Return Type |
|---|---|
| Web API success | ActionResult<T> or IActionResult |
| MVC view | IActionResult |
| Always async | Task<IActionResult> or Task<ActionResult<T>> |
[HttpGet("{id:int}")]
public async Task<ActionResult<OrderDto>> GetById(int id)
{
var order = await _orderService.GetByIdAsync(id);
if (order is null) return NotFound();
return Ok(order);
}
[HttpPost]
public async Task<ActionResult<OrderDto>> Create([FromBody] CreateOrderRequest request)
{
var created = await _orderService.CreateAsync(request);
return CreatedAtAction(nameof(GetById), new { id = created.Id }, created);
}
[FromBody] // JSON/XML body (default for complex types in ApiController)
[FromRoute] // Route segment: /orders/{id}
[FromQuery] // Query string: ?page=1&size=10
[FromHeader] // HTTP header
[FromForm] // HTML form data or multipart
[FromServices] // Dependency injection (not user input)
Use DataAnnotations or FluentValidation — never validate manually in controller actions:
public class CreateOrderRequest
{
[Required]
[StringLength(200, MinimumLength = 1)]
public string CustomerName { get; set; } = string.Empty;
[Range(1, int.MaxValue, ErrorMessage = "Quantity must be at least 1")]
public int Quantity { get; set; }
[EmailAddress]
public string? ContactEmail { get; set; }
}
With [ApiController], validation failures automatically return 400 Bad Request with the ModelState error details — do not check ModelState.IsValid manually.
[HttpGet] // GET /api/orders
[HttpGet("{id:int}")] // GET /api/orders/5
[HttpGet("{id:int}/items")] // GET /api/orders/5/items
[HttpPost] // POST /api/orders
[HttpPut("{id:int}")] // PUT /api/orders/5
[HttpPatch("{id:int}")] // PATCH /api/orders/5
[HttpDelete("{id:int}")] // DELETE /api/orders/5
{id:int} // integer only
{id:guid} // GUID
{id:min(1)} // minimum value
{name:alpha} // letters only
{id:int:min(1)} // combined
// Apply globally in Program.cs:
builder.Services.AddControllers(options =>
options.Filters.Add<CorrelationIdFilter>());
// Apply to controller or action:
[ServiceFilter(typeof(AuditLogFilter))]
public class OrdersController : ControllerBase { }
Use a global exception filter or middleware — never catch generic exceptions in controller actions:
// Program.cs
app.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
context.Response.StatusCode = 500;
await context.Response.WriteAsJsonAsync(new { error = "An unexpected error occurred." });
});
});
Always inject via constructor; never use ServiceLocator or static access:
public class OrdersController : ControllerBase
{
private readonly IOrderService _orderService;
private readonly ILogger<OrdersController> _logger;
public OrdersController(IOrderService orderService, ILogger<OrdersController> logger)
{
_orderService = orderService;
_logger = logger;
}
}
ViewModel classes per view — never pass domain entities to viewsSelectList for dropdown data; populate in controller, not view// View model
public class CreateOrderViewModel
{
[Required]
public string CustomerName { get; set; } = string.Empty;
public IEnumerable<SelectListItem> Products { get; set; } = [];
}
<!-- Razor view with Tag Helpers -->
<form asp-controller="Orders" asp-action="Create" method="post">
<input asp-for="CustomerName" class="form-control" />
<span asp-validation-for="CustomerName" class="text-danger"></span>
<select asp-for="ProductId" asp-items="Model.Products"></select>
<button type="submit">Create</button>
</form>
ControllerBase (API) or Controller (MVC with views)[ApiController] attribute applied to Web API controllersasync Task<...> for I/O-bound operations[controller]/[action] tokens or explicit pathsDataAnnotations or FluentValidation, not manuallyCreatedAtAction used for POST that creates a resourceHttpContext.RequestServicestry/catch for general exceptions — handled via global middlewareWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gagandeepp/software-agent-teams --plugin backend-csharp7 skills in this plugin
/csharp-codingUse when writing or reviewing C# code — enforces idiomatic C# patterns including naming conventions, async/await, nullable reference types, LINQ, pattern matching, error handling, and dependency injection/csharp-ef-coreUse when configuring Entity Framework Core — DbContext setup, entity configurations, relationships, migrations, queries, and repository implementations. Triggers when adding a new entity, configuring mappings, writing LINQ queries, or managing migrations in a C# .NET project./csharp-frameworksUse when implementing ASP.NET Core features — enforces Clean Architecture with CQRS, MediatR command/query handlers, FluentValidation, minimal APIs vs controllers, middleware pipeline, and IdentityServer4 JWT auth patterns