.cursor/skills/fastify-v5/SKILL.md
TypeBox schemas with Fastify routes for type-safe API development. Native JSON Schema, automatic OpenAPI generation. Use when: building Fastify REST APIs with schema validation and OpenAPI generation.
npx skillsauth add blockmatic-icebox/basilic-old TypeBox + 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.
@fastify/type-provider-typebox for TypeBox type provider@sinclair/typebox for schema definitionsTypeBoxTypeProvider for automatic type inference from schemas@fastify/swagger)request.params, request.query, request.body) are inferred from schemasTypeBoxTypeProvider for type safety: fastify.withTypeProvider<TypeBoxTypeProvider>()Type.* constructors for schema definitionsoperationId in route schemas for OpenAPI generationtags for route organization in OpenAPI docsimport { Type } from '@sinclair/typebox'
import type { FastifyPluginAsync } from 'fastify'
const UserSchema = Type.Object({
id: Type.String(),
email: Type.String({ format: 'email' }),
name: Type.String(),
})
const userRoutes: FastifyPluginAsync = async fastify => {
fastify.get('/users/:id', {
schema: {
operationId: 'getUser',
params: Type.Object({ id: Type.String() }),
response: {
200: UserSchema,
404: Type.Object({ code: Type.String(), message: Type.String() }),
},
},
}, async (request, reply) => {
// request.params.id is typed
const { id } = request.params
return reply.send(user)
})
}
Type.String()
Type.Number()
Type.Boolean()
Type.Object({ id: Type.String() })
Type.Array(Type.String())
Type.Optional(Type.String())
Type.Union([Type.String(), Type.Number()])
See Route Schema Template for complete example.
Configure Fastify instance with TypeBox type provider, logger, and request settings:
import type { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
import Fastify from 'fastify'
const fastify = Fastify({
logger: {
level: 'info',
transport: process.env.NODE_ENV === 'development' ? {
target: 'pino-pretty',
} : undefined,
},
trustProxy: true,
bodyLimit: 1048576, // 1MB
requestTimeout: 30000,
requestIdHeader: 'x-request-id',
requestIdLogLabel: 'reqId',
}).withTypeProvider<TypeBoxTypeProvider>()
See Instance Configuration for complete setup.
Create reusable plugins with fastify-plugin for non-encapsulated behavior:
import type { FastifyPluginAsync } from 'fastify'
import fp from 'fastify-plugin'
const myPlugin: FastifyPluginAsync = async fastify => {
// Plugin logic
}
export default fp(myPlugin, {
name: 'my-plugin',
})
See Plugin Patterns and Plugin Template for examples.
Use hooks to intercept requests, modify responses, or handle errors:
fastify.addHook('onRequest', async (request, reply) => {
// Add security headers, logging, etc.
})
fastify.addHook('onResponse', async (request, reply) => {
// Modify response, add headers, etc.
})
fastify.addHook('onError', async (request, reply, error) => {
// Handle errors
})
See Hooks Guide and Hook Plugin Template for patterns.
Test routes using Fastify's inject() method for blackbox testing:
const response = await fastify.inject({
method: 'GET',
url: '/users/123',
})
expect(response.statusCode).toBe(200)
const data = JSON.parse(response.body)
See Testing Patterns and Test Utils Template for setup.
Handle streaming responses (e.g., Server-Sent Events, text streams):
fastify.post('/stream', {
schema: {
response: {
200: Type.String({ description: 'Streaming response' }),
},
},
}, async (request, reply) => {
reply.header('Content-Type', 'text/event-stream')
reply.header('Cache-Control', 'no-cache')
return reply.send(stream)
})
import rateLimit from '@fastify/rate-limit'
await fastify.register(rateLimit, {
max: 100,
timeWindow: 60000,
keyGenerator: request => request.ip,
})
import cors from '@fastify/cors'
await fastify.register(cors, {
origin: (origin, callback) => {
// Validate origin
callback(null, true)
},
credentials: false,
})
fastify.setErrorHandler((error, request, reply) => {
// Global error handling
reply.status(error.statusCode ?? 500).send({
code: 'ERROR',
message: error.message,
})
})
Handle process signals for graceful shutdown:
const shutdown = async (signal: string) => {
fastify.log.info({ signal }, 'Shutting down')
await fastify.close()
process.exit(0)
}
process.on('SIGTERM', () => shutdown('SIGTERM'))
process.on('SIGINT', () => shutdown('SIGINT'))
Use @fastify/autoload for automatic plugin/route discovery:
import AutoLoad from '@fastify/autoload'
await fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
forceESM: true,
})
development
# Skill: wagmi ## Scope - React/Next.js wallet integration with Wagmi v3 for EVM chains - Contract interactions using viem v2 for address validation and transaction building - Transaction state management and error handling - Custom hooks wrapping wagmi for contract-specific interactions Does NOT cover: - Solana frontend development - Backend RPC interactions - Smart contract development ## Assumptions - Wagmi v3.3.2+ - viem v2.44.4 - React 18+ or Next.js 14+ - TypeScript v5+ with strict mo
development
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
development
Advanced TypeScript patterns for type-safe, maintainable code using sophisticated type system features. Use when building type-safe APIs, implementing complex domain models, or leveraging TypeScript's advanced type capabilities.
development
TanStack Query (React Query) for async operations, data fetching, caching, and state management. Use when: fetching server data, managing async operations, caching responses, handling mutations, or any operation that benefits from automatic state management and caching.