johnku2011/boilerplates-with-ai-skills/fastify-api-design

Claude Code and agent skill by johnku2011/boilerplates-with-ai-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when adding or changing routes, schemas, or plugins in this Fastify API — keep endpoints validated, typed, and testable.

Install

npx vskill@latest install johnku2011/boilerplates-with-ai-skills/fastify-api-design

SKILL.md

The same SKILL.md was published earlier as johnku2011/boilerplates-with-ai-skills/fastify-api-design.

Fastify API Design

Overview

Keep the Fastify app small, testable, and schema-first. Build on the exported createApp() factory so tests can inject the server without binding a fixed port.

Process

  1. Register routes on the app returned by createApp() in src/app.js.
  2. Define JSON schemas for request/response when the payload shape matters.
  3. Return correct status codes (200/201 success, 400 client error, 404 not found).
  4. Use Fastify's built-in error handler; do not leak stack traces in production.
  5. Add a test/ case that starts the app on port 0 and asserts responses.

Plugin Order

  1. Core plugins (cors, sensible) if needed
  2. Route registration
  3. Global error handler

Testing

  • Integration tests: app.listen({ port: 0 }), fetch against 127.0.0.1.
  • Extract pure helpers for unit tests when logic grows beyond route handlers.
  • Run npm test before every commit.

Guidelines

  • Prefer route-level schemas over ad-hoc validation in handlers.
  • Keep handlers thin; move business logic to testable functions.
  • Read secrets from environment variables at startup, not from requests.
  • Prefer explicit routes over catch-all handlers.

Anti-patterns

  • Bypassing Fastify validation with unvalidated request.body access.
  • Starting the server inside createApp() — keep listen in server.js only.
  • Global mutable state shared across requests.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
240
Repository forks
24
7-day trend score
27

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/johnku2011/boilerplates-with-ai-skills/fastify-api-design/badge)](https://verified-skill.com/skills/johnku2011/boilerplates-with-ai-skills/fastify-api-design)

Something wrong with this skill or its page? Tell us.