skills/nodejs-skills/fastify/SKILL.md
Provides comprehensive guidance for Fastify framework including routing, plugins, JSON schema validation, hooks, serialization, and performance optimization. Use when the user asks about Fastify, needs to create high-performance Node.js applications, implement plugins, or optimize API performance.
npx skillsauth add teachingai/agent-skills fastifyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill whenever the user wants to:
fastify.inject() for testing, deploy with process managerconst fastify = require('fastify')({ logger: true });
// Register plugins
fastify.register(require('@fastify/cors'));
fastify.register(require('@fastify/helmet'));
// Route with JSON Schema validation
fastify.post('/api/items', {
schema: {
body: {
type: 'object',
required: ['name', 'price'],
properties: {
name: { type: 'string', minLength: 1 },
price: { type: 'number', minimum: 0 },
},
},
response: {
201: {
type: 'object',
properties: {
id: { type: 'integer' },
name: { type: 'string' },
price: { type: 'number' },
},
},
},
},
handler: async (request, reply) => {
const item = await createItem(request.body);
reply.code(201).send(item);
},
});
fastify.get('/api/items/:id', async (request, reply) => {
const item = await getItem(request.params.id);
if (!item) {
reply.code(404).send({ error: 'Not found' });
return;
}
return item;
});
fastify.listen({ port: 3000, host: '0.0.0.0' });
// plugins/db.js
async function dbPlugin(fastify, options) {
const pool = createPool(options.connectionString);
fastify.decorate('db', pool);
fastify.addHook('onClose', async () => pool.end());
}
module.exports = require('fastify-plugin')(dbPlugin);
// app.js
fastify.register(require('./plugins/db'), {
connectionString: process.env.DATABASE_URL,
});
fastify.setErrorHandler((error, request, reply) => {
request.log.error(error);
const statusCode = error.statusCode || 500;
reply.code(statusCode).send({
error: error.message,
statusCode,
});
});
fastify-plugin to break encapsulation when sharing decorators across scopesconsole.log in productiononRequest, preHandler) for cross-cutting concernsfastify.inject() without starting a serverfastify, Node.js, high performance, JSON schema, plugins, serialization, hooks, Pino logger
development
Guidance for Next.js using the official docs at nextjs.org/docs. Use when the user needs Next.js concepts, configuration, routing, data fetching, or API reference details.
tools
Provides comprehensive guidance for Flask framework including routing, templates, forms, database integration, extensions, and deployment. Use when the user asks about Flask, needs to create web applications, implement routes, or build Python web services.
development
Provides comprehensive guidance for FastAPI framework including routing, request validation, dependency injection, async operations, OpenAPI documentation, and database integration. Use when the user asks about FastAPI, needs to create REST APIs, or build high-performance Python web services.
development
Provides comprehensive guidance for Django framework including models, views, templates, forms, admin, REST framework, and deployment. Use when the user asks about Django, needs to create web applications, implement models and views, or build Django REST APIs.