一键导入
planforge-new-controller
Scaffold a REST API controller with authorization, ProblemDetails error handling, proper HTTP status codes, and CancellationToken.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold a REST API controller with authorization, ProblemDetails error handling, proper HTTP status codes, and CancellationToken.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run a comprehensive code review across architecture, security, testing, naming, and patterns. Invokes relevant reviewer agents in sequence. Use before merging features or at the end of a phase. With --quorum, dispatches multi-model analysis for higher confidence.
Audit UI components for WCAG 2.2 compliance, semantic HTML, ARIA labels, keyboard navigation, color contrast, and responsive design.
Audit API endpoints for backward compatibility, versioning, OpenAPI compliance, pagination, rate limiting, and RFC 9457 error responses.
Review code for architecture violations: layer separation, sync-over-async, missing CancellationToken, improper DI. Use for PR reviews or code audits.
Fix a bug using TDD: reproduce with a failing test first, then implement the fix, then verify. Prevents regressions.
Review CI/CD pipelines for best practices: environment promotion, secrets management, rollback strategies, build caching, and deployment safety.
| name | planforge-new-controller |
| description | Scaffold a REST API controller with authorization, ProblemDetails error handling, proper HTTP status codes, and CancellationToken. |
| metadata | {"author":"plan-forge","source":".github/prompts/new-controller.prompt.md"} |
Scaffold a controller that follows REST conventions and delegates all logic to services.
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class {EntityName}Controller(
I{EntityName}Service service,
ILogger<{EntityName}Controller> logger) : ControllerBase
{
[HttpGet("{id:guid}")]
[ProducesResponseType(typeof({EntityName}Dto), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetById(Guid id, CancellationToken ct)
{
var result = await service.GetByIdAsync(id, ct);
return result is not null ? Ok(result) : NotFound();
}
[HttpPost]
[ProducesResponseType(typeof({EntityName}Dto), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> Create([FromBody] Create{EntityName}Request request, CancellationToken ct)
{
var result = await service.CreateAsync(request, ct);
return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
}
[HttpPut("{id:guid}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public async Task<IActionResult> Update(Guid id, [FromBody] Update{EntityName}Request request, CancellationToken ct)
{
var success = await service.UpdateAsync(id, request, ct);
return success ? NoContent() : NotFound();
}
[HttpDelete("{id:guid}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
{
await service.DeleteAsync(id, ct);
return NoContent();
}
}
ProblemDetails for errors (RFC 9457)[ProducesResponseType] for OpenAPI documentationCancellationToken on every action method[Authorize] at class level, [AllowAnonymous] where needed| Exception | HTTP Status |
|---|---|
ValidationException | 400 Bad Request |
NotFoundException | 404 Not Found |
ConflictException | 409 Conflict |
UnauthorizedAccessException | 403 Forbidden |