System for generating structured LLM prompts that produce C# API controller classes.
src/
Controllers/ # Example output: what the generated class looks like
ProductsController.cs
Prompts/
ControllerPromptBuilder.cs # Core: builds the prompt from parameters
examples/
Example_GeneratePrompts.cs # Usage examples with different configs
- Define a
ControllerPromptParametersobject with your desired configuration - Call
ControllerPromptBuilder.Build(parameters)to produce a prompt string - Send that prompt to an LLM — it returns a complete C# controller class
| Parameter | Type | Description |
|---|---|---|
EntityName |
string | Name of the entity (e.g. Product) |
Namespace |
string | C# namespace for the controller |
RoutePrefix |
string | Route template (default: api/[controller]) |
UseAuthorization |
bool | Add [Authorize] attribute |
AuthorizationPolicy |
string? | Named authorization policy |
UseApiVersioning |
bool | Add [ApiVersion] attribute |
ApiVersion |
string? | Version string (e.g. "2.0") |
UseMediatR |
bool | Use MediatR instead of service injection |
UseFluentValidation |
bool | Note FluentValidation in prompt |
GenerateSwaggerAnnotations |
bool | Add [ProducesResponseType] |
Actions |
List | HTTP actions to generate |
var parameters = new ControllerPromptParameters
{
EntityName = "Product",
Actions = new()
{
new ActionDefinition
{
HttpMethod = "Get",
ActionName = "GetAll",
ReturnDtoType = "ProductDto",
IsCollection = true
}
}
};
string prompt = ControllerPromptBuilder.Build(parameters);
// Send `prompt` to your LLM of choiceYou are an expert C# .NET developer.
Generate ONLY the C# source code for the class described below.
## Class to generate
- **Type**: ASP.NET Core API Controller
- **Class name**: `ProductsController`
- **Namespace**: `MyApi.Controllers`
- **Route**: `[Route("api/[controller]")]`
- **Attributes**: `[ApiController]`
## Actions
### GetAll
- **HTTP Method**: `[HttpGet]`
- **Return type**: `async Task<IActionResult>`
- **ProducesResponseType**: `typeof(IEnumerable<ProductDto>)` with status `200`