@mcollina/fastify

My own collection of skills for modern Node.js development

View in AI SkillSafe app
8267 downloads
0 stars
0 demos
SKILL.md
namefastify-best-practices
descriptionGuides 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.

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.mdroutes.mdschemas.md
  • Adding authentication: plugins.mdhooks.mdauthentication.md
  • Improving performance: schemas.mdserialization.mdperformance.md
  • Setting up testing: routes.mdtesting.md
  • Going to production: logging.mdconfiguration.mddeployment.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

Embed badges

Add these to your README to show the skill's verification status.

SkillSafe verified badge
Verified badge
[![SkillSafe verified badge](https://api.skillsafe.ai/v1/badge/@mcollina/fastify/verified)](https://skillsafe.ai/skill/@mcollina/fastify/)
Installs badge
Installs badge
[![Installs badge](https://api.skillsafe.ai/v1/badge/@mcollina/fastify/installs)](https://skillsafe.ai/skill/@mcollina/fastify/)
Scan badge
Scan badge
[![Scan badge](https://api.skillsafe.ai/v1/badge/@mcollina/fastify/scan)](https://skillsafe.ai/skill/@mcollina/fastify/)
Eval pass rate badge
Eval pass rate
[![Eval pass rate badge](https://api.skillsafe.ai/v1/badge/@mcollina/fastify/eval)](https://skillsafe.ai/skill/@mcollina/fastify/)