skills/team/dotnet-controller-api-scaffolder/SKILL.md
Scaffolds controller-based ASP.NET Core Web API endpoints ([ApiController]/ControllerBase) that CONFORM to an existing codebase — base controller, validation (DataAnnotations or FluentValidation), service layer vs. mediator, response envelope, routing, versioning, DI. Detect-and-match, never impose. Use when adding controllers/actions to an existing controller-based API. Not for greenfield Minimal APIs (minimal-api-scaffolder); use dotnet-vertical-slice only when the team has chosen CQRS/vertical-slice.
npx skillsauth add michaelalber/ai-toolkit dotnet-controller-api-scaffolderInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
"When in Rome, do as the Romans do." — Ambrose of Milan
"A good API is not just easy to use but also hard to misuse." — Joshua Bloch
This skill adds controller-based Web API endpoints to an existing ASP.NET Core codebase. The codebase already has conventions — a base controller, a validation style, a way to talk to the data/service layer, a response shape, a routing scheme. This skill's job is to detect those conventions and conform to them, producing controllers a reviewer cannot distinguish from hand-written team code.
Non-Negotiable Constraints:
[ApiController] + Attribute Routing — Every API controller derives from ControllerBase (never Controller), carries [ApiController], and uses attribute routing ([Route], [HttpGet]…). No convention-based MVC routing for APIs.try/catch per action when a global handler exists.[ProducesResponseType] for every status code, and surface errors as RFC 7807 ProblemDetails — or the project's existing error envelope if one is established.The full 10-row Domain Principles Table, Knowledge Base lookups, AI Discipline Rules,
Anti-Patterns Table, and Error-Recovery procedures live in
references/principles-and-pitfalls.md.
The lifecycle flows: DETECT → SCAFFOLD → SECURE → DOCUMENT. DETECT is mandatory and gates everything else — its output is the convention profile every later phase obeys.
Inventory the existing conventions. See references/convention-detection.md for the grep commands.
grep <TargetFramework> across .csprojApiControllerBase / BaseApiController exist? What does it provide?IXxxService), mediator (Send()), or direct DbContext?IValidator<T>ActionResult<T>, or a custom envelope (ApiResponse<T>)?[Authorize]? Policies? Anonymous opt-out?Generate controller + DTOs + (validators or annotations) matching the profile.
ControllerBase + [ApiController])IValidator<T>)[Authorize], explicit [AllowAnonymous])[ProducesResponseType] for all status codesGenerateDocumentationFile)<controller-scaffold-state>
mode: DETECT | SCAFFOLD | SECURE | DOCUMENT
target_framework: net8.0
base_controller: ApiControllerBase # or "ControllerBase (none found)"
data_boundary: service-layer # service-layer | mediator | direct-dbcontext
validation: dataannotations # dataannotations | fluentvalidation
response_shape: ActionResult<T> # ActionResult<T> | ApiResponse<T> envelope | raw DTO
versioning: url-segment # url-segment | header | query | none
auth_default: class-level [Authorize]
controllers_created: [UsersController]
last_action: Detected conventions; emitted profile for confirmation
next_action: Scaffold UsersController matching service-layer + DataAnnotations
</controller-scaffold-state>
## Convention Profile: [Solution] | .NET [version]
| Aspect | Detected | New code will |
|--------|----------|--------------|
| Base controller | ApiControllerBase | derive from it |
| Data boundary | IXxxService service layer | inject + delegate |
| Validation | DataAnnotations | annotate DTOs |
| Response shape | ActionResult<T> | match |
| Versioning | /api/v{n} URL segment | match |
| Auth default | class-level [Authorize] | match |
## Controller: [Resource]Controller
Route: /api/v{n}/[resource] | Base: [base] | Auth: [Required/Anonymous]
| Verb | Route | Action | Request DTO | Response DTO | Status Codes |
| GET | / | GetAll | [Query]DTO | PagedResult<T> | 200,401 |
| GET | /{id} | GetById | — | TDto | 200,404,401 |
| POST | / | Create | CreateTRequest | TDto | 201,400,401 |
| PUT | /{id} | Update | UpdateTRequest | — | 204,400,404,401 |
| DELETE | /{id} | Delete | — | — | 204,404,401 |
Full controller, DTO, validator, ProblemDetails, and testing templates:
references/controller-patterns.md. Convention detection commands:
references/convention-detection.md. Auth/CORS/rate-limit/integration-test patterns:
references/security-and-testing.md.
| Skill | Integration Point | When to Use |
|-------|-------------------|-------------|
| dotnet-architecture-checklist | Review the controller/N-tier project before and after scaffolding | Confirms the detected style and grades against it |
| minimal-api-scaffolder | Sibling for the Minimal API paradigm | When the project is (or should be) Minimal API, not controllers |
| dotnet-vertical-slice | Alternative for teams that have chosen CQRS/vertical slice | Only when the team uses that architecture — not for layered projects |
| test-scaffold | Generate controller integration tests | WebApplicationFactory<Program> tests exercising the new actions |
| dotnet-security-review | Security audit of the new endpoints | Verify auth, validation, CORS, and no entity leakage |
| ef-migration-manager | Schema changes behind new endpoints | When new actions require entities or migrations |
| react-feature-slice | Front-end consumer of these endpoints | Generate the typed React data layer that calls the new controller |
References: references/principles-and-pitfalls.md (principles, KB lookups, discipline,
anti-patterns, error recovery) | references/convention-detection.md (detection grep
commands + decision rules) | references/controller-patterns.md (controller, DTO,
validator, ProblemDetails templates for service-layer and mediator variants) |
references/security-and-testing.md (authorization, CORS, rate limiting, integration tests).
development
Interviews the user relentlessly about a plan, decision, or idea — one question at a time, each with a recommended answer. Shared engine behind "grill-me" and "grill-with-docs". Use on any "grill" trigger phrase or to stress-test thinking. Do NOT use to build the plan; it ends at shared understanding, not implementation.
testing
Runs a relentless interview to sharpen a plan or design, capturing the decisions as ADRs and a glossary along the way. Use when the user wants to be grilled AND wants the session to leave durable domain documentation behind. Do NOT use for a throwaway stress-test with no artifacts; use grill-me instead.
tools
OWASP-based security review of Vue/TypeScript front-ends. Detects framework (Vite/Vue CLI/Nuxt), entry points, and data flows; scans the OWASP Top 10 (2025) mapped to Vue client-side risks (raw-HTML XSS via v-html, URL/protocol injection, bundled secrets, insecure token storage, dependency CVEs, missing CSP, open redirects, router guard bypass); emits an exec summary plus graded findings. Use to audit Vue for vulnerabilities. Not for architecture grading (vue-architecture-checklist).
tools
Analyzes legacy Vue codebases and produces actionable modernization plans. Primary migration paths include Options API to Composition API, Vue 2 to Vue 3, Vue CLI to Vite, JavaScript to TypeScript, Vue Test Utils/Karma/Mocha to Vitest + Vue Testing Library, legacy Vuex to Pinia, and removed-in-Vue-3 pattern cleanup (filters, event bus, `$listeners`). Does NOT perform the migration — assesses, quantifies risk, and plans.