Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
ilteoood avatar

Fastify Best Practices

  • 221 installs
  • 2 repo stars
  • Updated July 24, 2026
  • ilteoood/harness

This is a copy of fastify-best-practices by mcollina - installs and ranking accrue to the original listing.

fastify-best-practices is an agent skill that implements Fastify JWT authentication and protected-route patterns.

About

fastify-best-practices (packaged in harness under an authentication-focused SKILL frontmatter) gives indie API builders concrete Fastify patterns for JWT auth, protected routes, and refresh-token flows. Instead of stitching Stack Overflow snippets, you get TypeScript-oriented register/decorate examples, schema-validated login bodies, and onRequest guards suitable for a first production slice. The skill fits Prism’s Build → backend shelf but honestly supports Ship → security when you harden access control before launch. Use it when you are standing up `/login`, issuing signed claims (id, email, role), and gating `/profile`-style routes—not when you need a full IdP product comparison. OAuth and session topics appear in metadata; the excerpt emphasizes JWT as the primary path. Pair with your own secret management and rate limiting; the skill teaches structure, not compliance certification. Agents on Claude Code or Cursor can drop these patterns into an existing Fastify app register graph quickly.

  • @fastify/jwt registration with sign options and request.jwtVerify guard
  • authenticate onRequest hook pattern for protected routes
  • JSON schema validation on login body (email + password)
  • Refresh token flow patterns beyond access-token sign
  • Metadata tags: auth, jwt, session, oauth, security, authorization

Fastify Best Practices by the numbers

  • 221 all-time installs (skills.sh)
  • +30 installs in the week ending Jul 25, 2026 (Skillselion tracking)
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 25, 2026 (Skillselion catalog sync)
npx skills add https://github.com/ilteoood/harness --skill fastify-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs221
repo stars2
Security audit3 / 3 scanners passed
Last updatedJuly 24, 2026
Repositoryilteoood/harness

What it does

Implement Fastify JWT login, route protection, and refresh-token patterns with copy-paste-ready TypeScript examples.

Who is it for?

Best when you're creating TypeScript Fastify APIs and want JWT auth scaffolding before adding business routes.

Skip if: Greenfield teams choosing auth providers (Auth0, Clerk) with no self-hosted JWT, or non-Node HTTP frameworks.

When should I use this skill?

User asks for Fastify authentication, JWT, authorization, session, or OAuth patterns on a Node API.

What you get

Your Fastify app gains documented register/decorate auth hooks, schema-validated login, and protected route examples—then you add secrets handling and refresh-token storage in your own code.

  • JWT plugin registration and authenticate decorator
  • Login and protected route handler examples with JSON schema

Files

SKILL.mdMarkdownGitHub ↗

When to use

Use this skill when you need to:

  • Develop backend applications using Fastify
  • Implement Fastify plugins and route handlers
  • Get guidance on Fastify architecture and patterns
  • Use TypeScript with Fastify (strip types)
  • Implement testing with Fastify's inject method
  • Configure validation, serialization, and error handling

Quick Start

A minimal, runnable Fastify server to get started immediately:

import Fastify from 'fastify'

const app = Fastify({ logger: true })

app.get('/health', async (request, reply) => {
  return { status: 'ok' }
})

const start = async () => {
  await app.listen({ port: 3000, host: '0.0.0.0' })
}
start()

Recommended Reading Order for Common Scenarios

  • New to Fastify? Start with plugins.mdroutes.mdschemas.md
  • Adding authentication: plugins.mdhooks.mdauthentication.md
  • Improving performance: schemas.mdserialization.mdperformance.md
  • Setting up testing: routes.mdtesting.md
  • Going to production: logging.mdconfiguration.mddeployment.md

How to use

Read individual rule files for detailed explanations and code examples:

  • rules/plugins.md - Plugin development and encapsulation
  • rules/routes.md - Route organization and handlers
  • rules/schemas.md - JSON Schema validation
  • rules/error-handling.md - Error handling patterns
  • rules/hooks.md - Hooks and request lifecycle
  • rules/authentication.md - Authentication and authorization
  • rules/testing.md - Testing with inject()
  • rules/performance.md - Performance optimization
  • rules/logging.md - Logging with Pino
  • rules/typescript.md - TypeScript integration
  • rules/decorators.md - Decorators and extensions
  • rules/content-type.md - Content type parsing
  • rules/serialization.md - Response serialization
  • rules/cors-security.md - CORS and security headers
  • rules/websockets.md - WebSocket support
  • rules/database.md - Database integration patterns
  • rules/configuration.md - Application configuration
  • rules/deployment.md - Production deployment
  • rules/http-proxy.md - HTTP proxying and reply.from()

Core Principles

  • Encapsulation: Fastify's plugin system provides automatic encapsulation
  • Schema-first: Define schemas for validation and serialization
  • Performance: Fastify is optimized for speed; use its features correctly
  • Async/await: All handlers and hooks support async functions
  • Minimal dependencies: Prefer Fastify's built-in features and official plugins

Related skills

How it compares

Opinionated Fastify JWT recipe skill—not a generic OpenAPI generator or a full OAuth provider integration.

FAQ

Who is fastify-best-practices for?

backend devs on Fastify who need JWT authentication and route guards without reading the entire Fastify ecosystem docs first.

When should I use fastify-best-practices?

In Build when adding auth plugins and login routes; in Ship/security when reviewing JWT expiry, refresh tokens, and 401 handling before launch.

Is fastify-best-practices safe to install?

Examples use environment-backed secrets and standard verify flows—review the Security Audits panel on this page and never commit JWT_SECRET or paste real credentials into prompts.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.