Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

fastify-best-practices — Claude Code skill: setup and guide

Guides AI assistants in building Fastify backend servers with TypeScript or JavaScript. It covers plugin encapsulation, schemas, logging, and deployment patterns.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mcollina/skills --skill fastify-best-practices -a claude-code
npx skills add mcollina/skills --skill fastify -a claude-code
Open on GitHub

What fastify-best-practices does

This skill equips your coding agent with architectural guidelines for Fastify REST APIs in JavaScript and TypeScript. It walks through the complete request lifecycle, including hooks, content-type parsing, response serialization, and structured logging via Pino. Route testing relies on Fastify's native inject() method without opening network ports.

The knowledge base breaks down into individual rule files for schemas, error handling, authentication, WebSockets, and HTTP proxying via reply.from(). It enforces a schema-first mindset, requiring JSON Schema definitions for request validation and response output. Because of this focus on strict encapsulation, handlers that bypass plugin scopes or omit schema definitions will be flagged for restructuring.

TypeScript integration assumes the strip types approach. Recommended reading paths help organize complex projects from initial setup to production monitoring.

What it helps with

  • structure modular Fastify plugins with strict encapsulation
  • validate incoming requests and serialize responses using JSON Schema
  • test endpoints without opening network sockets using inject()
  • configure structured logging with Pino and custom error handlers

Example prompts for the agent

  • Create a Fastify auth plugin that validates tokens in an onRequest hook
  • Define a JSON Schema for validating POST request bodies on `/api/items`
  • Write a test suite for the `/health` route using Fastify's inject method

How to install fastify-best-practices

1Skills CLI (Vercel)

npx skills add mcollina/skills --skill fastify-best-practices -a claude-code
npx skills add mcollina/skills --skill fastify -a claude-code

2Manually: put the files in place

~/.claude/skills/fastify/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/fastify/

Similar

gemini-interactions-api official google This skill guides Gemini Interactions API usage on Gemini Enterprise Agent Platform for stateful chats, background tasks, streaming, and function calling. Claude Code Gemini CLI CX Codex 10,434installs nextjs-app-router-patterns Seth Hobson This skill covers Next.js App Router patterns for rendering, routing, and data fetching. Use it when starting an App Router project or moving from Pages Router. Claude Code CX Codex Cursor 32,529installs typescript-mcp-server-generator official github Generates a TypeScript MCP server project with tools, resources, and configuration. Use it when a new server should start on the MCP TypeScript SDK v2. GitHub Copilot 12,050installs voicestudio debpalash Connects an agent to VoiceStudio for speech generation, audio transcription, and dubbing workflows through its REST API or MCP server. Claude Code CX Codex Cursor +1 1,700installs architecture official anthropics Writes an Architecture Decision Record or reviews a system design: options, trade-offs, consequences. Useful when you have to pick between technologies. Claude Code CX Codex Cursor +1 6,700installs sandbox-stable cloudflare This skill helps build and maintain Cloudflare Sandbox apps on the stable @cloudflare/sandbox package. Use it when Workers need isolated Linux environments. Claude Code CX Codex Cursor +1 67,600installs mcp-builder official anthropics This skill walks through building an MCP server in TypeScript or Python, from reading the protocol spec to writing tests and evaluation questions. Claude Code Claude.ai 130,949installs google-agents-cli-adk-code official Google A reference skill for building ADK agents with tools, callbacks, state, and workflows. Use it when an agent project needs concrete API patterns or code examples. Claude Code CX Codex Cursor +1 511,400installs

Questions about fastify-best-practices

How do I install fastify-best-practices in Claude Code?

Run npx skills add mcollina/skills --skill fastify-best-practices -a claude-code in your terminal.

What does fastify-best-practices do?

It instructs the agent on proper Fastify architecture, covering plugin encapsulation, hooks, schemas, database integrations, and Pino logging.

How does the skill handle endpoint testing?

The skill directs the assistant to use Fastify's built-in inject() method. This runs simulated HTTP requests directly against the app instance without binding to a network port.

Source text

SKILL.md · MIT
---
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:

```ts
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()
```

## Recommended Reading Order for Common Scenarios

- **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

© mcollina · MIT · mcollina/skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor