fastify-patterns

Generate Fastify 5.x API structures with schema-based routing and plugins.

2|1|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/MolcajeteAI/plugin --skill fastify-patterns
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fastify-patterns
Source: https://github.com/MolcajeteAI/plugin/tree/main/deprecated/tech-stacks/js/node/skills/fastify-patterns
Command: npx skills add https://github.com/MolcajeteAI/plugin --skill fastify-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fastify, @fastify/cors, @fastify/jwt, @fastify/swagger, @fastify/swagger-ui, zod, zod-to-json-schema, pino-pretty, @prisma/client, vitest, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive set of patterns and best practices for building high-performance Node.js APIs using the Fastify framework, streamlining development and ensuring robust API design.

Core Features & Use Cases

  • Schema-First Development: Enforces data validation and serialization using Zod schemas.
  • Plugin Architecture: Demonstrates patterns for registering reusable plugins like database connections and authentication.
  • Route Management: Shows how to structure routes, including nested routes and schema-based definitions.
  • Error Handling: Implements a global error handler for consistent error responses.
  • Testing: Includes examples for unit testing routes with Vitest.
  • Use Case: Quickly scaffold a new Fastify API project by leveraging these pre-defined patterns for routing, database integration, and authentication.

Quick Start

Use the fastify-patterns skill to generate a basic Fastify API structure with schema-based routing and a database plugin.

Frequently Asked Questions about fastify-patterns

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

FAQPage Schema
What is the best way to structure a Fastify API with schema validation?▼

The best way to structure a Fastify API is by using schema-first development with Zod schemas to enforce data validation and serialization, alongside a plugin architecture for reusable components like database connections and authentication.

How do I set up global error handling in a Fastify Node.js application?▼

You can set up global error handling in a Fastify Node.js application by implementing a global error handler pattern that intercepts errors and returns consistent error responses across all routes.

Can I use Zod for schema definitions and still generate Swagger documentation in Fastify?▼

Yes, you can use Zod for schema definitions and generate Swagger documentation by converting Zod schemas to JSON schemas using zod-to-json-schema, which integrates with @fastify/swagger for automatic OpenAPI spec generation.

How do I unit test Fastify routes?▼

You can unit test Fastify routes using Vitest, which provides patterns for injecting mock HTTP requests into your route handlers to verify responses and validate schema behavior without starting a live server.

Does this Fastify patterns approach work with Fastify 5.x?▼

Yes, this approach is designed specifically for Fastify 5.x, providing structured patterns for routing, decorators, and plugin registration to ensure maintainable and performant API development in the latest version.

How do I register database connections and JWT authentication as reusable Fastify plugins?▼

You register database connections and JWT authentication as reusable Fastify plugins by encapsulating Prisma client setup and @fastify/jwt configuration within decorated plugin scopes, allowing clean separation and easy route integration.