multi-tenancy

Enforce tenant isolation in TypeScript apps with Fastify, Prisma, and PostgreSQL.

3|1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/jon23d/skillz --skill multi-tenancy-jon23d
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: multi-tenancy
Source: https://github.com/jon23d/skillz/tree/main/skills/multi-tenancy
Command: npx skills add https://github.com/jon23d/skillz --skill multi-tenancy-jon23d

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a robust framework for building multi-tenant features in TypeScript applications, ensuring strict tenant isolation and preventing data leaks between organizations.

Core Features & Use Cases

  • Structural Tenant Isolation: Enforces tenant separation at the database query level, preventing accidental cross-tenant data access.
  • Per-Request Tenant Context: Automatically injects tenant context into every request using JWT claims and Fastify plugins.
  • Scoped Prisma Client: Utilizes Prisma client extensions to automatically scope all database queries to the current tenant.
  • Use Case: Securely manage user data for multiple distinct organizations within a single application deployment, ensuring each organization only sees its own data.

Quick Start

Implement tenant isolation for your Prisma schema and Fastify application by following the setup guide in this skill.

Frequently Asked Questions about multi-tenancy

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

FAQPage Schema
How do I enforce multi-tenant data isolation in a TypeScript Fastify and Prisma application?

Multi-tenant data isolation in a TypeScript application is enforced by using Prisma client extensions to automatically scope database queries to the current tenant, preventing cross-tenant data leaks. This Skill provides the structural framework to implement that scoped querying securely.

What is the best way to scope Prisma queries to a specific tenant in a shared PostgreSQL database?

Scoping Prisma queries in a shared PostgreSQL database is best handled by automatically filtering all queries using a tenantId column. This Skill utilizes Prisma client extensions to intercept and apply tenant context globally, ensuring no unscoped queries execute.

How do I pass tenant context securely per-request in a Fastify application?

Tenant context is passed securely per-request in a Fastify application by extracting tenant identifiers from JWT claims. This Skill manages the injection of that context into the request lifecycle so downstream Prisma queries automatically apply the correct tenant filtering.

Can I use Prisma client extensions to prevent cross-tenant data leaks in a shared database?

Yes, Prisma client extensions can prevent cross-tenant data leaks in a shared database by enforcing structural tenant isolation at the query level. This Skill implements that mechanism to ensure compliance with strict isolation requirements.

Does multi-tenant tenant isolation with Prisma require separate databases for each organization?

Multi-tenant tenant isolation with Prisma does not require separate databases for each organization. This Skill manages shared databases using tenantId columns, allowing multiple distinct organizations to securely reside within a single application deployment.