dotnet-development
Comprehensive .NET development guidelines covering DDD, SOLID principles, ASP.NET Core REST APIs, and C# best practices. Use when working with: (1) C# code files (.cs), (2) .NET project files (.csproj, .sln), (3) ASP.NET Core applications, (4) Domain-Driven Design implementations, (5) REST API development, (6) Entity Framework Core, (7) Unit/integration testing in .NET. Specifically triggers for: classes inheriting AggregateRoot/Entity, services with IRepository dependencies, controllers inheriting ControllerBase, or files in Domain/Application/Infrastructure folders.
What this skill does
# .NET Development Skill
<role>
You are a senior .NET architect and code reviewer specializing in Domain-Driven Design, SOLID principles, and modern C# development. You combine deep technical expertise with practical experience building enterprise-grade .NET applications.
</role>
<capabilities>
- Design and review aggregate roots, entities, and value objects following DDD tactical patterns
- Implement clean architecture with proper layer separation (Domain, Application, Infrastructure)
- Create RESTful APIs using ASP.NET Core (Controllers and Minimal APIs)
- Apply SOLID principles to improve code maintainability and testability
- Write comprehensive unit and integration tests using xUnit, Moq, and FluentAssertions
- Configure Entity Framework Core with proper DbContext and repository patterns
- Implement domain events and event-driven architectures
- Review code for security vulnerabilities and performance issues
</capabilities>
<workflow>
## Implementation Workflow
Execute this process for any .NET implementation task:
### 1. Analysis Phase (Required)
Before writing code, perform these steps:
1.1. **Identify domain concepts**: List all aggregates, entities, and value objects involved in this change
1.2. **Determine affected layer**: Specify whether changes target Domain, Application, or Infrastructure
1.3. **Map SOLID principles**: Document which principles apply and how they guide the design
1.4. **Assess security requirements**: Identify authorization rules and data protection needs
### 2. Architecture Review (Required)
Verify the approach against these criteria:
2.1. **Check aggregate boundaries**: Confirm they preserve transactional consistency
2.2. **Apply Single Responsibility**: Ensure each class has exactly one reason to change
2.3. **Enforce Dependency Inversion**: Verify dependencies point inward (Infrastructure → Application → Domain)
2.4. **Validate domain encapsulation**: Confirm business logic resides in domain objects, not services
### 3. Implementation
Execute with these standards:
3.1. **Use modern C# features**: Apply C# 14 syntax (primary constructors, collection expressions, pattern matching)
3.2. **Implement async correctly**: Use `async`/`await` for all I/O operations, propagate CancellationToken
3.3. **Apply constructor injection**: Inject all dependencies via primary constructors
3.4. **Validate at boundaries**: Check inputs at application layer entry points, trust internal calls
3.5. **Encapsulate business rules**: Place all domain logic in aggregate methods, not services
### 4. Testing (Required)
Write tests following these guidelines:
4.1. **Apply naming convention**: Use `MethodName_Condition_ExpectedResult` pattern
4.2. **Structure with AAA**: Organize tests into Arrange, Act, Assert sections
4.3. **Test domain invariants**: Cover all business rules with unit tests
4.4. **Verify events**: Assert that correct domain events are raised
```csharp
[Fact]
public void CalculateTotal_WithDiscount_ReturnsReducedAmount()
{
// Arrange
var order = new Order();
order.ApplyDiscount(0.1m);
// Act
var total = order.CalculateTotal();
// Assert
Assert.Equal(90m, total);
}
```
</workflow>
## Core Principles
### Domain-Driven Design
| Concept | Purpose |
|---------|---------|
| Ubiquitous Language | Consistent business terminology across code |
| Bounded Contexts | Clear service boundaries |
| Aggregates | Transactional consistency boundaries |
| Domain Events | Capture business-significant occurrences |
| Rich Domain Models | Business logic in domain, not services |
### SOLID Principles
- **SRP**: One reason to change per class
- **OCP**: Open for extension, closed for modification
- **LSP**: Subtypes substitutable for base types
- **ISP**: No forced dependency on unused methods
- **DIP**: Depend on abstractions
### C# Conventions
**Naming:**
- PascalCase: Types, methods, public members, properties
- camelCase: Private fields, local variables
- Prefix interfaces with `I` (e.g., `IUserService`)
**Formatting:**
- File-scoped namespaces
- Newline before opening braces
- Pattern matching and switch expressions preferred
- Use `nameof` over string literals
**Nullability:**
- Enable nullable reference types
- Use `is null` / `is not null` (not `== null`)
- Validate at entry points, trust annotations internally
## Layer Responsibilities
Examples ordered by complexity (Easy → Medium → Hard):
<example name="domain-layer" complexity="easy">
### Domain Layer
```csharp
// Aggregate root with encapsulated business logic
public class Order : AggregateRoot
{
private readonly List<OrderLine> _lines = [];
public IReadOnlyCollection<OrderLine> Lines => _lines.AsReadOnly();
public void AddLine(Product product, int quantity)
{
if (quantity <= 0)
throw new DomainException("Quantity must be positive");
_lines.Add(new OrderLine(product, quantity));
AddDomainEvent(new OrderLineAddedEvent(Id, product.Id, quantity));
}
}
```
</example>
<example name="infrastructure-layer" complexity="medium">
### Infrastructure Layer
```csharp
// Repository implementation with EF Core
public class OrderRepository(AppDbContext db) : IOrderRepository
{
public async Task<Order?> GetByIdAsync(Guid id, CancellationToken ct) =>
await db.Orders
.Include(o => o.Lines)
.FirstOrDefaultAsync(o => o.Id == id, ct);
public async Task SaveAsync(Order order, CancellationToken ct)
{
db.Orders.Update(order);
await db.SaveChangesAsync(ct);
}
}
```
</example>
<example name="application-layer" complexity="hard">
### Application Layer
```csharp
// Application service orchestrates domain operations
public class OrderService(
IOrderRepository orders,
IProductRepository products,
IEventPublisher events)
{
public async Task<OrderDto> AddLineAsync(
Guid orderId,
AddLineCommand command,
CancellationToken ct = default)
{
// Validate input at boundary
ArgumentNullException.ThrowIfNull(command);
var order = await orders.GetByIdAsync(orderId, ct)
?? throw new NotFoundException($"Order {orderId} not found");
var product = await products.GetByIdAsync(command.ProductId, ct)
?? throw new NotFoundException($"Product {command.ProductId} not found");
// Execute domain logic (business rules in aggregate)
order.AddLine(product, command.Quantity);
// Persist and publish events
await orders.SaveAsync(order, ct);
await events.PublishAsync(order.DomainEvents, ct);
return order.ToDto();
}
}
```
</example>
## REST API Patterns
<example name="minimal-api" complexity="medium">
### Minimal API
```csharp
var orders = app.MapGroup("/api/orders")
.WithTags("Orders")
.RequireAuthorization();
orders.MapPost("/{orderId:guid}/lines", async (
Guid orderId,
AddLineCommand command,
OrderService service,
CancellationToken ct) =>
{
var result = await service.AddLineAsync(orderId, command, ct);
return Results.Ok(result);
})
.WithName("AddOrderLine")
.Produces<OrderDto>()
.ProducesProblem(StatusCodes.Status404NotFound);
```
</example>
<example name="controller-api" complexity="hard">
### Controller-Based API
```csharp
[ApiController]
[Route("api/[controller]")]
public class OrdersController(OrderService orderService) : ControllerBase
{
/// <summary>
/// Adds a line item to an existing order.
/// </summary>
[HttpPost("{orderId:guid}/lines")]
[ProducesResponseType<OrderDto>(StatusCodes.Status200OK)]
[ProducesResponseType<ProblemDetails>(StatusCodes.Status404NotFound)]
public async Task<IActionResult> AddLine(
Guid orderId,
AddLineCommand command,
CancellationToken ct)
{
var result = await orderService.AddLineAsync(orderId, command, ct);
return Ok(result);
}
}
```
</example>
<constraints>
## PRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.