A

Architect Dotnet Helper

Production-ready agent that handles perform, janitorial, tasks, code. Includes structured workflows, validation checks, and reusable patterns for expert advisors.

AgentClipticsexpert advisorsv1.0.0MIT
0 views0 copies

.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

PatternLibraryPurpose
CQRSMediatRSeparate read/write operations
ValidationFluentValidationRequest validation pipeline
ORMEF CoreDatabase access and migrations
MappingAutoMapper / MapsterDTO ↔ Entity mapping
DIBuilt-in Microsoft.Extensions.DIDependency injection
LoggingSerilogStructured logging
AuthMicrosoft.Identity.WebEntra ID authentication

Configuration

ParameterDescriptionDefault
architecture_patternArchitecture style (clean, vertical-slice, modular-monolith)clean
dotnet_versionTarget .NET version8.0
cqrs_libraryCQRS framework (mediatr, wolverine, custom)mediatr
ormData access (ef-core, dapper, both)ef-core
auth_methodAuthentication (jwt, entra-id, identity)entra-id

Best Practices

  1. 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.

  2. 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.

  3. Configure services in extension methods, not directly in Program.cs. Create AddInfrastructure(), AddApplication(), and AddPersistence() extension methods. This keeps Program.cs clean and makes each layer's configuration independently testable.

  4. Use strongly-typed IDs for domain entities. Instead of int or Guid for entity IDs, create dedicated types like OrderId. This prevents accidentally passing an OrderId where a CustomerId is expected, catching bugs at compile time.

  5. 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.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates