express-to-fastify-migration
БесплатноЗапускает вложенные скриптыНе проверенMigrate Express.js REST APIs to Fastify with automated testing, performance benchmarking, and schema generation. Use when migrating Express applications to…
Об этом скилле
Express to Fastify Migration
MANDATORY WORKFLOW
You MUST complete each phase IN ORDER. Do NOT proceed to the next phase until the current phase is complete. Report your progress after each phase.
Phase 1: Assessment & Baseline Capture (REQUIRED before any code changes)
Before writing ANY code, you MUST:
1.1 Document the existing codebase:
- Routes: List ALL Express routes in the codebase (method, path, handler)
- Middleware: List ALL middleware (global and route-specific)
- Dependencies: List ALL Express-related dependencies from package.json
- Custom patterns: Note any authentication, error handling, or custom middleware
1.2 Capture Express API responses (CRITICAL):
You MUST save the actual API responses BEFORE making any code changes. These are required to verify output compatibility in Phase 6.
For EACH endpoint identified in 1.1, capture the response:
# Example: save responses to files for later comparison
curl -s "http://localhost:PORT/endpoint" | jq . > /tmp/express_endpoint.json
curl -s "http://localhost:PORT/endpoint?query=test" | jq . > /tmp/express_endpoint_query.json
Save responses for:
- Success cases (200 responses)
- Error cases (400/404 responses)
- Response headers (especially Cache-Control, Content-Type)
1.3 Capture Express baseline performance (CRITICAL):
You MUST benchmark the Express server BEFORE making any code changes. This baseline is required for performance comparison in Phase 6.
- Install autocannon:
npm install autocannon --save-dev - Start the Express server
- Run benchmarks on key endpoints and record the results:
npx autocannon -c 10 -d 10 http://localhost:PORT/endpoint
- Save these metrics - you will compare against them in Phase 6:
- Requests/second
- Average latency
- Throughput (bytes/sec)
STOP: You MUST report your assessment findings, saved API responses, AND Express baseline metrics before proceeding to Phase 2.
Phase 2: Dependencies
Install Fastify and equivalents for EACH Express plugin identified in Phase 1.
REQUIRED plugins (ALWAYS install these):
fastify- Core framework@fastify/helmet- Security headers (REQUIRED)@fastify/rate-limit- Rate limiting (REQUIRED)
Conditional plugins (install if Express equivalent was used):
compression→@fastify/compresscors→@fastify/corscookie-parser→@fastify/cookieexpress-session→@fastify/sessionbody-parser→ Built-in (no plugin needed)
IMPORTANT: Do NOT uninstall Express yet!
Keep Express installed until Phase 6 (Performance Verification) is complete. This allows you to run both servers simultaneously for benchmarking comparison.
STOP: Confirm all Fastify dependencies installed before Phase 3. Express stays installed for now.
Phase 3: Route Migration
For EACH route identified in Phase 1, you MUST:
Convert syntax using these patterns:
app.get()→fastify.get()req/res→request/replyres.json(data)→return datares.status(code).json(data)→reply.code(code); return datares.header()→reply.header()
Add JSON schema for validation (REQUIRED for every route):
fastify.get('/example', {
schema: {
querystring: {
type: 'object',
properties: {
query: { type: 'string' }
}
},
response: {
200: {
type: 'object',
properties: {
data: { type: 'array' }
}
}
}
}
}, async (request, reply) => {
// handler
});
- Convert middleware to hooks:
- Global middleware →
fastify.addHook('onRequest', ...) - Route middleware →
preHandleroption - Error middleware →
fastify.setErrorHandler(...)
- Global middleware →
Consult references/migration_patterns.md for detailed examples.
STOP: Confirm all routes migrated with schemas before Phase 4.
Phase 4: Server Setup
Update the server entry point:
- Configure Fastify with logging:
const app = Fastify({ logger: true });
- Register REQUIRED security plugins:
app.register(helmet);
app.register(rateLimit, { max: 100, timeWindow: '1 minute' });
- Register error handler:
app.setErrorHandler((error, request, reply) => {
request.log.error(error);
reply.status(error.statusCode || 500).send({ error: error.message });
});
- Update server startup to use Fastify's listen():
await app.listen({ port: PORT, host: '0.0.0.0' });
STOP: Confirm server setup complete before Phase 5.
Phase 5: Validation (REQUIRED before completion)
You MUST complete ALL of these checks:
Build & Test
- Run
npm run build- MUST succeed with no errors - Run
npm test- ALL tests MUST pass - Run linting - MUST pass or only have unrelated warnings
Code Quality Verification
- ALL routes have JSON schemas
- Security plugins registered (`@fastify/helmet
Установить express-to-fastify-migration в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл express-to-fastify-migration?
Migrate Express.js REST APIs to Fastify with automated testing, performance benchmarking, and schema generation. Use when migrating Express applications to Fastify, modernizing Node.js APIs, improving API performance, or when users mention Express to Fastify migration, Fastify conversion, API modernization, or performance optimization of Express apps.
Как установить скилл express-to-fastify-migration?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл express-to-fastify-migration запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic