multi-tenancy-patterns

Implement standardized multi-tenant patterns with branch_id isolation and tenant-scoped data access.

3|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/bipinks/ghost-office --skill multi-tenancy-patterns-bipinks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: multi-tenancy-patterns
Source: https://github.com/bipinks/ghost-office/tree/main/.claude/skills/multi-tenancy-patterns
Command: npx skills add https://github.com/bipinks/ghost-office --skill multi-tenancy-patterns-bipinks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It standardizes and codifies multi-tenant patterns to safely isolate customer data across shared databases, reducing the risk of cross-tenant data leakage and accelerating architecture reviews.

Core Features & Use Cases

  • Branch_id isolation on all domain tables
  • Tenant resolution and context propagation
  • HasBranch trait, BranchScope, and data-scoping rules
  • Tenant-aware caching, queues, and file storage patterns

Quick Start

Apply the branch_id pattern to your models and middleware and run tests to verify isolation.

Frequently Asked Questions about multi-tenancy-patterns

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

FAQPage Schema
How do I implement multi-tenant data isolation in a shared database?

Multi-tenant data isolation in a shared database is implemented by applying a branch_id column to domain tables and enforcing tenant-scoped data access rules. This standardizes data scoping to prevent cross-tenant data leakage.

What is tenant resolution and how does context propagation work?

Tenant resolution identifies the active customer context from incoming requests, while context propagation passes this branch_id through middleware. This ensures downstream caching, queues, and file storage operations remain tenant-aware.

How do I apply branch_id isolation to existing application models?

To apply branch_id isolation, integrate a HasBranch trait into your models and enforce a BranchScope for queries. This standardizes architecture migrations by automatically scoping all data access to the resolved tenant.

What's the best way to test tenant-aware caching and queues for cross-tenant leakage?

The best way to test tenant-aware caching and queues is to run isolation tests across tenant-specific scenarios. This verifies that branch_id scoping correctly prevents data leakage in middleware, storage, and asynchronous jobs.

Do I need explicit tenant resolution for multi-tenant file storage and queues?

Yes, explicit tenant resolution is required for multi-tenant file storage and queues. Applying branch_id scoping ensures that all cached data, queued jobs, and stored files are isolated to their respective tenants.

When should I standardize multi-tenancy patterns during an architecture migration?

You should standardize multi-tenancy patterns during architecture migrations when shared databases risk cross-tenant data leakage. Codifying branch_id isolation and BranchScope rules early accelerates architecture reviews and ensures safe data access.