Architect Dotnet Helper
Production-ready agent that handles perform, janitorial, tasks, code. Includes structured workflows, validation checks, and reusable patterns for expert advisors.
.NET Architect Helper
Your agent for .NET application architecture β covering ASP.NET Core, Entity Framework, clean architecture patterns, and modern C# best practices for enterprise development.
When to Use This Agent
Choose .NET Architect Helper when:
- Designing ASP.NET Core application architecture (Web API, MVC, Blazor)
- Implementing clean architecture, CQRS, or domain-driven design in .NET
- Structuring Entity Framework Core data access patterns
- Setting up dependency injection, middleware pipelines, and configuration
- Reviewing .NET code for architectural consistency and best practices
Consider alternatives when:
- You need Azure-specific infrastructure β use an Azure specialist agent
- You need frontend architecture (React, Angular) β use a frontend agent
- You need .NET MAUI or WinForms β use a desktop development agent
Quick Start
# .claude/agents/dotnet-architect.yml name: .NET Architect Helper model: claude-sonnet tools: - Read - Write - Edit - Bash - Glob - Grep description: .NET architecture agent for ASP.NET Core design, clean architecture, EF Core, and C# best practices
Example invocation:
claude "Set up a clean architecture project structure for our ASP.NET Core Web API with CQRS using MediatR, Entity Framework Core, and FluentValidation"
Core Concepts
Clean Architecture in .NET
Solution/
βββ src/
β βββ Domain/ # Enterprise business rules
β β βββ Entities/ # Business objects
β β βββ ValueObjects/ # Immutable value types
β β βββ Enums/ # Domain enumerations
β β βββ Interfaces/ # Repository contracts
β βββ Application/ # Application business rules
β β βββ Features/ # CQRS commands and queries
β β βββ Interfaces/ # Service contracts
β β βββ DTOs/ # Data transfer objects
β β βββ Behaviors/ # Pipeline behaviors (validation, logging)
β βββ Infrastructure/ # External concerns
β β βββ Persistence/ # EF Core, repositories
β β βββ Services/ # External service implementations
β β βββ Identity/ # Authentication/authorization
β βββ WebAPI/ # Presentation layer
β βββ Controllers/ # API endpoints
β βββ Middleware/ # Request pipeline
β βββ Program.cs # App configuration
βββ tests/
βββ Domain.Tests/
βββ Application.Tests/
βββ WebAPI.Tests/
Key .NET Patterns
| Pattern | Library | Purpose |
|---|---|---|
| CQRS | MediatR | Separate read/write operations |
| Validation | FluentValidation | Request validation pipeline |
| ORM | EF Core | Database access and migrations |
| Mapping | AutoMapper / Mapster | DTO β Entity mapping |
| DI | Built-in Microsoft.Extensions.DI | Dependency injection |
| Logging | Serilog | Structured logging |
| Auth | Microsoft.Identity.Web | Entra ID authentication |
Configuration
| Parameter | Description | Default |
|---|---|---|
architecture_pattern | Architecture style (clean, vertical-slice, modular-monolith) | clean |
dotnet_version | Target .NET version | 8.0 |
cqrs_library | CQRS framework (mediatr, wolverine, custom) | mediatr |
orm | Data access (ef-core, dapper, both) | ef-core |
auth_method | Authentication (jwt, entra-id, identity) | entra-id |
Best Practices
-
Keep the Domain layer free of dependencies. The Domain project should reference zero external packages β no EF Core, no MediatR, no AutoMapper. Domain entities and interfaces depend only on .NET base types. This keeps your business logic portable and testable.
-
Use MediatR pipeline behaviors for cross-cutting concerns. Implement validation, logging, caching, and transaction management as MediatR behaviors instead of scattering them through handlers. This applies concerns consistently without polluting business logic.
-
Configure services in extension methods, not directly in Program.cs. Create
AddInfrastructure(),AddApplication(), andAddPersistence()extension methods. This keeps Program.cs clean and makes each layer's configuration independently testable. -
Use strongly-typed IDs for domain entities. Instead of
intorGuidfor entity IDs, create dedicated types likeOrderId. This prevents accidentally passing anOrderIdwhere aCustomerIdis expected, catching bugs at compile time. -
Implement the Repository pattern over EF Core's DbContext. While EF Core is already a Unit of Work/Repository, wrapping it with domain-specific repository interfaces keeps infrastructure details out of your application layer and makes testing with mocks straightforward.
Common Issues
EF Core navigation properties cause circular serialization. When returning entities directly from API endpoints, navigation properties create circular JSON references. Always map entities to DTOs before returning from controllers, and configure JsonSerializerOptions to handle reference cycles.
MediatR handlers become bloated with cross-cutting logic. When handlers contain validation, logging, caching, and business logic, they're doing too much. Extract cross-cutting concerns into pipeline behaviors (IPipelineBehavior<TRequest, TResponse>) that run automatically for every request.
Dependency injection registration becomes unmanageable. Large projects with hundreds of services create massive DI registration code. Use assembly scanning (services.AddMediatR(assembly), services.Scan() from Scrutor) to register services by convention instead of individually.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
API Endpoint Builder
Agent that scaffolds complete REST API endpoints with controller, service, route, types, and tests. Supports Express, Fastify, and NestJS.
Documentation Auto-Generator
Agent that reads your codebase and generates comprehensive documentation including API docs, architecture guides, and setup instructions.
Ai Ethics Advisor Partner
All-in-one agent covering ethics, responsible, development, specialist. Includes structured workflows, validation checks, and reusable patterns for ai specialists.