agentleFS
zdanovichnickzdanovichnick/dotnet-pilot/skills/clean-architecture/SKILL.md

clean-architecture

Skill5 starsChanged 7 days agoMITView on GitHub

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

28 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use domain-driven-design, dependency-injection and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • jarrodmedranoSkill

    domain-driven-design

    This skill should be used whenever domain modeling is taking place. It provides specialized guidance for type-driven and data-driven design based on Rich Hickey and Scott Wlaschin's principles. The skill helps contextualize current modeling within the existing domain model, identifies inconsistencies, builds ubiquitous language, and creates visualizations (Mermaid, Graphviz/DOT, ASCII diagrams) to communicate domain concepts clearly. Use this skill when designing types, modeling business domains, refactoring domain logic, or ensuring domain consistency across a codebase.

    Also in 4 projects that use this

  • HamzaSheikh768Skill

    dependency-injection

    Leverages FastAPI's powerful Depends system for reusable authentication, database sessions, rate limiting, and business logic injection.

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    hexagonal-architecture

    Hexagonal architecture patterns and implementation

    Also in 3 projects that use this

  • xenitV1Skill

    clean-code

    Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

    Also in 7 projects that use this

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 26 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Contains: Use-case handlers/services, repository and gateway interfaces, DTOs, validators

    line 21
  2. Distinctive:

    Packages: Test framework, mocking library, assertions, WebApplicationFactory

    line 46

“Common” is measured: kept by at least 6 in 10 of the 26 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Clean Architecture for .NET

Reference for architectural decisions. This skill is the source of truth for layer rules; ddd documents its one variant (repository interfaces in Domain).

Layer Definitions

Domain (innermost)

  • Contains: Entities, value objects, domain events, domain errors, enums, the Result<TValue, TError> type (skills/error-handling/SKILL.md)
  • References: Nothing (zero project references)
  • Packages allowed: none — the BCL covers it (TimeProvider included)
  • Packages forbidden: EF Core, ASP.NET Core, MediatR, FluentValidation, any infrastructure

Application

  • Contains: Use-case handlers/services, repository and gateway interfaces, DTOs, validators
  • References: Domain only
  • Packages allowed: FluentValidation; MediatR / AutoMapper only with the licence check below
  • Packages forbidden: EF Core, database drivers, HTTP clients

Licensing: MediatR 13+ and AutoMapper 15+ are commercial (Lucky Penny Software, since July 2025; a free Community edition covers qualifying organisations). Earlier versions stay open source but get no fixes. Before adding either, confirm the licence or use a plain handler interface and hand-written mapping — neither library is needed for this layering.

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: Microsoft.AspNetCore.OpenApi (built-in AddOpenApi()/MapOpenApi()), authentication, rate limiting
  • Responsibility: Wire everything together, no business logic. Referencing Infrastructure here is the composition root's job, not a violation

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.AddValidatorsFromAssembly(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 ownershipApplication defines interfaces (Domain, under the DDD variant); Infrastructure implements
Composition rootOnly API project wires DI container

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.