agentleFS
joaoguimaraesprojoaoguimaraespro/personal-finance/.claude/skills/dotnet-create-module/SKILL.md

dotnet-create-module

Skill1 starsChanged todayMITView on GitHub

Scaffold a new module in a .NET modular monolith (Domain, Application, Infrastructure, Api projects, its own DbContext and schema, DI registration, test project). Use when a new bounded context needs its own module.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use the repo's provider and naming convention (e.g.

    line 54
  2. Very specific:

    Add the projects to the solution (dotnet sln add), add the test project, extend architecture tests to the new module.

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “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

Create a module

Inputs: module name (PascalCase, plural noun or capability: Invoices, Notifications), its first entity. First read the repo's architecture doc/ADRs and one existing module end to end. Copy its project references, package versions (Directory.Packages.props if central), base classes and registration style. The structure below is the default only.

Structure

src/Modules/<Module>/
  <Module>.Domain/             entities, value objects, <Entity>Errors, domain events   -> SharedKernel
  <Module>.Application/        commands, queries, validators, responses, abstractions    -> Domain, mediator
    DependencyInjection.cs
  <Module>.Infrastructure/     <Module>DbContext, Schema, configurations, repositories   -> Application, base Infrastructure
    Database/<Module>DbContext.cs, Database/Schema.cs, Database/Configurations/, Database/Migrations/
    DependencyInjection.cs
  <Module>.Api/                controllers or minimal-API endpoints                      -> Application
tests/<Module>.Tests/          domain and handler tests (+ integration tests where the repo keeps them)

Dependencies point inwards only: Api -> Application -> Domain; Infrastructure -> Application. No project references another module's projects except its public API contract project, if the repo has one.

DbContext and schema

namespace <Module>.Infrastructure.Database;

public static class Schema
{
    public const string Name = "<module_snake_case>";
}

public sealed class <Module>DbContext(DbContextOptions<<Module>DbContext> options /*, tenant provider if any */)
    : BaseDbContext(options), I<Module>UnitOfWork
{
    public DbSet<<Entity>> <Entity>s => Set<<Entity>>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        modelBuilder.HasDefaultSchema(Schema.Name);
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(<Module>DbContext).Assembly);
    }
}

Use the repo's provider and naming convention (e.g. UseNpgsql(...).UseSnakeCaseNamingConvention()), the shared connection string, and the migrations history table in the module's schema (npgsql => npgsql.MigrationsHistoryTable(HistoryRepository.DefaultTableName, Schema.Name)).

Registration

public static IServiceCollection Add<Module>Module(this IServiceCollection services, IConfiguration configuration)
{
    services.Add<Module>Application();          // validators, handlers (assembly scan)
    services.Add<Module>Infrastructure(configuration);   // DbContext, repositories, unit of work
    return services;
}

Register in the host's Program.cs next to the other modules; add the Api assembly to controller discovery or map its endpoints; include the module in startup migration application if the repo does that.

Then

  1. First entity with dotnet-create-entity, first use cases with dotnet-create-command-query.
  2. Initial migration with dotnet-ef-migration (Initial<Module>Schema).
  3. Add the projects to the solution (dotnet sln add), add the test project, extend architecture tests to the new module.

Checklist

  • Four projects + test project, references inward only, added to the solution
  • Own DbContext, schema and migrations folder
  • Registered in the host; endpoints authorised
  • Architecture tests cover it; gate passes

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.