agentsclimarketplace

Clean architecture

Skill zdanovichnick/dotnet-pilot/skills/clean-architecture

.NET clean architecture enforcement — layer rules, dependency direction, DI registration patterns, and project reference validation.From its SKILL.md

Install
npx -y skills add zdanovichnick/dotnet-pilot --skill clean-architecture

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 5 stars5 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.0 KB, as published. Nobody here has run it

Clean Architecture for .NET

Reference for architectural decisions. Used by dnp-architect and dnp-planner.

Layer Definitions

Domain (innermost)

  • Contains: Entities, value objects, domain events, domain exceptions, enums
  • References: Nothing (zero project references)
  • Packages allowed: MediatR.Contracts (interfaces only), FluentResults
  • Packages forbidden: EF Core, ASP.NET Core, any infrastructure

Application

  • Contains: Service interfaces, DTOs, validators, MediatR handlers, mapping profiles
  • References: Domain only
  • Packages allowed: MediatR, FluentValidation, AutoMapper
  • Packages forbidden: EF Core, database drivers, HTTP clients

Infrastructure

  • Contains: DbContext, repositories, external service clients, email senders
  • References: Domain, Application
  • Packages allowed: EF Core, database drivers, HTTP clients, file system
  • Implements: Interfaces defined in Application

API/Web (outermost)

  • Contains: Controllers/endpoints, middleware, Program.cs, DI composition root
  • References: Application, Infrastructure
  • Packages allowed: Swashbuckle, authentication, rate limiting
  • Responsibility: Wire everything together, no business logic

Tests

  • References: Any (unrestricted)
  • Packages: Test framework, mocking library, assertions, WebApplicationFactory

DI Registration Pattern

// In Infrastructure project:
public static class InfrastructureServiceExtensions
{
    public static IServiceCollection AddInfrastructureServices(
        this IServiceCollection services, IConfiguration config)
    {
        services.AddDbContext<ApplicationDbContext>(options =>
            options.UseNpgsql(config.GetConnectionString("DefaultConnection")));

        services.AddScoped<IUserRepository, UserRepository>();
        return services;
    }
}

// In Application project:
public static class ApplicationServiceExtensions
{
    public static IServiceCollection AddApplicationServices(this IServiceCollection services)
    {
        services.AddScoped<IUserService, UserService>();
        services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(ApplicationServiceExtensions).Assembly));
        return services;
    }
}

// In Program.cs (API project):
builder.Services.AddApplicationServices();
builder.Services.AddInfrastructureServices(builder.Configuration);

Validation Rules

RuleCheck
Domain independenceDomain .csproj has 0 <ProjectReference> elements
Application → Domain onlyApplication .csproj references only Domain
No reverse dependenciesDomain never references Application/Infrastructure/API
Interface segregationApplication defines interfaces, Infrastructure implements
Composition rootOnly API project wires DI container

Keep looking

Skills are one crate of 610,220. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.