From jarvus-skills
Backend development using Fastify + TypeScript. Use when creating new backend APIs, adding routes, implementing services, working with plugins, or configuring environment variables.
npx claudepluginhub jarvusinnovations/agent-skills --plugin jarvus-skillsThis skill uses the workspace's default tool permissions.
High-performance Node.js backend stack:
Guides Fastify Node.js backend servers and REST APIs in TypeScript/JavaScript, covering routes, plugins, JSON Schema validation, hooks, authentication, performance, Pino logging, and deployment.
Creates Fastify plugins with step-by-step guidance, best practices, production-ready code, and configurations. Activates on 'fastify plugin creator' or similar phrases for backend tasks.
Guides Fastify development for high-performance Node.js APIs: routing, plugins, JSON Schema validation, hooks, serialization, error handling, and optimization.
Share bugs, ideas, or general feedback.
High-performance Node.js backend stack:
Use asdf to manage Node.js versions:
# Install Node.js plugin (one-time)
asdf plugin add nodejs
# Set project Node.js version
asdf set nodejs latest:22
This creates a .tool-versions file in the project root that ensures consistent Node.js versions across the team.
| File | When to Use |
|---|---|
| setup-guide.md | Starting a new backend project from scratch |
| patterns.md | Implementing routes, services, schema validation |
| authentication.md | Adding JWT auth, authorization, protected routes |
| api-design.md | Swagger/OpenAPI integration, response format, errors |
| mcp-integration.md | Integrating MCP server for AI agent access |
| gotchas.md | Debugging issues, common mistakes and fixes |
# Dev server with watch mode
npm run dev
# Build for production
npm run build
# Run production build
npm start
# Type check
npm run type-check
// Fastify types
import Fastify, { FastifyInstance, FastifyPluginAsync } from 'fastify'
import fp from 'fastify-plugin'
// Common plugins
import fastifyEnv from '@fastify/env'
import cors from '@fastify/cors'
Always access configuration through fastify.config, never process.env directly:
// CORRECT - type-safe, validated at startup
const port = fastify.config.PORT
const apiKey = fastify.config.API_KEY
// WRONG - no validation, no type safety
const port = process.env.PORT // Don't do this
// Standard response structure
{
success: boolean
data?: T
error?: string
metadata?: { timestamp: Date }
}
import fp from 'fastify-plugin'
export default fp(async (fastify, opts) => {
// Plugin logic here
fastify.decorate('something', value)
}, '5.x')
import { FastifyPluginAsync } from 'fastify'
const routes: FastifyPluginAsync = async (fastify, opts) => {
fastify.get('/', async (request, reply) => {
return { success: true, data: 'example' }
})
}
export default routes
// 1. Create service class
export class MyService {
constructor(private fastify: FastifyInstance) {}
async doWork() {
// Access config through fastify instance
const apiKey = this.fastify.config.API_KEY
this.fastify.log.info('Service method called')
}
}
// 2. Declare module augmentation
declare module 'fastify' {
interface FastifyInstance {
myService: MyService
}
}
// 3. Initialize and decorate in app.ts
fastify.decorate('myService', new MyService(fastify))
backend/
├── src/
│ ├── plugins/ # Fastify plugins (env, auth, etc.)
│ ├── routes/ # HTTP route handlers
│ ├── services/ # Business logic classes
│ ├── utils/ # Shared utilities
│ ├── app.ts # Plugin registration & setup
│ └── index.ts # Server entry point
├── package.json
├── tsconfig.json
├── .env.example
└── .gitignore
fastify.config.VAR not process.env.VARawait server.ready() before accessing config in index.tsnpm install <pkg> not manual package.json edits