controller-api-implementation

Implement HTTP and gRPC controllers as contract-safe transport adapters.

4|Updated May 16, 2026
One-click install
npx skills add https://github.com/machenjie/rd-skills --skill controller-api-implementation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: controller-api-implementation
Source: https://github.com/machenjie/rd-skills/tree/main/src/foundation/capabilities/controller-api-implementation
Command: npx skills add https://github.com/machenjie/rd-skills --skill controller-api-implementation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents API controllers from turning into messy business-logic hotspots by enforcing a strict transport-adapter pattern that keeps validation, auth context extraction, response mapping, and error handling consistent and contract-aligned.

Core Features & Use Cases

  • Thin transport adapter design: Parse and validate inputs, extract authentication context, and delegate all business decisions to the application layer.
  • Contract-compliant response mapping: Convert service results into DTOs that match the OpenAPI (or equivalent) response shape and correct HTTP status codes.
  • Safe error boundaries: Transform errors into RFC 7807 Problem Details without leaking internal messages, stack traces, or topology details.
  • Security guardrails at the boundary: Apply trusted-boundary validation, content negotiation discipline, and idempotency-key format validation.

Quick Start

Use controller-api-implementation to guide the implementation of a request handler or gRPC method as a contract-safe adapter: validate input at the boundary, extract auth context, call the service, map outputs to the contract, and return Problem Details for failures.

Frequently Asked Questions about controller-api-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep API controllers thin and prevent them from containing business logic?

To keep API controllers thin, implement them as transport adapters that only parse, validate, and map requests to contract-compliant responses while delegating all business decisions to the application layer. This isolates business logic from the transport layer.

How do I format API error responses using RFC 7807 Problem Details?

Format API error responses using RFC 7807 Problem Details by transforming service errors at the safe boundary without leaking internal messages or stack traces. This ensures correct HTTP status-code mapping and consistent contract-aligned error handling.

How should I handle request validation and auth context extraction in HTTP handlers?

Handle request validation and auth context extraction in HTTP handlers by applying trusted-boundary validation immediately upon deserialization. Extract the auth context at the boundary before delegating execution to the application layer.

Does this transport adapter pattern work for both HTTP handlers and gRPC server methods?

Yes, the transport adapter pattern works for both HTTP handlers and gRPC server methods. It handles route dispatch, request deserialization, content negotiation, and idempotency key handling across different protocol implementations.

Why do my API responses leak internal stack traces and topology details during failures?

API responses leak internal stack traces because error boundaries are not properly isolated. Transform errors into RFC 7807 Problem Details at the controller boundary to map status codes correctly without exposing internal messages or topology details.

How do I implement idempotency key format validation and correlation-aware logging in API controllers?

Implement idempotency key format validation and correlation-aware logging by enforcing security guardrails at the trusted boundary. Capture correlation context during request parsing to maintain strict forbidden responsibilities for maintainability.