Skip to content
Fastify Best Practices

Fastify Best Practices Skill

Matteo Collina's Fastify skill: a minimal server plus 19 rule files on plugins, routes, JSON Schema, hooks, auth, testing with inject(), Pino logging, TypeScript and deployment.

GitHub Docs

Install

Install with the skills CLI

One command for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf and dozens of other agents. Needs Node.js; the skill is fetched straight from mcollina/skills.

$ npx skills add mcollina/skills --skill fastify-best-practices

Run it in a terminal. The CLI finds the agents installed on your machine, asks which ones to add the skill to, and whether to install it into the folder you ran it from or for all your projects.

Other ways to install

  1. Open the skill on GitHub and download the folder that holds its SKILL.md.
  2. Put it at ~/.claude/skills/fastify-best-practices/, where Claude Code picks it up in every project.

No scripts or references next to it? Saving the SKILL.md alone as ~/.claude/skills/fastify-best-practices/SKILL.md works too.

Using another agent? Its personal skills folder
Codex
~/.agents/skills/
Cursor
~/.cursor/skills/
GitHub Copilot
~/.copilot/skills/
Gemini CLI
~/.gemini/skills/
Windsurf
~/.codeium/windsurf/skills/
OpenCode
~/.config/opencode/skills/

About

  • Written by Fastify lead maintainer Matteo Collina
  • Runnable minimal Fastify server to start from
  • 19 rule files loaded on demand, from plugins to deployment
  • Schema-first validation and serialisation with JSON Schema
  • Testing with Fastify's inject() and TypeScript via type stripping
  • Covers Pino logging, CORS and security headers, WebSockets and reply.from() proxying

Fastify Best Practices is an agent skill for building Fastify back ends in Node.js, written by Matteo Collina, Fastify's lead maintainer, and published in his mcollina/skills collection. It is for developers who use a coding agent to write or debug Fastify servers and REST APIs in TypeScript or JavaScript.

The SKILL.md itself is short: a runnable minimal server, recommended reading orders for common jobs (getting started, adding authentication, improving performance, setting up tests, going to production) and five core principles: plugin encapsulation, schema-first validation and serialisation, using Fastify's performance features correctly, async/await everywhere, and preferring built-in features and official plugins over extra dependencies.

The depth is in 19 rule files the agent loads as needed: plugins, routes, JSON Schema validation, error handling, hooks and the request lifecycle, authentication, testing with inject(), performance, Pino logging, TypeScript via type stripping, decorators, content-type parsing, response serialisation, CORS and security headers, WebSockets, database integration, configuration, production deployment and HTTP proxying with reply.from().

Its value is that the guidance comes from the framework's maintainer rather than generic Express-era habits. MIT licensed.

SKILL.md

The instructions your agent loads, as published by Matteo Collina.

SKILL.md
name
fastify-best-practices
description
Guides development of Fastify Node.js backend servers and REST APIs using TypeScript or JavaScript. Use when building, configuring, or debugging a Fastify application — including defining routes, implementing plugins, setting up JSON Schema validation, handling errors, optimising performance, managing authentication, configuring CORS and security headers, integrating databases, working with WebSockets, and deploying to production. Covers the full Fastify request lifecycle (hooks, serialization, logging with Pino) and TypeScript integration via strip types. Trigger terms: Fastify, Node.js server, REST API, API routes, backend framework, fastify.config, server.ts, app.ts.
metadata
tags: fastify, nodejs, typescript, backend, api, server, http
When to use

Use this skill when you need to:

  • Develop backend applications using Fastify
  • Implement Fastify plugins and route handlers
  • Get guidance on Fastify architecture and patterns
  • Use TypeScript with Fastify (strip types)
  • Implement testing with Fastify's inject method
  • Configure validation, serialization, and error handling
Quick Start

A minimal, runnable Fastify server to get started immediately:

import Fastify from 'fastify'

const app = Fastify({ logger: true })

app.get('/health', async (request, reply) => {
  return { status: 'ok' }
})

const start = async () => {
  await app.listen({ port: 3000, host: '0.0.0.0' })
}
start()
  • New to Fastify? Start with plugins.md → routes.md → schemas.md
  • Adding authentication: plugins.md → hooks.md → authentication.md
  • Improving performance: schemas.md → serialization.md → performance.md
  • Setting up testing: routes.md → testing.md
  • Going to production: logging.md → configuration.md → deployment.md
How to use

Read individual rule files for detailed explanations and code examples:

  • [rules/plugins.md](rules/plugins.md) - Plugin development and encapsulation
  • [rules/routes.md](rules/routes.md) - Route organization and handlers
  • [rules/schemas.md](rules/schemas.md) - JSON Schema validation
  • [rules/error-handling.md](rules/error-handling.md) - Error handling patterns
  • [rules/hooks.md](rules/hooks.md) - Hooks and request lifecycle
  • [rules/authentication.md](rules/authentication.md) - Authentication and authorization
  • [rules/testing.md](rules/testing.md) - Testing with inject()
  • [rules/performance.md](rules/performance.md) - Performance optimization
  • [rules/logging.md](rules/logging.md) - Logging with Pino
  • [rules/typescript.md](rules/typescript.md) - TypeScript integration
  • [rules/decorators.md](rules/decorators.md) - Decorators and extensions
  • [rules/content-type.md](rules/content-type.md) - Content type parsing
  • [rules/serialization.md](rules/serialization.md) - Response serialization
  • [rules/cors-security.md](rules/cors-security.md) - CORS and security headers
  • [rules/websockets.md](rules/websockets.md) - WebSocket support
  • [rules/database.md](rules/database.md) - Database integration patterns
  • [rules/configuration.md](rules/configuration.md) - Application configuration
  • [rules/deployment.md](rules/deployment.md) - Production deployment
  • [rules/http-proxy.md](rules/http-proxy.md) - HTTP proxying and reply.from()
Core Principles
  • Encapsulation: Fastify's plugin system provides automatic encapsulation
  • Schema-first: Define schemas for validation and serialization
  • Performance: Fastify is optimized for speed; use its features correctly
  • Async/await: All handlers and hooks support async functions
  • Minimal dependencies: Prefer Fastify's built-in features and official plugins
Install

Skill: Genkit for JavaScript

by Genkit (Google)

Featured

The official Genkit skill for Node.js and TypeScript — flows, Dotprompt files, tools and the beta agent API with sessions, interrupts and branching.

76 views

Skill: Convex

by Convex

Featured

Convex's official top-level agent skill — routes an agent to the right convex-* skill for the task and to a served capability catalogue that stays current without a reinstall.

New

Convex's official skill for turning a one-sentence app idea into a running Next.js + Convex template with an anonymous dev deployment, plus strict rules for writing Convex functions that compile and push first time.

Browse all skills →