users-service

Add Fastify Users Service routes with Auth0 JWT protection and Prisma logic.

1|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/mattbutlerengineering/mattbutlerengineering --skill users-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: users-service
Source: https://github.com/mattbutlerengineering/mattbutlerengineering/tree/main/.claude/skills/users-service
Command: npx skills add https://github.com/mattbutlerengineering/mattbutlerengineering --skill users-service

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The users-service skill helps you safely extend the Users Service by adding Fastify routes, wiring authentication, implementing Prisma-backed business logic, and covering changes with tests and API docs.

Core Features & Use Cases

  • Route scaffolding for Fastify: Create new REST endpoints in services/users/src/routes/users.ts with consistent request/response typing and OpenAPI schema metadata.
  • Auth0-protected endpoints: Add preHandler: requireAuth and declare security: [{ bearerAuth: [] }] so endpoints correctly require JWTs and follow the repo’s error behavior.
  • Service-layer implementation with Prisma: Add business logic in services/users/src/services/user.ts, using mapPrismaUser() for consistent domain mapping and types.
  • Testing patterns for routes: Follow Vitest patterns that mock the service layer and validate responses via app.inject, including 401 cases for missing/invalid auth.

Quick Start

Ask the skill to add a protected endpoint in the Users Service that returns the current authenticated user profile, including the route code, the corresponding service method, the OpenAPI schema update, and the Vitest coverage for the happy path and the 401 case.

Frequently Asked Questions about users-service

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Auth0 JWT protection to Fastify routes?

To add Auth0 JWT protection to Fastify routes, apply `preHandler: requireAuth` and declare `security: [{ bearerAuth: [] }]` in your OpenAPI schema metadata. This ensures endpoints require valid JWTs and follow consistent authentication error behavior.

How do I test Fastify API routes with Vitest including auth failures?

To test Fastify API routes with Vitest, mock the service layer dependencies and validate responses using `app.inject`. This pattern covers happy paths and 401 cases for missing or invalid auth, ensuring your endpoint logic is fully verified.

What is the best way to implement Prisma-backed business logic in a Node.js users service?

The best way to implement Prisma-backed business logic in a Node.js users service is to add methods in the service layer using `mapPrismaUser()` for consistent domain mapping and typing, keeping database interactions separate from route definitions.

How do I define OpenAPI schemas for new Fastify endpoints?

To define OpenAPI schemas for new Fastify endpoints, include consistent request and response typing alongside security metadata directly in your route definitions. This ensures API documentation remains accurate and synchronized with your endpoint implementations.

Can I scaffold new REST endpoints in Fastify with existing authentication behavior?

Yes, you can scaffold new REST endpoints in Fastify with existing authentication behavior by applying `preHandler: requireAuth` and the appropriate OpenAPI security declarations. This integrates new routes seamlessly with the repo's established Auth0 JWT error handling.