agentleFS
codewithmukeshcodewithmukesh/dotnet-agent-kit/skills/architecture-advisor/SKILL.md

architecture-advisor

Skill853 starsChanged yesterdayMITView on GitHub

Architecture selection for new or restructured .NET solutions: asks about domain, team and compliance, then recommends modular slices (default), vertical slice, Clean Architecture or DDD. Use for "which architecture", "new solution", "restructure", "DDD", "project structure", "tech stack". Do NOT use for adding features to a modular-slices codebase (modular-slices), scaffolding (scaffold), or CLAUDE.md (dotnet-init).

5 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask first, then recommend.

    line 14
  2. Distinctive:

    Architecture is not permanent: Every option has an evolution path (table below).

    line 25
  3. Very specific:

    Package versions are never typed from memory: Use dotnet add package <name> for third-party packages.

    line 27
  4. Distinctive:

    Before recommending an architecture, ask questions across these 6 categories.

    line 31

“Common” is measured: kept by at least 6 in 10 of the 4 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

Architecture Advisor

Ask first, then recommend. Modular slices (a modular monolith of vertical slices, ADR-008) is the starting point for business applications; the questionnaire confirms it or finds the signals that point elsewhere. Details for each alternative live in references/ and load on demand:

  • references/vertical-slice.md: single-project VSA, discovery code, the Mediator option
  • references/clean-architecture.md: Domain, Application, Infrastructure, Api; IAppDbContext; use cases; endpoints returning TypedResults unions
  • references/ddd.md: aggregates, value objects, strongly-typed IDs, domain events, domain services; usable inside a modular-slices module
  • references/project-structure.md: solution layout, Directory.Build.props, Directory.Packages.props, .slnx, global.json, .editorconfig, analyzers, tech-stack defaults

Core Principles

  1. Start from the default, then test it. For a business application, recommend modular slices and run the questionnaire to confirm. Never prescribe without asking, and never override an existing codebase's conventions.
  2. Right-size the architecture. The simplest structure that handles the real complexity wins. CRUD apps do not need DDD; a startup does not need Clean Architecture. Match structure to requirements, not aspirations.
  3. Architecture is not permanent. Every option has an evolution path (table below). Start simple, add structure when complexity demands it, and record the decision so the team knows when to move.
  4. One default, three alternatives. Modular slices is the default. Single-project VSA, Clean Architecture and DDD stay fully supported. All of them share the kit's conventions: IEndpoint per feature, TypedResults unions, DbContext used directly, no repository over EF Core, no MediatR.
  5. Package versions are never typed from memory. Use dotnet add package <name> for third-party packages; pin Microsoft.* and EF Core to the newest 10.0.x on net10.0, because an unversioned add now resolves 11.x.

The Architecture Questionnaire

Before recommending an architecture, ask questions across these 6 categories. Not every question applies to every project; skip irrelevant ones.

Category 1: Domain Complexity

#QuestionLow SignalHigh Signal
1How many distinct business entities does the system manage?< 10 entities20+ entities with relationships
2Do business rules involve multiple entities interacting?Rules are per-entity CRUDComplex invariants across entity groups
3Are there business workflows with multiple steps?Simple request, responseSagas, approval chains, state machines
4Do domain experts use specialized vocabulary?Generic terms (create, update)Ubiquitous language (underwrite, adjudicate)

Category 2: Team & Organization

#QuestionLow SignalHigh Signal
5How large is the development team?1-3 developers8+ developers, multiple teams
6Do different teams own different parts of the system?Single team owns everythingTeams aligned to business domains
7What is the team's experience level with .NET?Junior or mixedSenior, experienced with patterns

Category 3: System Lifetime & Scale

#QuestionLow SignalHigh Signal
8Expected system lifetime?< 2 years, MVP/prototype5+ years, long-lived product
9How many concurrent users or requests per second?< 100 RPS1000+ RPS, variable load
10Will the system need to scale independently by feature area?Uniform loadHot spots need independent scaling

Category 4: Regulatory & Compliance

#QuestionLow SignalHigh Signal
11Are there audit trail or compliance requirements?Basic logging sufficientFull audit trail, SOX/HIPAA/PCI
12Do different parts of the system have different security boundaries?Single auth boundaryMulti-tenant, data isolation

Category 5: Existing Codebase

#QuestionLow SignalHigh Signal
13Is this greenfield or brownfield?Greenfield, starting freshBrownfield, migrating from legacy
14Are there existing architectural patterns the team follows?No established patternsStrong conventions in place

Category 6: Integration Complexity

#QuestionLow SignalHigh Signal
15How many external systems does this integrate with?0-2 simple APIs5+ systems with complex contracts
16Are there event-driven or async communication needs?Synchronous request/responseEvent sourcing, pub/sub, eventual consistency

Recommendation

Map answers to an architecture. Say which signals drove the pick and what would change it.

ProfileRecommendedWhy
Business application with several areas (catalog, orders, billing, users), any team sizeModular slices (default)Contracts keep areas apart, slices keep each feature in one folder, no mediator or Result library
Multiple bounded contexts, team per domain, possible later extractionModular slicesContracts, per-module schemas and outboxes make extraction a deployment change
One business area, a few endpoints, small team, short lifetimeSingle-project VSASame slice conventions without the module split
High domain complexity, specialized vocabulary, complex invariantsDDD inside the complex modules, or with Clean ArchitectureAggregates protect invariants; the surrounding structure still applies
Team standardised on layers, or brownfield N-tierClean ArchitectureFamiliar layering with the right dependency direction
Library, SDK, desktop or console appNo web architectureModules and endpoints do not apply

When signals conflict

  1. Default to modular slices for business apps. It costs little more than VSA on day one and avoids a restructure later. Drop to single-project VSA only when there is clearly one area.
  2. Domain complexity changes the inside of a module, not the outside. Use DDD aggregates in the module that needs them.
  3. Team familiarity matters. A team fluent in Clean Architecture ships faster with it than learning modular slices under a deadline.
  4. Existing code wins. In a brownfield codebase, follow its architecture unless the user asks to change it.

Patterns

Modular slices (default)

A modular monolith whose modules are built from vertical slices. Load the modular-slices skill; it owns the building blocks and the module layout.

src/
  Modularity/                           # IModule, IEndpoint, IHandler, ModuleDbContext, outbox, Problems
  Modules/
    Orders/Orders/Features/PlaceOrder/  # Endpoint, Handler, Request, RequestValidator
    Orders/Orders.Contracts/            # interfaces, records, integration events; no packages
    Catalog/...
  Api/  Worker/  Migrator/  AppHost/

Single-project VSA

Organize by feature, not layer. One business area, one project, one DbContext. See references/vertical-slice.md.

src/MyApp.Api/
  Features/CreateOrder/   # Endpoint, Handler, Request, Validator
  Features/GetOrder/
  Persistence/AppDbContext.cs

Clean Architecture

Concentric layers, dependencies pointing inward. See references/clean-architecture.md.

src/
  MyApp.Domain/           # entities, domain logic; no references
  MyApp.Application/      # use cases, IAppDbContext, validators
  MyApp.Infrastructure/   # EF Core, external services
  MyApp.Api/              # IEndpoint classes, Program.cs

DDD

Tactical patterns (aggregates, value objects, domain events) for the parts of the domain with real invariants. Lives in a module's Domain/ folder or the Domain project. See references/ddd.md.

Which reference to load

SituationLoad
New business app, several areasmodular-slices skill, then references/project-structure.md
Small single-area APIreferences/vertical-slice.md
Layered team standard or brownfield N-tierreferences/clean-architecture.md
Heavy business rules in one areareferences/ddd.md (plus the architecture it sits in)
New solution files, package management, build propsreferences/project-structure.md
Which database, auth, cache, brokerTech-stack table in references/project-structure.md
Add a feature to a modular-slices codebasemodular-slices skill, not this one

Evolution Paths

FromToTriggerHow
Single-project VSAClean ArchitectureDomain logic outgrowing handlersExtract Domain and Application, keep features as use cases
Single-project VSAModular slicesA second business area appearsMove features into Modules/<Area>/, add a Contracts project, give each module its own DbContext and schema
Clean Architecture+ DDDInvariants getting complex, primitive obsessionIntroduce aggregates, value objects, domain events
Layered monolithModular slicesTeams stepping on each other, shared-database couplingSplit into modules with own DbContexts, schemas and contracts
Modular slicesDDD in one moduleOne module's rules outgrow its handlersIntroduce aggregates in that module only
Modular slicesMicroservicesIndependent scaling or deploymentExtract a module; its contracts become the API, its outbox feeds a broker

Anti-patterns

Picking Clean Architecture for a CRUD app

// BAD: 4 projects, 6+ files per feature for simple CRUD
src/MyApp.Domain/Entities/Product.cs
src/MyApp.Application/Products/CreateProduct/CreateProductCommand.cs
src/MyApp.Application/Products/CreateProduct/CreateProductHandler.cs
src/MyApp.Application/Products/CreateProduct/CreateProductValidator.cs
src/MyApp.Infrastructure/Persistence/ProductRepository.cs
src/MyApp.Api/Endpoints/ProductEndpoints.cs

// GOOD: a slice, one folder, no layers to cross
src/Modules/Catalog/Catalog/Features/CreateProduct/CreateProductEndpoint.cs
src/Modules/Catalog/Catalog/Features/CreateProduct/CreateProductHandler.cs
src/Modules/Catalog/Catalog/Features/CreateProduct/CreateProductRequest.cs

DDD everywhere

// BAD: value objects and aggregates for a settings table
public class UserSettings : AggregateRoot
{
    public ThemeName Theme { get; private set; }   // a value object for "dark" or "light"?
}

// GOOD: a plain entity for plain data
public class UserSettings
{
    public Guid UserId { get; init; }
    public string Theme { get; set; } = "light";
}

Premature microservices

// BAD: five services on day one with two developers
OrderService (own repo, own DB, own CI/CD)
CatalogService (own repo, own DB, own CI/CD)
IdentityService, NotificationService, GatewayService ...

// GOOD: modular slices, extract a module when there is evidence
src/Modules/Orders/  src/Modules/Catalog/  src/Modules/Identity/  src/Modules/Notifications/

Skipping the questionnaire

// BAD: scaffolding before asking anything
User: "Set up a new project for a todo app"
Agent: *immediately scaffolds a 4-project Clean Architecture solution*

// GOOD: ask first, then recommend
Agent: *asks about areas, team, lifetime; one area and one developer, so recommends single-project VSA*

Carrying old defaults into the alternatives

// BAD: a Clean Architecture handler on MediatR with a Result-to-HTTP mapper
return result.IsSuccess ? TypedResults.Ok(result.Value) : result.ToProblemDetails();

// GOOD: plain handler, endpoint declares the outcomes in a TypedResults union
private static async Task<Results<Ok<OrderDto>, ProblemHttpResult>> HandleAsync(...)

Decision Guide

ScenarioRecommendation
New business applicationModular slices; confirm with the questionnaire
New project, unknown requirementsStart from modular slices, run the questionnaire
Simple single-area API, 1 to 3 developersSingle-project VSA
Several business areas or teamsModular slices
Complex domain, specialized vocabularyModular slices with DDD in the complex modules, or DDD + Clean Architecture
Existing N-tier codebase to modernizeClean Architecture (familiar migration), or modular slices if areas are clear
MVP or startup, speed firstSingle-project VSA, or two or three modules if the areas are already known
Regulatory or compliance-heavyModular slices or Clean Architecture; both enforce boundaries in tests
Independent scaling laterModular slices (extraction-ready)
Existing codebase with its own architectureKeep it
Solution files, package management, editorconfigreferences/project-structure.md
Adding a feature, scaffoldingmodular-slices, scaffold
Generating CLAUDE.md for the projectdotnet-init

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.