| name | dotnet-enterprise |
| description | Generate .NET 10 enterprise repositories with Clean Architecture, DDD, CQRS, MassTransit, and cloud-native patterns. Use when user says "create a new .NET project", "set up microservices", "add DDD patterns", "configure MassTransit", "set up RabbitMQ", "add OpenTelemetry", "implement distributed caching", "set up Docker", or asks for "enterprise .NET", "CQRS architecture", "Clean Architecture", "event-driven microservices". |
| metadata | {"author":"Claude-DotNet-Ultimate","version":"2.1.0","category":"enterprise-architecture","license":"MIT"} |
.NET 10 Enterprise Repository Generator
Purpose
Creates production-ready .NET 10 enterprise solutions with Domain-Driven Design, modern cloud-native patterns, and comprehensive infrastructure.
Key .NET Principles (Battle-Tested from Production)
IMPORTANT: Follow these principles consistently for maintainable, testable, and performant code.
1. Immutability by Default
- Use records for DTOs, responses, and value objects
- Use readonly structs for performance-critical data
- Prefer init setters over set
- Avoid mutable collections in public APIs
public record CreateOrderRequest(Guid CustomerId, List<OrderItemDto> Items);
public readonly struct Money(decimal Amount, string Currency);
public class CreateOrderRequest { public Guid CustomerId { get; set; } }
2. Type Safety First
- Use strongly-typed IDs instead of raw Guids/ints
- Enable nullable reference types
- Use discriminated unions via records for state
- Avoid object, dynamic, or untyped collections
public record OrderId(Guid Value);
public record CustomerId(Guid Value);
public class Order { public Guid Id { get; set; } }
3. Composition Over Inheritance
- Use sealed classes by default
- Prefer interfaces and records for polymorphism
- Use extension methods for adding behavior
- Avoid abstract base classes unless necessary
public sealed class OrderService : IOrderService
{
private readonly IOrderRepository _repository;
private readonly IMapper _mapper;
public OrderService(IOrderRepository repository, IMapper mapper)
{
_repository = repository;
_mapper = mapper;
}
}
4. Performance-Aware Coding
- Use Span and Memory for slice operations
- Use IBufferWriter for high-throughput streaming
- Use deferred enumeration with yield return
- Use object pooling for allocations in hot paths
5. No Magic - Explicit Over Implicit
- NO AutoMapper - Use Mapster or manual mapping
- NO reflection-heavy frameworks in hot paths
- NO magic strings - Use source generators
- Explicit DI - No service locator anti-pattern
6. Testable by Design
- Inject dependencies via constructor injection
- Use pure functions where possible
- Avoid static state and singletons
- Make side effects explicit in method signatures
When to Use
- User requests a new .NET project or solution
- User mentions enterprise architecture, microservices, or DDD
- User needs MassTransit, RabbitMQ, or message bus integration
- User needs distributed caching with Redis/Memory
- User needs OpenTelemetry tracing and metrics
- User needs Docker or .NET Aspire configuration
Project Requirements Survey
When the user requests a new .NET project, ALWAYS run through this questionnaire to gather requirements:
1. PROJECT BASICS
- Project name: _______________
- Solution name: _______________
- Target .NET version: (10.0 / 9.0 / 8.0)
- Project type: (Web API / Minimal API / Web App / Console)
Skill gating: If the user picks Web API or Minimal API (not a server-rendered Web App with MVC), do not use dotnet-mvc. Use dotnet-api-endpoint (and CQRS) for HTTP. Use dotnet-mvc only when they choose MVC/Razor/Controllers+Views or a separate MVC project.
2. DATABASE
Primary Database:
- PostgreSQL (Recommended for enterprise)
- SQL Server / MS SQL
- MySQL / MariaDB
- SQLite (for small projects)
- MongoDB (NoSQL)
ORM Choice:
- Entity Framework Core (Recommended)
- Dapper (micro-ORM, high performance)
- Both (EF Core + Dapper)
- No ORM (raw ADO.NET)
Database Migrations:
- EF Core Migrations
- FluentMigrator
- Raw SQL scripts
3. MESSAGING / SERVICE BUS
Message Broker:
- RabbitMQ (Recommended)
- Azure Service Bus
- Amazon SQS
- Kafka
- None (synchronous only)
Messaging Library:
- MassTransit (Recommended)
- NServiceBus
- Raw RabbitMQ.Client
4. CACHING
Caching Strategy:
- Redis + Memory (HybridCache) (Recommended)
- Redis only (distributed)
- Memory only (in-process)
- No caching
Cache Invalidation:
- Tags-based
- Key-based
- Time-based expiry
5. OBJECT MAPPING
Mapper Library:
- Mapster (Recommended - faster than AutoMapper)
- AutoMapper
- Manual mapping
- None
6. API STYLE
- Minimal APIs (Recommended for .NET 6+)
- Controllers (MVC)
- Both (Minimal APIs + Controllers)
If the choice is Minimal APIs or Web API without MVC UI, dotnet-mvc does not apply. Only if Controllers (MVC) or Both and the user needs Razor/Views should you load dotnet-mvc.
7. AUTHENTICATION
- JWT Bearer Tokens
- OAuth 2.0 / OpenID Connect
- Windows Authentication
- No authentication
8. API DOCUMENTATION
- Swagger / OpenAPI (Recommended)
- Scalar / Redoc
- None
9. LOGGING & OBSERVABILITY
Structured Logging:
- Serilog (Recommended)
- Microsoft.Extensions.Logging
Log Destinations:
- Console
- File (rolling)
- Seq
- Elasticsearch
- Datadog
Tracing:
- OpenTelemetry (Recommended)
- None
Metrics:
- OpenTelemetry + Prometheus
- None
10. CONTAINERIZATION
- Docker (Recommended)
- Docker Compose
- Kubernetes manifests
- None
11. ORCHESTRATION
- .NET Aspire (Recommended for .NET 9+)
- Raw Docker Compose
- Kubernetes
12. TESTING
Unit Testing:
- xUnit (Recommended)
- NUnit
- MSTest
Mocking:
- Moq (Recommended)
- NSubstitute
- FakeItEasy
Integration Testing:
- Testcontainers (Recommended)
- In-memory databases
- Manual setup
13. ADDITIONAL LIBRARIES
Select all that apply:
- FluentValidation (Recommended)
- MediatR / CQRS (Recommended)
- Polly (Resilience)
- FluentAssertions
- Swagger (OpenAPI)
- Health Checks
- CORS
- Rate Limiting
14. PROJECT ARCHITECTURE
Patterns:
- Domain-Driven Design (DDD) (Recommended)
- Clean Architecture
- Simple Layered Architecture
- CQRS
- Event Sourcing
Folder Structure:
- Vertical Slices (Recommended)
- Feature-based
- Traditional (Controllers/Services/Repositories)
SOLUTION STRUCTURE
Layer Architecture
Solution/
├── src/
│ ├── Core/ # Domain layer (DDD)
│ │ ├── Common/ # Base classes, interfaces
│ │ └── Domain/ # Entities, Value Objects, Aggregates
│ ├── Application/ # Use cases, interfaces
│ │ ├── Common/Interfaces/ # IMessageBus, ICacheService, IRepository
│ │ ├── Features/ # Vertical slices (Commands, Queries)
│ │ └── Behaviors/ # MediatR pipeline behaviors
│ ├── Infrastructure/ # External concerns
│ │ ├── Messaging/ # MassTransit + RabbitMQ
│ │ ├── Caching/ # HybridCache (L1 Memory + L2 Redis)
│ │ ├── Logging/ # OpenTelemetry + Serilog
│ │ └── Persistence/ # EF Core + PostgreSQL
│ ├── Api/ # Minimal API endpoints
│ └── Aspire/ # .NET Aspire orchestration
└── tests/
├── Unit/ # Unit tests (xUnit, Moq)
└── Integration/ # Testcontainers for real infra
Core Patterns (DDD)
Base Classes
public abstract class BaseEntity<TId> where TId : StronglyTypedId
{
public TId Id { get; protected set; }
public DateTime CreatedAt { get; set; }
}
public abstract class AggregateRoot<TId> : BaseEntity<TId>
{
private readonly List<DomainEvent> _domainEvents = [];
public IReadOnlyList<DomainEvent> DomainEvents => _domainEvents.AsReadOnly();
protected void RaiseDomainEvent(DomainEvent eventItem) => _domainEvents.Add(eventItem);
}
public abstract class ValueObject
{
protected abstract IEnumerable<object> GetEqualityComponents();
}
Result Pattern (No Exceptions for Flow Control)
public class Result<T>
{
public T? Value { get; }
public Error? Error { get; }
public bool IsSuccess => Error is null;
}
Application Layer
MediatR Pipeline Behaviors
- ValidationBehavior - FluentValidation pipeline
- LoggingBehavior - Structured logging with Serilog
- PerformanceBehavior - Slow request detection
Feature Structure (Vertical Slices)
Features/Orders/Commands/CreateOrder/
├── CreateOrderCommand.cs # Request + validation attributes
├── CreateOrderCommandHandler.cs # Business logic
└── CreateOrderCommandValidator.cs
Infrastructure Setup
MassTransit + RabbitMQ
- Retry policies: 3 retries with exponential backoff
- Outbox pattern for reliable messaging
- Dead letter queue handling
- Consumer configuration with concurrency limits
HybridCache (.NET 9)
- L1: IMemoryCache (in-process)
- L2: Redis (distributed)
- Pub/Sub invalidation between instances
- Tags for selective cache invalidation
OpenTelemetry
- Tracing with OTLP exporter
- Metrics (AspNetCore host metrics)
- Structured logging with Serilog
- Seq sink for log aggregation
Persistence
- EF Core 9 with PostgreSQL
- AuditableEntityInterceptor for CreatedAt/ModifiedAt
- Automatic migrations
- Repository pattern
C# 14 Features to Apply
- Primary Constructors:
public class OrderService(IMapper mapper, IOrderRepository repo)
- File-Scoped Namespaces:
namespace Orders.Entities;
- Collection Expressions:
string[] names = ["Alice", "Bob"];
- Using declarations:
using var scope = services.BeginScope();
- Pattern Matching:
if (value is int or string result)
- Enhanced lock objects:
private readonly Lock _lock = new();
- Params collections:
params ReadOnlySpan<T> items
Skill Routing Guide
When working on specific .NET topics, reference the appropriate skill:
| Topic | Reference | Key Patterns |
|---|
| C# / Code Quality | modern-csharp-coding-standards | Records, pattern matching, nullable types |
| Concurrency | csharp-concurrency-patterns | Task vs Channel vs lock vs actors |
| API Design | api-design | Extend-only design, versioning |
| Performance | type-design-performance | Sealed, readonly, Span |
| Data Access | efcore-patterns | Entity config, migrations, query optimization |
| Database | database-performance | N+1 prevention, AsNoTracking |
| DI / Config | dependency-injection-patterns | IServiceCollection extensions, keyed services |
| Testing | testcontainers-integration-tests | Docker-based integration tests |
| ASP.NET Core | aspire-service-defaults | OpenTelemetry, health checks, resilience |
| MVC / Razor | dotnet-mvc | Controllers, Views, Razor Pages, Microsoft stack patterns |
Business Workflow Patterns
For product development, follow this workflow:
- Product Vision - Define what to build and why
- User Research - Understand real user needs
- Requirements - Translate to technical specs
- Implementation - Clean Architecture, DDD, CQRS
- Testing - Unit + Integration with Testcontainers
- Observability - OpenTelemetry for monitoring
- Deployment - Docker + Aspire orchestration
Build & Test Commands
dotnet build Solution.sln
dotnet test tests/
docker-compose up -d
dotnet run --project src/Aspire/AppHost/
Project Files Template
Directory.Build.props
<Project>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS8602;CS8603</NoWarn>
</PropertyGroup>
</Project>
Project File (.csproj)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MassTransit.RabbitMQ" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="3.0.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" />
</ItemGroup>
</Project>
Docker Configuration
Multi-stage Dockerfile (Chiseled Ubuntu)
# Chiseled Ubuntu for reduced attack surface (~100MB vs ~250MB)
FROM mcr.microsoft.com/dotnet/aspnet:10.0-chiseled AS base
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ["src/Api/Api.csproj", "Api/"]
RUN dotnet restore "Api/Api.csproj"
COPY . .
WORKDIR "/src/Api"
RUN dotnet build -c Release -o /app/build
FROM build AS publish
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=true
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["./Api"]
Docker Compose for Local Development
services:
api:
build: .
ports:
- "8080:8080"
depends_on:
- postgres
- redis
environment:
- ConnectionStrings__Default=Host=postgres;Database=mydb
- ConnectionStrings__Redis=redis:6379
postgres:
image: postgres:17-alpine
volumes:
- pgdata:/var/lib/postgresql/data
redis:
image: redis:7-alpine
volumes:
pgdata:
Additional Resources
Third-Level References (Load As Needed)
Before diving into specific patterns, consult these bundled references:
| Reference | Content |
|---|
references/PATTERNS.md | Design patterns (GoF), SOLID, GRASP, anti-patterns, CQRS, DDD, caching patterns |
references/ARCHITECTURE.md | Clean Architecture structure, layer responsibilities, solution organization |
references/EXAMPLES.md | Complete code examples for commands, queries, entities, validators |
references/DISTRIBUTION.md | Docker, Kubernetes, CI/CD, NuGet packaging strategies |
references/README.md | Quick reference and quick-start guide |
Skill Structure (Progressive Disclosure)
dotnet-enterprise/
├── SKILL.md # Core instructions (always loaded)
├── scripts/ # Python automation scripts (optional)
│ ├── scaffold_project.py # Generate project structure
│ ├── analyze_code.py # Code quality analysis
│ └── migrate_dotnet.py # Version migration
├── references/ # Detailed documentation (load as needed)
│ ├── PATTERNS.md # Design patterns & libraries
│ ├── ARCHITECTURE.md # Architecture patterns
│ ├── EXAMPLES.md # Code examples
│ └── DISTRIBUTION.md # Deployment & DevOps
└── platforms/ # Platform-specific configurations
Python Scripts for Enhanced Performance
The skill includes Python scripts for automation and enhanced functionality:
1. Project Scaffolding (scripts/scaffold_project.py)
Fast project generation with Clean Architecture + DDD patterns.
python scripts/scaffold_project.py --name MyProject --output ./output
python scripts/scaffold_project.py --name MyProject --template minimal --output ./output
Generated structure:
- Solution file with proper GUIDs
- 4-layer Clean Architecture (Domain, Application, Infrastructure, Api)
- Directory.Build.props with .NET 10 settings
- Unit test project with xUnit, Moq, FluentAssertions
- Docker + docker-compose.yml
2. Code Quality Analysis (scripts/analyze_code.py)
Static analysis for common C# anti-patterns and best practices.
python scripts/analyze_code.py ./src
python scripts/analyze_code.py ./src --output report.html --format html
python scripts/analyze_code.py ./src --output report.json --format json
Detects:
async void methods (error)
- Missing null checks with nullable types
- IDisposable not sealed classes
- Magic strings
- Missing async/await patterns
3. Version Migration (scripts/migrate_dotnet.py)
Automated migration between .NET versions.
python scripts/migrate_dotnet.py ./src --from net8.0 --to net10.0
python scripts/migrate_dotnet.py ./src --from net8.0 --to net10.0 --update-packages
python scripts/migrate_dotnet.py ./src --from net8.0 --to net10.0 --dry-run
Migrates:
- TargetFramework
- LangVersion
- Package versions (EF Core, MassTransit, OpenTelemetry, etc.)
- Visual Studio solution file versions
Requirements
pip install -r requirements.txt
When to Use Scripts
| Task | Tool | Reason |
|---|
| Create new project | scaffold_project.py | Faster than manual, consistent structure |
| Code review | analyze_code.py | Catches issues before PR |
| Version upgrade | migrate_dotnet.py | Reduces manual errors |
| CI/CD integration | Any script | Automate workflows |