| name | ring:adding-multi-tenancy |
| description | Adding database-per-tenant isolation into a Go service end-to-end via an 11-gate cycle: detects the stack, audits compliance, then dispatches backend agents to implement tenantId-from-JWT routing through the lib-commons v5 dispatch layer (config, middleware, repositories, metrics, tests) and runs reviewers. Use when adding tenant isolation to a Go service. Skip for non-Go services or organization_id-style soft tenancy. |
Multi-Tenant Development Cycle
When to use
- User requests multi-tenant implementation for a Go service
- User asks to add tenant isolation to an existing service
- Task mentions "multi-tenant", "tenant isolation", "dispatch layer", "postgres.Manager", "WithPG", "WithMB", "EventListener", "TenantCache", "TenantLoader"
Skip when
- Service is not a Go project
- Task does not involve multi-tenancy or tenant isolation
- Service is a shared infrastructure component operating outside tenant context
- Task is documentation-only or non-code
You orchestrate. Agents implement. NEVER use Edit/Write/Bash on Go source files.
All code changes go through Task(subagent_type="ring:backend-go").
TDD mandatory for all implementation gates (RED → GREEN → REFACTOR).
Multi-Tenant Architecture
Isolation: tenantId from JWT → dispatch layer middleware → database-per-tenant.
organization_id is NOT multi-tenant. tenantId from JWT is the ONLY mechanism.
Standards reference: https://raw.githubusercontent.com/LerianStudio/ring/main/dev-team/docs/standards/golang/multi-tenant.md
Sub-package import reference: