mcpField
F
fastify-best-practices

fastify-best-practices

github.com/mcollinaDevelopment2.0k84.8k installsUpdated 1w ago
Repository

About fastify-best-practices

A Fastify development skill for backend developers, with focused guidance on plugins, routes, schemas, testing, and production practices.

Key features

  1. 01Plugin and route design
  2. 02Schema validation and serialization
  3. 03Error handling and request hooks
  4. 04Authentication and security patterns
  5. 05Testing with inject()
  6. 06Performance and deployment guidance

Use cases

  1. 01Structuring a Fastify backend
  2. 02Adding schema-based request validation
  3. 03Testing routes with inject()
  4. 04Preparing a Fastify service for production

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mcollina/skills --skill fastify-best-practices

After installing, type/fastify-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

tile.json
rules/
authentication.md
configuration.md
content-type.md
cors-security.md
database.md
decorators.md
deployment.md
error-handling.md
hooks.md
http-proxy.md
logging.md
performance.md
plugins.md
routes.md
schemas.md
serialization.md
testing.md
typescript.md
websockets.md

Details

From the project README

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

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:

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

Comments

Markdown supported