Skip to content
Development
Agent

controller-generator

Generates ASP.NET Core API controllers following Clean Architecture patterns

From plugin
f5-framework
24104 skills104 agents69 commands

Claude Code

> /plugin marketplace add Fujigo-Software/f5-framework-claude

Agent definition

controller-generator.md
name: dotnet-controller-generator
description: Generates ASP.NET Core API controllers following Clean Architecture patterns
triggers:
  - create controller
  - generate controller
  - add controller
  - dotnet controller
  - aspnet controller

ASP.NET Core Controller Generator

Purpose

Generate API controllers following Clean Architecture principles with proper dependency injection, validation, and error handling.

Required Context

Before generating, gather: 1. **Entity Name**: PascalCase name (e.g., `Product`) 2. **CRUD Operations**: Which operations to include (Create, Read, Update, Delete) 3. **Authorization**: Required roles/policies 4. **Service Interface**: Service to inject

Generation Template

// {{SolutionName}}.API/Controllers/{{EntityName}}sController.cs
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using {{SolutionName}}.Application.DTOs;
using {{SolutionName}}.Application.Interfaces;

namespace {{SolutionName}}.API.Controllers;

[ApiController]
[Route("api/[controller]")]
[Produces("application/json")]
public class {{EntityName}}sController : ControllerBase
{
    private readonly I{{EntityName}}Service _service;
    private readonly ILogger<{{EntityName}}sController> _logger;

    public {{EntityName}}sController(
        I{{EntityName}}Service service,
        ILogger<{{EntityName}}sController> logger)
    {
        _service = service;
        _logger = logger;
    }

    /// <summary>
    /// Get all {{entityName}}s with optional filtering
    /// </summary>
    [HttpGet]
    [ProducesResponseType(typeof(IEnumerable<{{EntityName}}Dto>), StatusCodes.Status200OK)]
    public async Task<ActionResult<IEnumerable<{{EntityName}}Dto>>> GetAll(
        [FromQuery] {{EntityName}}FilterDto filter,
        CancellationToken cancellationToken)
    {
        var result = await _service.GetAllAsync(filter, cancellationToken);
        return Ok(result);
    }

    /// <summary>
    /// Get a {{entityName}} by ID
    /// </summary>
    [HttpGet("{id:guid}")]
    [ProducesResponseType(typeof({{EntityName}}Dto), StatusCodes.Status200OK)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    public async Task<ActionResult<{{EntityName}}Dto>> GetById(
        Guid id,
        CancellationToken cancellationToken)
    {
        var result = await _service.GetByIdAsync(id, cancellationToken);

        if (result is null)
            return NotFound();

        return Ok(result);
    }

    /// <summary>
    /// Create a new {{entityName}}
    /// </summary>
    [HttpPost]
    [Authorize(Policy = "{{EntityName}}Write")]
    [ProducesResponseType(typeof({{EntityName}}Dto), StatusCodes.Status201Created)]
    [ProducesResponseType(StatusCodes.Status400BadRequest)]
    public async Task<ActionResult<{{EntityName}}Dto>> Create(
        [FromBody] Create{{EntityName}}Dto dto,
        CancellationToken cancellationToken)
    {
        var result = await _service.CreateAsync(dto, cancellationToken);

        return CreatedAtAction(
            nameof(GetById),
            new { id = result.Id },
            result);
    }

    /// <summary>
    /// Update an existing {{entityName}}
    /// </summary>
    [HttpPut("{id:guid}")]
    [Authorize(Policy = "{{EntityName}}Write")]
    [ProducesResponseType(typeof({{EntityName}}Dto), StatusCodes.Status200OK)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    [ProducesResponseType(StatusCodes.Status400BadRequest)]
    public async Task<ActionResult<{{EntityName}}Dto>> Update(
        Guid id,
        [FromBody] Update{{EntityName}}Dto dto,
        CancellationToken cancellationToken)
    {
        var result = await _service.UpdateAsync(id, dto, cancellationToken);

        if (result is null)
            return NotFound();

        return Ok(result);
    }

    /// <summary>
    /// Delete a {{entityName}}
    /// </summary>
    [HttpDelete("{id:guid}")]
    [Authorize(Policy = "{{EntityName}}Delete")]
    [ProducesResponseType(StatusCodes.Status204NoContent)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    public async Task<IActionResult> Delete(
        Guid id,
        CancellationToken cancellationToken)
    {
        var success = await _service.DeleteAsync(id, cancellationToken);

        if (!success)
            return NotFound();

        return NoContent();
    }
}

Generation Checklist

  • [ ] Controller inherits from ControllerBase
  • [ ] Route attribute uses [controller] placeholder
  • [ ] ApiController attribute present
  • [ ] Proper HTTP method attributes
  • [ ] ProducesResponseType for Swagger
  • [ ] CancellationToken in all async methods
  • [ ] Authorization policies applied
  • [ ] XML documentation comments
  • [ ] Dependency injection via constructor

Related Templates

  • `templates/dotnet-controller.md` - Full controller template
  • `templates/dotnet-dto.md` - DTO generation
  • `templates/dotnet-service.md` - Service interface
Read more
@fujigo-software
Ships withf5-framework

AI-Powered Development Framework for Claude Code

2434 skills104 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
24
Star history of Fujigo-Software/f5-framework-claude on GitHub, a chart by star-history.com

Other agents on f5-framework.

More agents from other plugins.

a11y-architect
Auto-invoked

a11y-architect

Agent

Accessibility Architect specializing in WCAG 2.2 compliance for Web and Native platforms. Use PROACTIVELY when designing UI…

ecc2w293k
@affaan-m@affaan-mInstall Agent
analyze-pass-impact

analyze-pass-impact

Agent

Analyzes how a specific topic affects a group of compiler passes. Used by the /plan-update skill to parallelize research across…

react4d252k
@facebook@facebookInstall Agent
orchestrator

orchestrator

Agent

- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as…

codex3d135k
@openai@openaiInstall Agent
cavecrew-builder

cavecrew-builder

Agent

Surgical 1-2 file edit. Typo fixes, single-function rewrites, mechanical renames, comment removal, format-preserving tweaks. Hard…

caveman4d119k
@juliusbrussee@juliusbrusseeInstall Agent

Questions about controller-generator.

Which coding agents can use controller-generator?
controller-generator installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.