Build an app with DevKit¶
Start with a minimal ASP.NET Core Web API and add DevKit one capability at a time. The guide builds a Customers module with its own configuration, domain model, repository, and SQL Server database. No entity, database context, or persistence setup is required at the start.
Use the same approach in an existing application. Keep its working features and add only the parts you need. Each step introduces something new rather than converting an existing data model.
- 01Minimal API
WebApplication.CreateBuilder(args)start - 02bdk MCP
dotnet tool run bdk mcpagent tools - 03DevKit host
DevKitWebApplication.CreateBuilder(args)1 package - 04Module
Configure<T>(), AddModules(), MapModules()appsettings - 05Customer
AggregateRoot<Guid>, Customer.Create(...)1 file - 06SQL Server
AddSqlServerDbContext(...), InitialCustomers1 package - 07Repository
AddEntityFrameworkRepository<Customer, CustomersDbContext>()registration - 08Handlers
AddRequester(), validation, commands and queries2 files - 09Endpoints
AddEndpoints<CustomerEndpoints>(), MapEndpoints()1 file - 10Domain events
AddNotifier(), RepositoryDomainEventPublisherBehavioroptional
Each step ends with a copyable AI prompt. Connect bdk MCP in step 2 before using the planning and apply prompts.
Start with a minimal Web API¶
Use an existing ASP.NET Core application, or create a plain .NET 10 web project. This command uses the standard .NET template:
dotnet new web -n Customers.Web -f net10.0
cd Customers.Web
The starting app needs only a host and one route:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Customers API is running.");
app.Run();
For an existing app, keep its Program.cs and use one of its existing routes for the first checks. No customer endpoints or database are needed yet. The examples below use Customers.Web as the project name and namespace.
Check it
Run in Development with PowerShell 7.3 or later:
$env:ASPNETCORE_ENVIRONMENT = "Development"
dotnet run --no-launch-profile --urls http://localhost:5199
In a second terminal, run Invoke-RestMethod http://localhost:5199/. Expect Customers API is running. Stop the app before changing files.
AI prompt
Do step 1, "Start with a minimal Web API", of the guide "Build an app with DevKit".
Read https://bridgingit-gmbh.github.io/bITdevKit/getting-started-existing-app/#step-1.
Use the existing ASP.NET Core host if one is present. Otherwise create the plain .NET 10 web project shown in the guide. Keep existing working features. Do not add an entity, DbContext, repository, or database yet.
Build the application, start it in Development, check its root route, and stop the process. Report the project, namespace, URL, and check result. Leave changes uncommitted for review.
Install bdk and connect MCP¶
Install the local bdk CLI so your agent can search DevKit guides, get feature guidance, and check API signatures before changing the app. These tools work without a running DevKit host.
Solutions created from the DevKit template already have bdk MCP installed and configured.
Run from your app's repository root in PowerShell 7.3 or later:
if (-not (Test-Path .config/dotnet-tools.json) -and -not (Test-Path dotnet-tools.json)) {
dotnet new tool-manifest
}
dotnet tool install BridgingIT.DevKit.Cli
If the manifest already lists the CLI, run dotnet tool restore instead of installing it again.
Configure your MCP client to run dotnet with arguments tool run bdk mcp from this repository root. For clients that read .mcp.json, merge this server into the existing configuration:
{
"mcpServers": {
"bdk": {
"command": "dotnet",
"args": ["tool", "run", "bdk", "mcp"]
}
}
}
Reload the client's MCP connection. MCP client setup covers other configuration formats.
Check the tools
Ask the agent to call bdk_mcp_status, then bdk_docs_search with query host builder and bdk_guidance_list. Expect the correct workspace, documentation results, and guidance topics. No running host is needed.
The step prompts use bdk_docs_get to read feature guides, bdk_guidance_get for implementation checklists, and bdk_api_search with bdk_api_get for exact signatures.
AI prompt
Set up step 2, "Install bdk and connect MCP", of the guide "Build an app with DevKit" in this repository. Do not change application code.
Read https://bridgingit-gmbh.github.io/bITdevKit/getting-started-existing-app/#step-2.
Inspect the local tool manifest and MCP client configuration. Install or restore BridgingIT.DevKit.Cli and merge the bdk server into the client's configuration, preserving existing tools and servers. Run dotnet tool run bdk mcp from this repository root through the MCP client.
If the client needs a reload, report how to reload it and resume verification after reconnecting. Do not claim the connection works until the tools respond.
Call bdk_mcp_status and check the workspace. Call bdk_docs_search with query host builder, read a result with bdk_docs_get, and call bdk_guidance_list. These tools need no running DevKit host.
Read the linked reference guide with the bdk MCP tool bdk_docs_get and source docs/features-cli-mcp-clients.md.
If documentation is truncated, read the full document from its returned URL.
The starting application needs only its existing route from step 1. No database, entity, or customer endpoints are required. Keep application code unchanged.
Report the configuration files and check results. If devkit-plan.md exists, tick step 2 only after all checks pass. Leave changes uncommitted for my review. Do not apply later steps.
Add the DevKit application builder¶
Install the host package, then replace WebApplication.CreateBuilder with DevKitWebApplication.CreateBuilder:
dotnet add package BridgingIT.DevKit.Presentation.Web
using BridgingIT.DevKit.Common;
using BridgingIT.DevKit.Presentation.Web;
var builder = DevKitWebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Customers API is running.");
app.Run();
Keep all DevKit packages on the same version. With Central Package Management, manage those versions in Directory.Packages.props.
Check it
Build and run the app. The root route still responds. In Development, dotnet tool run bdk hosts list also finds the host.
The builder makes DevKit host integrations available. Enable logging, request correlation, or dashboards when you need them.
AI prompt
Do step 3, "Add the DevKit application builder", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 3 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Read the linked reference guide with the bdk MCP tool bdk_docs_get and source docs/features-presentation.md.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 3 in the plan and report the result. Leave the changes uncommitted for my review.
Add a module and its appsettings configuration¶
A module owns its feature registrations and configuration. Add a Customers module before introducing any data model.
CustomersModule.cs
namespace Customers.Web.Modules.Customers;
using BridgingIT.DevKit.Common;
public class CustomersModule : WebModuleBase
{
private CustomersModuleConfiguration moduleConfiguration = null!;
public override IServiceCollection Register(
IServiceCollection services,
IConfiguration? configuration = null,
IWebHostEnvironment? environment = null)
{
this.moduleConfiguration = this.Configure<CustomersModuleConfiguration,
CustomersModuleConfiguration.Validator>(services, configuration);
return services;
}
public override IApplicationBuilder Use(
IApplicationBuilder app,
IConfiguration? configuration = null,
IWebHostEnvironment? environment = null) => app;
public override IEndpointRouteBuilder Map(
IEndpointRouteBuilder app,
IConfiguration? configuration = null,
IWebHostEnvironment? environment = null)
{
app.MapGet("/api/customers/status", () => Results.Ok(new
{
module = this.Name,
message = this.moduleConfiguration.Greeting,
})).WithTags("Customers");
return app;
}
}
Typed module configuration
namespace Customers.Web.Modules.Customers;
using FluentValidation;
public class CustomersModuleConfiguration
{
public string Greeting { get; set; } = string.Empty;
public class Validator : AbstractValidator<CustomersModuleConfiguration>
{
public Validator()
{
this.RuleFor(c => c.Greeting).NotEmpty();
}
}
}
Add this section to appsettings.json. Keep the app's other settings:
{
"Modules": {
"customers": {
"Enabled": true,
"Greeting": "Customers module is ready."
}
}
}
CustomersModule has the module name customers. Configure<T, TValidator> binds and validates Modules:customers. The module registry reads Enabled from the same section.
Register the module before builder.Build() and run its lifecycle after the app is built:
using BridgingIT.DevKit.Common;
using BridgingIT.DevKit.Presentation.Web;
using Customers.Web.Modules.Customers;
var builder = DevKitWebApplication.CreateBuilder(args);
builder.Services.AddModules(builder.Configuration, builder.Environment, modules => modules
.WithModule<CustomersModule>());
var app = builder.Build();
app.UseRequestModuleContext();
app.UseModules();
app.MapModules();
app.MapGet("/", () => "Customers API is running.");
app.Run();
Check it
Run Invoke-RestMethod http://localhost:5199/api/customers/status. Expect module customers and the configured greeting. Change Greeting, restart, and check that the response changes. An empty greeting fails configuration validation at startup.
Modules covers naming, configuration, and module lifecycle behavior.
AI prompt
Do step 4, "Add a module and its appsettings configuration", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 4 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Call the bdk MCP tool bdk_guidance_get with topic modules.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 4 in the plan and report the result. Leave the changes uncommitted for my review.
Add the Customer entity¶
Introduce the first domain type. The aggregate has an ID and a factory for creating customers. Persistence comes in the next step.
namespace Customers.Web;
using BridgingIT.DevKit.Domain.Model;
public class Customer : AggregateRoot<Guid>
{
private Customer()
{
}
public string FirstName { get; private set; } = string.Empty;
public string LastName { get; private set; } = string.Empty;
public string Email { get; private set; } = string.Empty;
public static Customer Create(string firstName, string lastName, string email)
{
var customer = new Customer
{
Id = Guid.NewGuid(),
FirstName = firstName,
LastName = lastName,
Email = email,
};
return customer;
}
}
Check it
Run dotnet build. The app and module status route still work without a database.
Domain building blocks explains entities and aggregate roots.
AI prompt
Do step 5, "Add the Customer entity", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 5 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Call the bdk MCP tool bdk_guidance_get with topic domain.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 5 in the plan and report the result. Leave the changes uncommitted for my review.
Add SQL Server persistence¶
Use a local SQL Server instance and a database dedicated to this guide. Install the provider and EF Core design tools:
dotnet add package BridgingIT.DevKit.Infrastructure.EntityFramework.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Design --version 10.*
dotnet tool install dotnet-ef --version 10.*
If dotnet-ef is already in the local tool manifest, restore it instead. Keep its major version and the design package aligned with the installed EF Core version.
namespace Customers.Web;
using Microsoft.EntityFrameworkCore;
public class CustomersDbContext(DbContextOptions<CustomersDbContext> options) : DbContext(options)
{
public DbSet<Customer> Customers { get; set; } = null!;
}
Extend CustomersModuleConfiguration with the connection string dictionary and its validator:
Updated module configuration
namespace Customers.Web.Modules.Customers;
using FluentValidation;
public class CustomersModuleConfiguration
{
public string Greeting { get; set; } = string.Empty;
public Dictionary<string, string> ConnectionStrings { get; set; } = new();
public class Validator : AbstractValidator<CustomersModuleConfiguration>
{
public Validator()
{
this.RuleFor(c => c.Greeting).NotEmpty();
this.RuleFor(c => c.ConnectionStrings)
.Must(strings => strings is not null
&& strings.TryGetValue("Default", out var value)
&& !string.IsNullOrWhiteSpace(value))
.WithMessage("Connection string 'Default' is required.");
}
}
}
Store the connection string under the module, alongside its other settings:
{
"Modules": {
"customers": {
"Enabled": true,
"Greeting": "Customers module is ready.",
"ConnectionStrings": {
"Default": "Server=localhost;Database=CustomersDev;Integrated Security=true;TrustServerCertificate=true"
}
}
}
}
The example uses Windows integrated authentication. Replace the server and authentication settings for your SQL Server installation. For a SQL login, supply the full string through Modules__customers__ConnectionStrings__Default instead of putting a password in source control.
In CustomersModule.Register, after Configure<...>, add:
services.AddSqlServerDbContext<CustomersDbContext>(options => options
.UseConnectionString(this.moduleConfiguration.ConnectionStrings["Default"]))
.WithDatabaseMigratorService(options => options
.Enabled(environment?.IsDevelopment() == true)
.HaltOnFailure());
Add using BridgingIT.DevKit.Infrastructure.EntityFramework; to the module. The migrator applies pending EF Core migrations at startup in Development. It does not delete the database. If deployment tooling owns schema changes, apply migrations there instead.
The design-time factory reads the same module configuration when EF tools run:
namespace Customers.Web;
using BridgingIT.DevKit.Infrastructure.EntityFramework;
using Microsoft.EntityFrameworkCore;
public class CustomersDbContextFactory : SqlServerModuleDbContextFactory<CustomersDbContext>
{
public CustomersDbContextFactory()
: base("Modules:customers:ConnectionStrings:Default",
(options, connectionString) => options.UseSqlServer(connectionString))
{
}
}
With the app stopped, create the first schema migration:
dotnet ef migrations add InitialCustomers --context CustomersDbContext
Check it
Start the app in Development. The migrator runs after the host starts. Wait for the Customers table to appear in SQL Server, then request the module status route. No customer data or previous migration was required before this step.
AI prompt
Do step 6, "Add SQL Server persistence", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 6 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Read the linked reference guide with the bdk MCP tool bdk_docs_get and source docs/features-modules.md.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 6 in the plan and report the result. Leave the changes uncommitted for my review.
Register the Customer repository¶
The repository exposes persistence through the domain abstraction. Add this registration to CustomersModule.Register after the context registration:
services.AddEntityFrameworkRepository<Customer, CustomersDbContext>()
.WithBehavior<RepositoryLoggingBehavior<Customer>>();
Add using BridgingIT.DevKit.Domain.Repositories; to the module. Application handlers can now depend on IGenericRepository<Customer>.
Check it
Build and start the app. The existing status routes still respond. The next steps add the use cases and HTTP routes that exercise the repository.
Repositories covers querying, behaviors, and provider capabilities.
AI prompt
Do step 7, "Register the Customer repository", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 7 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Call the bdk MCP tool bdk_guidance_get with topic repositories.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 7 in the plan and report the result. Leave the changes uncommitted for my review.
Add commands, queries, and validation¶
Add a command for creating customers and a query for finding one. The handlers use the repository from the start.
CustomerCreateCommand.cs
namespace Customers.Web.Modules.Customers;
using BridgingIT.DevKit.Common;
using FluentValidation;
using BridgingIT.DevKit.Domain.Repositories;
public class CustomerCreateCommand : RequestBase<Customer>
{
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public class Validator : AbstractValidator<CustomerCreateCommand>
{
public Validator()
{
this.RuleFor(c => c.FirstName).NotEmpty();
this.RuleFor(c => c.LastName).NotEmpty();
this.RuleFor(c => c.Email).NotEmpty().EmailAddress();
}
}
}
public class CustomerCreateCommandHandler(IGenericRepository<Customer> repository)
: RequestHandlerBase<CustomerCreateCommand, Customer>
{
protected override async Task<Result<Customer>> HandleAsync(
CustomerCreateCommand request, SendOptions options, CancellationToken cancellationToken)
{
var customer = Customer.Create(request.FirstName, request.LastName, request.Email);
await repository.InsertAsync(customer, cancellationToken);
return customer;
}
}
CustomerFindOneQuery.cs
namespace Customers.Web.Modules.Customers;
using BridgingIT.DevKit.Common;
using BridgingIT.DevKit.Domain.Repositories;
public class CustomerFindOneQuery(Guid id) : RequestBase<Customer>
{
public Guid Id { get; } = id;
}
public class CustomerFindOneQueryHandler(IGenericRepository<Customer> repository)
: RequestHandlerBase<CustomerFindOneQuery, Customer>
{
protected override async Task<Result<Customer>> HandleAsync(
CustomerFindOneQuery request, SendOptions options, CancellationToken cancellationToken)
{
return await repository.FindOneResultAsync(
request.Id, cancellationToken: cancellationToken);
}
}
In Program.cs, before builder.Build(), register the requester and validation behavior:
builder.Services.AddRequester()
.AddHandlers()
.WithBehavior(typeof(ValidationPipelineBehavior<,>));
Check it
Run dotnet build. The handlers, validator, and repository registration compile together. Step 9 exposes them through the API.
Commands and queries, Requester and Notifier, and Results.
AI prompt
Do step 8, "Add commands, queries, and validation", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 8 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Call the bdk MCP tool bdk_guidance_get once for each of the topics commands_queries, requester_notifier and results.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 8 in the plan and report the result. Leave the changes uncommitted for my review.
Add the Customer endpoints¶
The endpoints map HTTP requests to the handlers and their results to status codes.
CustomerEndpoints.cs
namespace Customers.Web.Modules.Customers;
using BridgingIT.DevKit.Common;
using BridgingIT.DevKit.Presentation.Web;
using Microsoft.AspNetCore.Mvc;
public class CustomerEndpoints : EndpointsBase
{
public override void Map(IEndpointRouteBuilder app)
{
var group = app.MapGroup("api/customers").WithTags("Customers");
group.MapGet("/{id:guid}", async (
Guid id,
[FromServices] IRequester requester,
CancellationToken cancellationToken) =>
{
var query = new CustomerFindOneQuery(id);
var result = await requester.SendAsync(
query, cancellationToken: cancellationToken);
return result.MapHttpOk();
});
group.MapPost("/", async (
[FromBody] CustomerCreateCommand command,
[FromServices] IRequester requester,
CancellationToken cancellationToken) =>
{
var result = await requester.SendAsync(
command, cancellationToken: cancellationToken);
return result.MapHttpCreated(customer => $"/api/customers/{customer.Id}");
});
}
}
Add services.AddEndpoints<CustomerEndpoints>(); in CustomersModule.Register. Add app.MapEndpoints(); in Program.cs after app.MapModules();.
Check it
$customer = Invoke-RestMethod http://localhost:5199/api/customers -Method Post -ContentType application/json -Body '{"firstName":"Ada","lastName":"Lovelace","email":"ada@example.test"}'
Invoke-RestMethod "http://localhost:5199/api/customers/$($customer.id)"
Expect 201 when creating a customer and 200 when reading it. Restart the app and read the same ID to confirm SQL Server persistence. An empty last name or invalid email returns 400. A missing ID returns 404.
Endpoints covers endpoint discovery and result mapping.
AI prompt
Do step 9, "Add the Customer endpoints", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 9 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Read the linked reference guide with the bdk MCP tool bdk_docs_get and source docs/features-presentation-endpoints.md.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 9 in the plan and report the result. Leave the changes uncommitted for my review.
Publish a domain event¶
Add this step when creating a customer should trigger a separate reaction. Register the event in Customer.Create before returning the new customer:
customer.DomainEvents.Register(new CustomerCreatedDomainEvent(customer.Id));
Event and handler
namespace Customers.Web;
using BridgingIT.DevKit.Domain;
public class CustomerCreatedDomainEvent(Guid customerId) : DomainEventBase
{
public Guid CustomerId { get; } = customerId;
}
namespace Customers.Web.Modules.Customers;
using BridgingIT.DevKit.Domain;
public class CustomerCreatedDomainEventHandler(ILoggerFactory loggerFactory)
: DomainEventHandlerBase<CustomerCreatedDomainEvent>(loggerFactory)
{
public override bool CanHandle(CustomerCreatedDomainEvent @event) => true;
public override Task Process(CustomerCreatedDomainEvent @event, CancellationToken cancellationToken)
{
this.Logger.LogInformation("customer {CustomerId} created", @event.CustomerId);
return Task.CompletedTask;
}
}
Register the notifier before builder.Build():
builder.Services.AddNotifier()
.AddHandlers();
Extend the repository registration to publish events after saving:
services.AddEntityFrameworkRepository<Customer, CustomersDbContext>()
.WithBehavior<RepositoryLoggingBehavior<Customer>>()
.WithBehavior<RepositoryDomainEventPublisherBehavior<Customer>>();
Check it
Repeat the create/read check. The customer is stored and the event handler runs after the insert. Domain events remain internal to the application. This step introduces no schema change.
Domain events covers immediate publication. The outbox recipe adds durable publication when needed.
AI prompt
Do step 10, "Publish a domain event", of the guide "Build an app with DevKit" in this application, and nothing else.
Use the bdk MCP connection from step 2. If it is unavailable, reconnect using step 2 before editing.
Read step 10 with bdk_docs_get and source docs/site/getting-started-existing-app.md.
Call the bdk MCP tool bdk_guidance_get once for each of the topics domain_events and requester_notifier.
Use bdk_docs_search for additional feature guides. Verify DevKit signatures with bdk_api_search, then bdk_api_get using the returned uid. If documentation is truncated, read the full document from its returned URL.
Read devkit-plan.md for this app's names and rules. If it does not exist, run the planning prompt from the section "Use an agent" in the guide, and wait for my approval.
If an earlier step is unchecked in the plan, stop and tell me.
Make the change with this app's names from the plan. Build the application or solution, run the step's check from the plan, and stop the app.
Tick step 10 in the plan and report the result. Leave the changes uncommitted for my review.
Complete setup¶
Program.cs
using BridgingIT.DevKit.Common;
using BridgingIT.DevKit.Presentation.Web;
using Customers.Web.Modules.Customers;
var builder = DevKitWebApplication.CreateBuilder(args);
builder.Services.AddModules(builder.Configuration, builder.Environment, modules => modules
.WithModule<CustomersModule>());
builder.Services.AddRequester()
.AddHandlers()
.WithBehavior(typeof(ValidationPipelineBehavior<,>));
builder.Services.AddNotifier()
.AddHandlers();
var app = builder.Build();
app.UseRequestModuleContext();
app.UseModules();
app.MapModules();
app.MapEndpoints();
app.MapGet("/", () => "Customers API is running.");
app.Run();
CustomersModule.cs
namespace Customers.Web.Modules.Customers;
using BridgingIT.DevKit.Common;
using BridgingIT.DevKit.Domain.Repositories;
using BridgingIT.DevKit.Infrastructure.EntityFramework;
public class CustomersModule : WebModuleBase
{
private CustomersModuleConfiguration moduleConfiguration = null!;
public override IServiceCollection Register(
IServiceCollection services,
IConfiguration? configuration = null,
IWebHostEnvironment? environment = null)
{
this.moduleConfiguration = this.Configure<CustomersModuleConfiguration,
CustomersModuleConfiguration.Validator>(services, configuration);
services.AddSqlServerDbContext<CustomersDbContext>(options => options
.UseConnectionString(this.moduleConfiguration.ConnectionStrings["Default"]))
.WithDatabaseMigratorService(options => options
.Enabled(environment?.IsDevelopment() == true)
.HaltOnFailure());
services.AddEntityFrameworkRepository<Customer, CustomersDbContext>()
.WithBehavior<RepositoryLoggingBehavior<Customer>>()
.WithBehavior<RepositoryDomainEventPublisherBehavior<Customer>>();
services.AddEndpoints<CustomerEndpoints>();
return services;
}
public override IApplicationBuilder Use(
IApplicationBuilder app,
IConfiguration? configuration = null,
IWebHostEnvironment? environment = null) => app;
public override IEndpointRouteBuilder Map(
IEndpointRouteBuilder app,
IConfiguration? configuration = null,
IWebHostEnvironment? environment = null)
{
app.MapGet("/api/customers/status", () => Results.Ok(new
{
module = this.Name,
message = this.moduleConfiguration.Greeting,
})).WithTags("Customers");
return app;
}
}
Keep domain types in Domain, handlers in Application, persistence in Infrastructure, and endpoints and module composition in Presentation when you split into layer projects. The guide keeps one project so each addition is visible.
Use an agent¶
Start with the minimal API in step 1 and connect bdk MCP in step 2. Then use these prompts to plan and build the features. Keep the connection string pointed at a dedicated development SQL Server database.
1. Plan the change
Plan how to build up this Web API with bITdevKit. Do not change application code yet.
Read "Build an app with DevKit" with bdk_docs_get, source docs/site/getting-started-existing-app.md. If the response is truncated, read the full document from its returned URL. Use the bdk MCP connection established in step 2. Call bdk_guidance_list and bdk_guidance_get for modules, domain, repositories, commands_queries, requester_notifier, and domain_events. Verify proposed DevKit signatures with bdk_api_search and bdk_api_get.
Inspect the host, target framework, nullable setting, configuration files, and existing routes. Start from a minimal Web API. Do not assume an entity, DbContext, repository, database, or EF migration already exists.
Write devkit-plan.md with:
1. Names: the app project, namespace, module, entity, context, routes, and URL. Use the guide's Customer feature or map it to a feature I requested.
2. Configuration: the Modules:customers section, its typed configuration, the SQL Server instance, and a dedicated development database. Preserve unrelated configuration.
3. Steps: the files each of the ten steps adds or changes. Mark existing equivalent capabilities as complete. Domain events are optional.
4. Checks: the root route first, configured module status after step 4, SQL Server schema after step 6, and customer create/read, persistence, validation, and not-found behavior after step 9.
5. Rules: change one step at a time, preserve existing working features, keep DevKit packages on the same version, and stop if a required API is unavailable or a check fails. Create the InitialCustomers migration in step 6. Never delete a database or alter unrelated tables. Use environment configuration for SQL credentials. Stop application processes started for a check. Never commit devkit-plan.md.
Stop for my review of the plan before implementing the remaining steps.
2. Apply the steps
Build up this Web API following devkit-plan.md and "Build an app with DevKit". If the plan is missing, run the planning prompt first and wait for my review.
Use a branch for this work. Work through unchecked steps in order. Read each step and its references with bdk_docs_get; use bdk_docs_search for additional guides. Read the matching bdk_guidance_get topics and verify DevKit signatures with bdk_api_search and bdk_api_get. If documentation is truncated, read the full document from its returned URL.
Start from the minimal app, then add the DevKit builder, module with appsettings configuration, entity, SQL Server context, repository, handlers, endpoints, and optional domain event. Do not convert existing entities or persistence just to reproduce the sample.
Build after each step and run its check from the plan. The database first appears in step 6. Preserve unrelated routes, features, and data. Record each result and stop processes used for the check. Leave changes uncommitted for review and report the files changed, checks, and any deviations.
Choose the next step¶
Add the capabilities your application needs through the independent feature recipes. Logging, request correlation, background work, storage, dashboards, and AI runtime tools can be enabled separately.