AP

api-conventions

Ensure API consistency using MX Space design conventions, including decorators, auth, and response transformation.

Install

mkdir -p .claude/skills/api-conventions && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5664" && unzip -o skill.zip -d .claude/skills/api-conventions && rm skill.zip

Installs to .claude/skills/api-conventions

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

MX Space API design conventions. Apply when writing controllers, API endpoints, or handling HTTP requests.
106 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Apply @ApiController decorator to controllers
  • Enforce authentication via @Auth and @CurrentUser decorators
  • Automatically transform responses using ResponseInterceptor
  • Convert JSON fields to snake_case
  • Implement idempotency for create operations
  • Configure HTTP caching for endpoints

How it works

The skill provides a set of decorators and interceptors that enforce consistent routing, authentication, and response formatting across the API.

Inputs & outputs

You give it
TypeScript controller code
You get back
Standardized API endpoint implementation following MX Space conventions

When to use api-conventions

  • Design API controllers
  • Implement endpoint authentication
  • Handle response transformation

About this skill

MX Space API Design Conventions

Controller Decorators

// Use @ApiController instead of @Controller
// Dev environment has no prefix, production auto-adds /api/v{version} prefix
@ApiController('posts')  // ✓
@Controller('posts')     // ✗

Authentication

// Endpoints requiring login
@Auth()
async create() {}

// Optional auth (get current user status)
async get(@IsAuthenticated() isAuth: boolean) {}

// Get current user
async get(@CurrentUser() user: UserModel) {}

Response Transformation

ResponseInterceptor (global APP_INTERCEPTOR) wraps every controller return value:

Return valueEmitted
bare value T{ data: T }
withMeta(data, meta){ data, meta }
undefined204 No Content
@HTTPDecorators.RawResponseuntouched — skips envelope and case conversion

withMeta (from ~/common/response/envelope.types) is detected by an internal Symbol, not by the presence of a data key — returning an object literal whose top-level keys include data gets double-wrapped. CI enforces this via scripts/check-controller-response-envelope.ts.

transformResponseCase (~/common/response/case-transform.ts) converts the response data/meta to snake_case at the wire boundary:

  • createdAtcreated_at
  • categoryIdcategory_id

Opt a field subtree out with @BypassCaseTransform(['items[].rawPayload']).

Pagination

Pagination belongs in meta, never merged into data. Build it with MetaObjectBuilder:

@Get('/')
async list(@Query() query: PagerDto) {
  const result = await this.postRepository.list({
    page: query.page,
    size: query.size,
    sortBy: query.sortBy,
    sortOrder: query.sortOrder,
  })

  const metaBuilder = new MetaObjectBuilder().view('card').pagination({
    page: result.pagination.currentPage,
    size: result.pagination.size,
    total: result.pagination.total,
    totalPages: result.pagination.totalPage,
  })

  return withMeta(result.data, metaBuilder.build())
}

For CRUD boilerplate, use BasePgCrudFactory:

@ApiController(paths)
export class LinkControllerCrud extends BasePgCrudFactory({
  repository: LinkRepository,
}) {
  @Get('/')
  async gets(@Query() pager: PagerDto) {
    const { size = 10, page = 1 } = pager
    return this.repository.list(page, size)
  }
}

Parameter Validation

// Path parameters — use EntityIdDto for Snowflake entity IDs
@Get('/:id')
async get(@Param() params: EntityIdDto) {
  return this.service.findById(params.id)
}

// For integer IDs or entity IDs (e.g. notes with nid)
@Get('/:id')
async get(@Param() params: IntIdOrEntityIdDto) {}

// Query parameters
@Get('/')
async list(@Query() query: PagerDto) {}

// Request body
@Post('/')
async create(@Body() body: CreateDto) {}

HTTP Methods

MethodPurposeStatus Code
GETRetrieve resource200
POSTCreate resource201
PUTFull update200
PATCHPartial update200
DELETEDelete resource204

Error Handling

import { BusinessException } from '~/common/exceptions/biz.exception'
import { ErrorCodeEnum } from '~/constants/error-code.constant'

// Business errors
throw new BusinessException(ErrorCodeEnum.PostNotFound)
throw new BusinessException(ErrorCodeEnum.SlugNotAvailable, slug)

// HTTP errors
throw new BadRequestException('Invalid input')
throw new NotFoundException('Resource not found')
throw new UnauthorizedException('Not logged in')

Idempotency

// Add idempotency protection for create operations
@Post('/')
@HTTPDecorators.Idempotence()
async create() {}

// Custom idempotency key
@HTTPDecorators.Idempotence({ key: 'custom-key' })

Caching

// Disable cache
@Get('/')
@HttpCache.disable
async list() {}

// Custom cache
@HttpCache({ ttl: 60, key: 'my-key' })
async get() {}

When not to use it

  • When building services that do not follow the MX Space API architecture
  • When implementing logic that requires non-standard response formats

Limitations

  • Requires use of specific decorators like @ApiController and @Auth
  • Relies on predefined interceptors for response and JSON transformation

How it compares

It replaces manual boilerplate code with standardized decorators and interceptors to ensure uniform API behavior.

Compared to similar skills

api-conventions side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
api-conventions (this skill)13moNo flagsIntermediate
telegram-mini-app626moReviewAdvanced
stripe-integration482moNo flagsAdvanced
backend-dev-guidelines1028dReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

telegram-mini-app

davila7

Expert in building Telegram Mini Apps (TWA) - web apps that run inside Telegram with native-like experience. Covers the TON ecosystem, Telegram Web App API, payments, user authentication, and building viral mini apps that monetize. Use when: telegram mini app, TWA, telegram web app, TON app, mini app.

62163

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

backend-dev-guidelines

langfuse

Comprehensive backend development guide for Langfuse's Next.js 14/tRPC/Express/TypeScript monorepo. Use when creating tRPC routers, public API endpoints, BullMQ queue processors, services, or working with tRPC procedures, Next.js API routes, Prisma database access, ClickHouse analytics queries, Redis queues, OpenTelemetry instrumentation, Zod v4 validation, env.mjs configuration, tenant isolation patterns, or async patterns. Covers layered architecture (tRPC procedures → services, queue processors → services), dual database system (PostgreSQL + ClickHouse), projectId filtering for multi-tenant isolation, traceException error handling, observability patterns, and testing strategies (Jest for web, vitest for worker).

10100

nodejs-backend-patterns

wshobson

Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.

1246

telegram-dev

2025Emma

Telegram 生态开发全栈指南 - 涵盖 Bot API、Mini Apps (Web Apps)、MTProto 客户端开发。包括消息处理、支付、内联模式、Webhook、认证、存储、传感器 API 等完整开发资源。

232

agent-dev-backend-api

ruvnet

Agent skill for dev-backend-api - invoke with $agent-dev-backend-api

318

Search skills

Search the agent skills registry