
Fastify
- 442 installs
- 63 repo stars
- Updated July 18, 2026
- bobmatnyc/claude-mpm-skills
fastify is a Claude agent skill that scaffolds high-performance Fastify HTTP APIs with JSON-schema validation, plugins, lifecycle hooks, and TypeScript-friendly patterns for developers building Node.js backends.
About
fastify is a Claude MPM skill that scaffolds high-performance Node.js APIs using the Fastify framework. The skill covers JSON-schema request and response validation, plugin registration, lifecycle hooks, and TypeScript-friendly server patterns so new routes start with consistent structure. Developers reach for fastify when replacing Express boilerplate, standing up typed REST or JSON APIs, or needing schema-driven validation without manual middleware chains. The workflow emphasizes Fastify idioms—route schemas, encapsulation contexts, and hook ordering—so generated servers remain maintainable as endpoints grow. Use it during greenfield API work or when refactoring legacy Node handlers into a schema-validated Fastify architecture.
- JSON-schema validation
- composable plugins
- lifecycle hooks
- performance-oriented routing
- TypeScript integration
Fastify by the numbers
- 442 all-time installs (skills.sh)
- Ranked #986 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 1, 2026 (Skillselion catalog sync)
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill fastifyAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 442 |
|---|---|
| repo stars | ★ 63 |
| Last updated | July 18, 2026 |
| Repository | bobmatnyc/claude-mpm-skills ↗ |
How do you scaffold a Fastify API with schema validation?
Scaffold high-performance Fastify APIs with JSON-schema validation, plugins, lifecycle hooks, and TypeScript-friendly server patterns.
Who is it for?
Node.js developers starting or refactoring HTTP APIs who want Fastify performance with schema validation and plugin-based architecture.
Skip if: Teams committed to Express-only stacks or GraphQL-first backends that will not adopt Fastify route and schema conventions.
When should I use this skill?
A new Node.js API needs Fastify scaffolding, JSON-schema validation, or TypeScript-friendly plugin and hook setup.
What you get
Fastify server entrypoint, route modules with JSON schemas, plugin wiring, and TypeScript-friendly handler structure.
- Fastify server scaffold
- Route modules with schemas
- Plugin and hook configuration
Files
Fastify (TypeScript) - Production Backend Framework
Overview
Fastify is a high-performance Node.js web framework built around JSON schema validation, encapsulated plugins, and great developer ergonomics. In TypeScript, pair Fastify with a type provider (Zod or TypeBox) to keep runtime validation and static types aligned.
Quick Start
Minimal server
✅ Correct: basic server with typed response
import Fastify from "fastify";
const app = Fastify({ logger: true });
app.get("/health", async () => ({ status: "ok" as const }));
await app.listen({ host: "0.0.0.0", port: 3000 });❌ Wrong: start server without awaiting listen
app.listen({ port: 3000 });
console.log("started"); // races startup and hides bind failuresSchema Validation + Type Providers
Fastify validates requests/responses via JSON schema. Use a type provider to avoid duplicating types.
Zod provider (recommended for full-stack TypeScript)
✅ Correct: Zod schema drives validation + types
import Fastify from "fastify";
import { z } from "zod";
import { ZodTypeProvider } from "fastify-type-provider-zod";
const app = Fastify({ logger: true }).withTypeProvider<ZodTypeProvider>();
const Query = z.object({ q: z.string().min(1) });
app.get(
"/search",
{ schema: { querystring: Query } },
async (req) => {
return { q: req.query.q };
},
);
await app.listen({ port: 3000 });TypeBox provider (recommended for OpenAPI + performance)
✅ Correct: TypeBox schema
import Fastify from "fastify";
import { Type } from "@sinclair/typebox";
import { TypeBoxTypeProvider } from "@fastify/type-provider-typebox";
const app = Fastify({ logger: true }).withTypeProvider<TypeBoxTypeProvider>();
const Params = Type.Object({ id: Type.String({ minLength: 1 }) });
const Reply = Type.Object({ id: Type.String() });
app.get(
"/users/:id",
{ schema: { params: Params, response: { 200: Reply } } },
async (req) => ({ id: req.params.id }),
);
await app.listen({ port: 3000 });Plugin Architecture (Encapsulation)
Use plugins to keep concerns isolated and testable (auth, db, routes).
✅ Correct: route plugin
import type { FastifyPluginAsync } from "fastify";
export const usersRoutes: FastifyPluginAsync = async (app) => {
app.get("/", async () => [{ id: "1" }]);
app.get("/:id", async (req) => ({ id: (req.params as any).id }));
};✅ Correct: register with a prefix
app.register(usersRoutes, { prefix: "/api/v1/users" });Error Handling
Centralize unexpected failures and return stable error shapes.
✅ Correct: setErrorHandler
app.setErrorHandler((err, req, reply) => {
req.log.error({ err }, "request failed");
reply.status(500).send({ error: "internal" as const });
});Security Hardening (Baseline)
Add standard security plugins and enforce payload limits.
✅ Correct: Helmet + CORS + rate limiting
import helmet from "@fastify/helmet";
import cors from "@fastify/cors";
import rateLimit from "@fastify/rate-limit";
await app.register(helmet);
await app.register(cors, { origin: false });
await app.register(rateLimit, { max: 100, timeWindow: "1 minute" });Graceful Shutdown
Close HTTP server and downstream clients (DB, queues) on SIGINT/SIGTERM.
✅ Correct: close on signals
const close = async (signal: string) => {
app.log.info({ signal }, "shutting down");
await app.close();
process.exit(0);
};
process.on("SIGINT", () => void close("SIGINT"));
process.on("SIGTERM", () => void close("SIGTERM"));Testing (Fastify inject)
Test routes in-memory without binding ports.
✅ Correct: inject request
import Fastify from "fastify";
import { describe, it, expect } from "vitest";
describe("health", () => {
it("returns ok", async () => {
const app = Fastify();
app.get("/health", async () => ({ status: "ok" as const }));
const res = await app.inject({ method: "GET", url: "/health" });
expect(res.statusCode).toBe(200);
expect(res.json()).toEqual({ status: "ok" });
});
});Decision Trees
Fastify vs Express
- Prefer Fastify for schema-based validation, predictable plugins, and high throughput.
- Prefer Express for minimal middleware and maximal ecosystem familiarity.
Zod vs TypeBox
- Prefer Zod for app codebases that already standardize on Zod (forms, tRPC, shared types).
- Prefer TypeBox for OpenAPI generation and performance-critical validation.
Anti-Patterns
- Skip request validation; validate at boundaries with schemas.
- Register everything in
main.ts; isolate routes and dependencies into plugins. - Return raw error objects; return stable error shapes and log the details.
Resources
- Fastify: https://www.fastify.io/
- fastify-type-provider-zod: https://github.com/turkerdev/fastify-type-provider-zod
- @fastify/type-provider-typebox: https://github.com/fastify/fastify-type-provider-typebox
{
"name": "fastify",
"version": "1.0.0",
"category": "toolchain",
"toolchain": "typescript",
"tags": [
"typescript",
"fastify",
"nodejs",
"backend",
"api",
"validation",
"json-schema",
"zod",
"typebox",
"security",
"testing"
],
"entry_point_tokens": 130,
"full_tokens": 1494,
"related_skills": [
"typescript-core",
"nodejs-backend",
"zod",
"vitest",
"api-design-patterns",
"docker"
],
"author": "Claude MPM Team",
"license": "MIT",
"requires": [],
"repository": "https://github.com/bobmatnyc/claude-mpm-skills",
"created": "2025-12-17",
"updated": "2025-12-17"
}
Related skills
FAQ
What does the fastify skill generate?
The fastify skill scaffolds Fastify HTTP APIs with JSON-schema validation, plugin registration, lifecycle hooks, and TypeScript-friendly server and route patterns for Node.js backends.
When should developers use the fastify skill?
Developers should use the fastify skill when starting a new Node.js API or refactoring handlers to Fastify with schema-driven validation, plugins, and consistent hook-based middleware.