Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

modular-slices

БесплатноБез исполняемых скриптовНе проверен

Default architecture for .NET business apps: modular monolith of vertical slices with Contracts projects, Features/<VerbPhrase>/ folders (IEndpoint +…

codewithmukeshот codewithmukesh★ 858 звёзд на GitHub

Об этом скилле

Modular Slices

A modular monolith built from vertical slices. This is the kit's default for business applications (ADR-008). Each business area is a module with its own projects, schema and public contracts; each operation inside a module is a slice in its own folder. Full code to copy lives in references/:

  • references/building-blocks.md: IModule, IEndpoint, IHandler, discovery, validation filter, Problems, permissions, ModuleDbContext, a full feature
  • references/hosts-and-projects.md: Api, Worker, Migrator and AppHost programs, project files, Directory.Build.props
  • references/outbox.md: per-module outbox and inbox, consumers, the worker, scheduled jobs
  • references/architecture-tests.md: boundary rules with proofs
  • references/testing.md: fixture, test auth, the four tests every feature gets

Core Principles

  1. A module is two projects: <Module> and <Module>.Contracts. Other modules may reference only the contracts, which hold interfaces, the records they return, and integration events, with no package or framework references. The compiler then enforces the boundary, and EF Core or ASP.NET Core types cannot leak into what other modules see.
  2. A feature is a folder, and adding one touches nothing else. Features/PlaceOrder/ holds PlaceOrderEndpoint, PlaceOrderHandler, PlaceOrderRequest, PlaceOrderRequestValidator and, if it is specific, the response. IEndpoint and IHandler are discovered, validators are registered by assembly, so neither the module class nor Program.cs changes.
  3. Handlers return TypedResults unions, not a Result<T>. Results<Created<OrderResponse>, ProblemHttpResult> is checked by the compiler and documented in OpenAPI automatically. There is no mediator and no mapping layer: the endpoint injects its handler and returns what it returns.
  4. Everything is internal except the module class and request/response records. Hosts can see only how to add the module; other modules can see only its contracts. Architecture tests fail the build if anything else becomes public.
  5. Each module owns its data and talks asynchronously through its outbox. One database, one schema per module, one DbContext per module used directly (no repositories). A change and the events it causes commit together; a worker delivers them to other modules' consumers, each of which handles an event once.

Patterns

Solution layout

src/
  Modularity/                       # shared building blocks (the only shared code with behaviour)
  Modules/
    Catalog/Catalog/                # implementation
    Catalog/Catalog.Contracts/      # ICatalog, ProductInfo, ProductRetired
    Orders/Orders/
      OrdersModule.cs
      OrdersPermissions.cs
      Domain/Order.cs
      Features/
        PlaceOrder/                 # PlaceOrderEndpoint, Handler, Request, RequestValidator
        GetOrder/
        CancelOrder/
        Common/OrderResponse.cs     # shared by several features of this module only
      Events/MarkOrderPaid.cs       # IEventConsumer<PaymentReceived>
      Persistence/OrdersDbContext.cs
      Services/OrdersService.cs     # implements IOrders from Orders.Contracts
    Orders/Orders.Contracts/
  Api/  Worker/  Migrator/  AppHost/  ServiceDefaults/
tests/
  Architecture.Tests/  Testing/  Orders.Tests/Features/PlaceOrder/

The module class

public sealed class OrdersModule : IModule
{
    public string Name => "Orders";
    public string RouteSegment => "orders";

    public void AddServices(IServiceCollection services, IConfiguration configuration)
    {
        services.AddModuleDbContext<OrdersDbContext>();
        services.AddScoped<IOrders, OrdersService>();                                   // for other modules
        services.AddEventConsumer<PaymentReceived, MarkOrderPaid, OrdersDbContext>();   // from Billing
    }
}

// Api/Program.cs: one line per module, then one call to map them all
builder.AddModule<CatalogModule>();
builder.AddModule<OrdersModule>();
app.MapModules();   // /api/v1/{segment}, tagged per module, validation filter on every endpoint

A slice: endpoint + handler

internal sealed class CancelOrderEndpoint : IEndpoint
{
    public void Map(IEndpointRouteBuilder endpoints) =>
        endpoints.MapPost("/{id:guid}/cancel", HandleAsync)
            .RequirePermission(OrdersPermissions.Manage)
            .WithSummary("Cancels an order that has not shipped");

    private static Task<Results<Ok<OrderResponse>, ProblemHttpResult>> HandleAsync(
        Guid id, CancelOrderRequest request, CancelOrderHandler handler, CancellationToken ct) =>
        handler.HandleAsync(id, request, ct);
}

internal sealed class CancelOrderHandler(OrdersDbContext db, TimeProvider clock) : IHandler
{
    public async Task<Results<Ok<OrderResponse>, ProblemHttpResult>> HandleAsync(
        Guid id, CancelOrderRequest request, CancellationToken ct)
    {
        if (await db.Orders.FirstOrDefaultAs
Полный SKILL.md на GitHub

Установить modular-slices в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/architecture-tests.mdreferences/building-blocks.mdreferences/hosts-and-projects.mdreferences/outbox.mdreferences/testing.md

FAQ

Что делает скилл modular-slices?

Default architecture for .NET business apps: modular monolith of vertical slices with Contracts projects, Features/<VerbPhrase>/ folders (IEndpoint + IHandler), IModule discovery, a DbContext per module. Use for "modular monolith", "IModule", "IHandler", "contracts project", "module boundaries", or adding a feature under src/Modules/. Do NOT use for small single-area APIs, Clean Architecture or DDD codebases (use architecture-advisor).

Как установить скилл modular-slices?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл modular-slices запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить modular-slices с