
Fastify Best Practices
FreeStreamline your Fastify backend development process.
Free · Opens the source repo
What Fastify Best Practices does
Fastify Best Practices is a skill designed for developers working with Fastify, a fast and low-overhead web framework for Node.js. This skill provides comprehensive guidelines and best practices for building, configuring, and debugging Fastify applications, whether you are using TypeScript or JavaScript. It covers essential topics such as defining routes, implementing plugins, setting up JSON Schema validation, handling errors, optimizing performance, and managing authentication. With this skill, developers can ensure that their applications adhere to industry standards and leverage the full capabilities of Fastify.
The skill includes a structured approach to Fastify development, guiding users through the Fastify request lifecycle, which encompasses hooks, serialization, and logging with Pino. Each section is organized into specific rule files that provide detailed explanations and code examples, making it easy to find the information you need. Whether you are a newcomer to Fastify or looking to refine your existing knowledge, the recommended reading order helps you navigate through common scenarios effectively.
This skill is particularly useful for teams and individual developers who want to maintain high-quality code and efficient workflows while developing backend applications. By following the best practices outlined in this skill, users can avoid common pitfalls and streamline their development process, ultimately leading to more robust and maintainable applications. Fastify Best Practices is an essential resource for anyone looking to enhance their Fastify development skills and ensure their applications are built on a solid foundation.
When to use it
Use this skill when developing backend applications with Fastify, especially when you need to implement plugins, define routes, or configure validation and error handling.
When not to use it
This skill may not be suitable for developers looking for a general-purpose Node.js framework or those who are not specifically working with Fastify.
What you can build with it
Starting a New Fastify Project
Use this skill to set up your Fastify project by following the recommended reading order for plugins and routes.
Implementing Authentication
Leverage the guidelines in this skill to add authentication to your Fastify application efficiently.
Optimizing Application Performance
Utilize the performance optimization strategies outlined in this skill to enhance your Fastify application's speed.
How to install Fastify Best Practices
View source1. Install with the skills CLI
npx skills add mcollina/skills/fastify --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by mcollinaWhen 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:
- rules/plugins.md - Plugin development and encapsulation
- rules/routes.md - Route organization and handlers
- rules/schemas.md - JSON Schema validation
- rules/error-handling.md - Error handling patterns
- rules/hooks.md - Hooks and request lifecycle
- rules/authentication.md - Authentication and authorization
- rules/testing.md - Testing with inject()
- rules/performance.md - Performance optimization
- rules/logging.md - Logging with Pino
- rules/typescript.md - TypeScript integration
- rules/decorators.md - Decorators and extensions
- rules/content-type.md - Content type parsing
- rules/serialization.md - Response serialization
- rules/cors-security.md - CORS and security headers
- rules/websockets.md - WebSocket support
- rules/database.md - Database integration patterns
- rules/configuration.md - Application configuration
- rules/deployment.md - Production deployment
- 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
Frequently asked questions about Fastify Best Practices
Similar skills
Python PyPI Package Builder
Streamline the process of creating and publishing Python packages.
Minecraft Plugin Development
Streamline your Minecraft server plugin creation.
MCP Server Builder
Easily build .NET MCP servers with the latest standards.
CommunityToolkit.Mvvm Messenger
Decoupled communication for ViewModels in .NET applications.
MVVM Toolkit DI
Streamline ViewModel integration with Dependency Injection in .NET.
MCP Apps Builder
Essential guidelines for MCP server development.
