File contents 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
1 --- 2 name: fastify-best-practices 3 description: Quick Start 4 --- 5 6 ## Quick Start 7 8 A minimal, runnable Fastify server to get started immediately: 9 10 ```ts 11 import Fastify from 'fastify' 12 13 const app = Fastify({ logger: true }) 14 15 app.get('/health', async (request, reply) => { 16 return { status: 'ok' } 17 }) 18 19 const start = async () => { 20 await app.listen({ port: 3000, host: '0.0.0.0' }) 21 } 22 start() 23 ``` 24 25 ## Recommended Reading Order for Common Scenarios 26 27 - **New to Fastify?** Start with `plugins.md` → `routes.md` → `schemas.md` 28 - **Adding authentication:** `plugins.md` → `hooks.md` → `authentication.md` 29 - **Improving performance:** `schemas.md` → `serialization.md` → `performance.md` 30 - **Setting up testing:** `routes.md` → `testing.md` 31 - **Going to production:** `logging.md` → `configuration.md` → `deployment.md` 32 33 ## How to use 34 35 Read individual rule files for detailed explanations and code examples: 36 37 - [rules/plugins.md](rules/plugins.md) - Plugin development and encapsulation 38 - [rules/routes.md](rules/routes.md) - Route organization and handlers 39 - [rules/schemas.md](rules/schemas.md) - JSON Schema validation 40 - [rules/error-handling.md](rules/error-handling.md) - Error handling patterns 41 - [rules/hooks.md](rules/hooks.md) - Hooks and request lifecycle 42 - [rules/authentication.md](rules/authentication.md) - Authentication and authorization 43 - [rules/testing.md](rules/testing.md) - Testing with inject() 44 - [rules/performance.md](rules/performance.md) - Performance optimization 45 - [rules/logging.md](rules/logging.md) - Logging with Pino 46 - [rules/typescript.md](rules/typescript.md) - TypeScript integration 47 - [rules/decorators.md](rules/decorators.md) - Decorators and extensions 48 - [rules/content-type.md](rules/content-type.md) - Content type parsing 49 - [rules/serialization.md](rules/serialization.md) - Response serialization 50 - [rules/cors-security.md](rules/cors-security.md) - CORS and security headers 51 - [rules/websockets.md](rules/websockets.md) - WebSocket support 52 - [rules/database.md](rules/database.md) - Database integration patterns 53 - [rules/configuration.md](rules/configuration.md) - Application configuration 54 - [rules/deployment.md](rules/deployment.md) - Production deployment 55 - [rules/http-proxy.md](rules/http-proxy.md) - HTTP proxying and reply.from() 56 57 ## Core Principles 58 59 - **Encapsulation**: Fastify's plugin system provides automatic encapsulation 60 - **Schema-first**: Define schemas for validation and serialization 61 - **Performance**: Fastify is optimized for speed; use its features correctly 62 - **Async/await**: All handlers and hooks support async functions 63 - **Minimal dependencies**: Prefer Fastify's built-in features and official plugins
jgamaraalv/delivery-loop/tree/main/.claude/skills/fastify-best-practices commit 46f3bb72c3
Frequently asked questions How do I install the Fastify Best Practices skill? Run npx skillmds@latest add jgamaraalv/fastify-best-practices in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Fastify Best Practices skill do? Quick Start It is listed under Coding & Dev Tools, Integrations & APIs on SkillMD.
Is Fastify Best Practices safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Fastify Best Practices? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Fastify Best Practices free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Fastify Best Practices? jgamaraalv (@jgamaraalv) published this skill. Their other Agent Skills are listed on their SkillMD profile.