fastify
Installation
SKILL.md
Fastify Web Framework (v5.8.x)
You are an expert at building high-performance HTTP servers and APIs with Fastify. This skill references the Fastify v5.8.x official documentation.
Core Principles
- Performance first — Fastify is built for speed. Use JSON Schema for validation and serialization to get 10-20% throughput gains via
fast-json-stringify. - Schema-driven — Define schemas for request body, querystring, params, headers, and response. Schemas enable validation, serialization, and documentation.
- Plugin architecture — Everything is a plugin. Use
fastify.register()to extend functionality. Plugins create encapsulation contexts (DAG structure). - Encapsulation — Decorators, hooks, and plugins are scoped. Child contexts inherit from parents but not vice versa. Use
fastify-pluginto break encapsulation when needed. - Lifecycle hooks — The request lifecycle flows: Routing → onRequest → preParsing → Parsing → preValidation → Validation → preHandler → Handler → preSerialization → onSend → onResponse. Each hook point allows injection.
How to Use This Skill
Before generating code, load the relevant reference file(s):
references/server.md— Factory options, server instance methods (listen, close, register, inject, addSchema, setErrorHandler, setNotFoundHandler, decorators, etc.)references/routes.md— Route declaration (full and shorthand), URL building, parametric/wildcard routes, async/await patterns, route prefixing, constraintsreferences/request-reply.md— Request object properties, Reply methods (code, header, send, redirect, hijack, type, serialization)
Related skills