nodejs-fastify
Use when the user asks about Fastify, Fastify plugins and encapsulation, JSON Schema or TypeBox route schemas, Fastify hooks, serializers or @fastify/swagger…
от j4flmao★ 47 звёзд на GitHub
Установить nodejs-fastify в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Node.js Fastify
Purpose
Build Fastify applications with schema-first validation, plugin encapsulation, request/response serialization, and lifecycle hooks.
Agent Protocol
Trigger
User request includes: fastify, fastify server, fastify plugin, fastify schema, fastify hooks, fastify validation, fastify serializer, TypeBox, @fastify/swagger.
Input Context
- Fastify version (4.x, 5.x)
- Validation approach (JSON Schema, TypeBox, Zod)
- Plugin set (swagger, cors, jwt, rate-limit)
- Database (TypeORM, Prisma, Knex)
Output Artifact
Server setup, plugin registration, schema definitions, hook pipeline, route patterns.
Response Format
Produce artifact directly. No preamble, no postamble, no explanations.
Completion Criteria
- Server created with logger and schema validator
- Plugins registered with encapsulation
- Routes defined with JSON Schema validation
- Hooks attached at correct lifecycle points
- Swagger/OpenAPI documentation configured
Max Response Length
4096 tokens
Architecture Decision Trees
Validation: JSON Schema vs TypeBox vs Zod
| Criterion | JSON Schema | TypeBox | Zod |
|---|---|---|---|
| Type inference | Manual | Static<typeof schema> |
z.infer<typeof schema> |
| Code-first | No | Yes | Yes |
| Composition | $ref |
Type.Union, Type.Intersect |
z.union, z.intersection |
| Performance | Fast native compilation | Fastest (TypeCode compiler) | Good |
| Ecosystem | Standard, swagger compatible | Fastify-native | Widely used |
Decision: Need OpenAPI/Swagger docs → JSON Schema or TypeBox. Want maximum type safety → TypeBox. Already using Zod in codebase → Zod.
Plugin vs Register Scope
| Scope | Encapsulation | Use Case |
|---|---|---|
| Root | Global | cors, rate-limiter, jwt, formbody |
| Plugin-level | Encapsulated within plugin | Feature modules, route groups |
| Child | Nested encapsulation | Sub-plugins within feature |
Decision: Infrastructure cross-cutting → Root. Feature-specific → Plugin. Shared helpers → fastify-plugin (bypass encapsulation).
Workflow
Step 1: Server Bootstrap
// src/server.ts
import Fastify from 'fastify';
import { registerPlugins } from './plugins';
import { config } from './config';
export async function buildServer() {
const server = Fastify({
logger: {
level: config.LOG_LEVEL,
transport: config.NODE_ENV === 'development'
? { target: 'pino-pretty' }
: undefined,
},
ajv: {
customOptions: { allErrors: true, coerceTypes: 'array' },
},
});
await registerPlugins(server);
// Health check
server.get('/health', async () => ({ status: 'ok', uptime: process.uptime() }));
return server;
}
// src/index.ts
import { buildServer } from './server';
async function main() {
const server = await buildServer();
const port = parseInt(process.env.PORT || '3000');
await server.listen({ port, host: '0.0.0.0' });
const shutdown = async (signal: string) => {
server.log.info(`${signal} received. Shutting down...`);
await server.close();
process.exit(0);
};
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT'));
}
main().catch(err => {
console.error('Fatal:', err);
process.exit(1);
});
Step 2: Plugin Registration
// src/plugins/index.ts
import { FastifyInstance } from 'fastify';
import fp from 'fastify-plugin';
import cors from '@fastify/cors';
import helmet from '@fastify/helmet';
import rateLimit from '@fastify/rate-limit';
import swagger from '@fastify/swagger';
import swaggerUi from '@fastify/swagger-ui';
import jwt from '@fastify/jwt';
import { userModule } from '../modules/users';
import { orderModule } from '../modules/orders';
import { errorHandlerPlugin } from './error-handler';
import { config } from '../config';
export async function registerPlugins(app: FastifyInstance) {
// Core plugins (global)
await app.register(cors, { origin: config.CORS_ORIGIN });
await app.register(helmet);
await app.register(rateLimit, { max: 100, timeWindow: '1 minute' });
await app.register(jwt, { secret: config.JWT_SECRET });
// Documentation
await app.register(swagger, {
openapi: { info: { title: 'API', version: '1.0.0' } },
});
await app.register(swaggerUi, { routePrefix: '/docs' });
// Error handler
await app.register(errorHandlerPlugin);
// Feature modules (encapsulated)
await app.register(userModule, { prefix: '/api/v1/users' });
await app.register(orderModule, { prefix: '/api/v1/orders' });
}
Step 3: Schema-First Routes with TypeBox
// src/modules/users/schema.ts
import { Type, Static } from '@sinclair/typebox';
export const CreateUserSchema = Type.Object({
name: Type.String({ minLength: 2, maxLength: 100 }),
email: Type.String({ format: 'email' }),
role: Type.Optional(Type.Union([Type.Literal('admin'), Type.Literal('u
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/fastify-advanced-plugins.md
- references/fastify-hooks.md
- references/fastify-plugins.md
- references/fastify-setup.md
- references/fastify-testing.md
- references/fastify-validation.md
FAQ
Что делает скилл nodejs-fastify?
Use when the user asks about Fastify, Fastify plugins and encapsulation, JSON Schema or TypeBox route schemas, Fastify hooks, serializers or @fastify/swagger. Produces Fastify 5 apps with schema-validated routes. Not for Express (use nodejs-express-skill).
Как установить скилл nodejs-fastify?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nodejs-fastify запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…