new-service-route

Generate Fastify route endpoints with schema validation and ADR-002 envelopes.

1|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/mattbutlerengineering/mattbutlerengineering --skill new-service-route
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: new-service-route
Source: https://github.com/mattbutlerengineering/mattbutlerengineering/tree/main/.claude/skills/new-service-route
Command: npx skills add https://github.com/mattbutlerengineering/mattbutlerengineering --skill new-service-route

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Scaffolding new backend endpoints takes time and consistency work—schemas, auth, error envelopes, and optional SSE patterns must match existing Fastify conventions.

Core Features & Use Cases

  • Fastify route scaffolding for monorepo services: Generates a new route handler in one of the Fastify services (reservations, users, agent) following the established “house pattern”.
  • Built-in request validation and OpenAPI metadata: Ensures the route uses Fastify schema for params, body, query, summary, operationId, tags, and response shapes rather than doing manual validation.
  • ADR-002 response/error envelopes: Wraps successes and failures in the ApiResponse / ApiError envelope style and uses createProblemDetails for RFC 7807 error responses.
  • Correct transactional and SSE behavior: Wraps multi-table writes in Prisma transactions and emits SSE events only after the DB commit succeeds (reservations service only).
  • Route test registration: Adds corresponding route-level tests using the existing app.inject() approach and mocks the service layer.

Quick Start

Provide the service name, HTTP method and path, what the route should do, the request and response shapes, and whether the endpoint requires SSE emission, and then ask the skill to scaffold the full route plus tests.

Frequently Asked Questions about new-service-route

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

FAQPage Schema
How do I scaffold a Fastify route with OpenAPI metadata and schema validation?

To scaffold a Fastify route with OpenAPI metadata, generate a handler that uses the Fastify `schema` object for params, body, query, summary, operationId, and response shapes, ensuring full request validation and documentation without manual checks.

How do I structure Prisma transactional writes with SSE event emission in Fastify?

Structuring Prisma transactional writes with SSE events involves wrapping multi-table writes in a Prisma transaction and emitting reservations SSE events only after the database commit succeeds, preventing event emission for rolled-back operations.

What is the ADR-002 ApiResponse envelope and how does it handle RFC 7807 errors?

The ADR-002 ApiResponse envelope wraps API successes and failures in a standardized structure, using `createProblemDetails` to format errors as RFC 7807 problem-details responses for consistent API error handling across Fastify services.

Does this route scaffolding pattern work for monorepo services like reservations, users, and agent?

Yes, this route scaffolding pattern works for monorepo services by matching existing routing conventions specifically across the `reservations`, `users`, and `agent` Fastify services, ensuring consistent auth preHandler usage and house patterns.

How do I add route tests using app.inject for a newly scaffolded Fastify endpoint?

Adding route tests for a scaffolded Fastify endpoint involves registering route-level tests using the existing `app.inject()` approach, mocking the service layer to verify request validation and response behavior without starting a live server.