| name | fastify |
| description | Production Fastify (TypeScript) patterns: schema validation, plugins, typed routes, error handling, security hardening, logging, testing with inject, and graceful shutdown |
| user-invocable | false |
| disable-model-invocation | true |
| version | 1.0.0 |
| category | toolchain |
| author | Claude MPM Team |
| license | MIT |
| progressive_disclosure | {"entry_point":{"summary":"Build fast, type-safe Node APIs with Fastify using schema-first validation, plugin encapsulation, and production middleware patterns","when_to_use":"When building TypeScript backends needing high performance, schema-based validation, clean plugin composition, and strong testability","quick_start":"1. Create Fastify instance 2. Add Type Provider (Zod/TypeBox) 3. Register plugins (CORS/Helmet) 4. Add error handler + logging 5. Test with inject()"},"token_estimate":{"entry":130,"full":5200}} |
| context_limit | 900 |
| tags | ["typescript","fastify","nodejs","api","validation","json-schema","security","testing"] |
| requires_tools | [] |
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");
Schema 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";
{ } ;
app = ({ : }).<>();
= z.({ : z.().() });
app.(
,
{ : { : } },
(req) => {
{ : req.. };
},
);
app.({ : });