Ring:Adding Multi Tenancy logo

Ring:Adding Multi Tenancy

Organization
LerianStudio
ring:adding-multi-tenancy

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.

Overview

PublisherLerianStudio
Repositoryring
Skill namering:adding-multi-tenancy
Stars
215
Forks
28
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by LerianStudio on GitHub. Read the source before you install it.

Installation

Install the Ring:Adding Multi Tenancy AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/LerianStudio/ring.git /tmp/ring
mkdir -p .claude/skills
cp -r /tmp/ring/dev-team/skills/adding-multi-tenancy .claude/skills/lerianstudio-ring-adding-multi-tenancy
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ring:Adding Multi Tenancy in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Ring:Adding Multi Tenancy on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Ring:Adding Multi Tenancy is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

AliasImport PathPurpose
clientgithub.com/LerianStudio/lib-commons/v5/commons/dispatch layer/clientTenant Manager HTTP client
tmcoregithub.com/LerianStudio/lib-commons/v5/commons/dispatch layer/coreContext helpers, resolvers
tmmiddlewaregithub.com/LerianStudio/lib-commons/v5/commons/dispatch layer/middlewareTenantMiddleware (WithPG/WithMB)
tmpostgresgithub.com/LerianStudio/lib-commons/v5/commons/dispatch layer/postgresPostgresManager
tmmongogithub.com/LerianStudio/lib-commons/v5/commons/dispatch layer/mongoMongoManager
tmrabbitmqgithub.com/LerianStudio/lib-commons/v5/commons/dispatch layer/rabbitmqRabbitMQ Manager
valkeygithub.com/LerianStudio/lib-commons/v5/commons/dispatch layer/valkeyRedis key prefixing
s3github.com/LerianStudio/lib-commons/v5/commons/dispatch layer/s3S3 key prefixing
secretsmanagergithub.com/LerianStudio/lib-commons/v5/commons/secretsmanagerM2M credentials

Key mandatory requirements:

  • MULTI_TENANT_URL — correct env var name (NOT TENANT_MANAGER_ADDRESS)
  • 4 canonical metrics (from multi-tenant.md) — all MANDATORY
  • Circuit breaker: client.WithCircuitBreaker — MANDATORY
  • Service API key: client.WithServiceAPIKey — MANDATORY
  • Tenant middleware: per-route WhenEnabled() — NOT global app.Use
  • All context helpers: tmcore.GetPGContext(ctx) / tmcore.GetMBContext(ctx) — NEVER .GetDB() directly

Mandatory agent instruction (include in EVERY dispatch):

WebFetch https://raw.githubusercontent.com/LerianStudio/ring/main/dev-team/docs/standards/golang/multi-tenant.md. Use exact import paths from skill. Do NOT invent sub-package paths. TDD: RED → GREEN → REFACTOR for every gate.

Gate Overview

GateNameConditionAgent
0Stack Detection + Compliance AuditAlwaysOrchestrator
1Codebase Analysis (multi-tenant focus)Alwaysring:codebase-explorer
1.5Implementation PreviewAlwaysring:visualizing
2lib-commons v5 + lib-auth v2 UpgradeSkip only if both already pinned in go.modring:backend-go
3Multi-Tenant ConfigurationAlwaysring:backend-go
4Tenant Middleware (TenantMiddleware with WithPG/WithMB)Alwaysring:backend-go
5Repository AdaptationAlways per detected DBring:backend-go
5.5M2M Secret ManagerSkip if service has no targetServicesring:backend-go
6RabbitMQ Multi-TenantSkip if no RabbitMQring:backend-go
7Metrics & Backward CompatAlwaysring:backend-go
8TestsAlwaysring:backend-go
9Code ReviewAlways9 defaults + triggered specialists in parallel
10User ValidationAlwaysUser
11Activation GuideAlwaysOrchestrator

Gates execute sequentially. Existing multi-tenant code ≠ compliance. Gate 0 audit is mandatory.

Gate 0: Stack Detection + Compliance Audit

Orchestrator executes directly. Two phases:

Phase 1: Stack Detection

bash
grep "lib-commons" go.mod
grep "lib-auth" go.mod
grep -rn "postgresql\|pgx" internal/ go.mod
grep -rn "mongodb\|mongo" internal/ go.mod
grep -rn "redis\|valkey" internal/ go.mod
grep -rn "rabbitmq\|amqp" internal/ go.mod
grep -rn "s3\|ObjectStorage" internal/
grep -rn "MULTI_TENANT_ENABLED\|dispatch layer" internal/
grep -rn "client_credentials\|M2M\|secretsmanager" internal/

Phase 2: Compliance Audit (if multi-tenant code detected)

Run A1-A8 checks (grep-based):

  • A1: MULTI_TENANT_URL used (not TENANT_MANAGER_ADDRESS or variants)
  • A2: WithCircuitBreaker on TM client
  • A3: WithServiceAPIKey on TM client
  • A4: tmcore.GetPGContext / tmcore.GetMBContext used (not .GetDB() / .GetDatabase())
  • A5: Tenant middleware per-route WhenEnabled() (not global app.Use)
  • A6: Redis keys use valkey.GetKeyContext
  • A7: S3 keys use s3.GetS3KeyStorageContext
  • A8: No global DB singletons (var db *sql.DB or var client *mongo.Client)

Any NON-COMPLIANT → corresponding gate MUST execute.

Severity Reference

SeverityCriteria
CRITICALCross-tenant data leak; wrong tenant identifier (organization_id)
HIGHMissing TenantMiddleware; wrong env var names; no circuit breaker
MEDIUMMissing circuit breaker; incomplete metrics
LOWMissing env var comments; pool tuning notes

Frequently asked questions

What does the Ring:Adding Multi Tenancy AI skill do?

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.

Why use Ring:Adding Multi Tenancy on TypingMind?

Because you install it once and use it with any model. Ring:Adding Multi Tenancy is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Ring:Adding Multi Tenancy in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/LerianStudio/ring/tree/main/dev-team/skills/adding-multi-tenancy. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Ring:Adding Multi Tenancy?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Ring:Adding Multi Tenancy?

As many as you like. As long as a model supports skills, you can use Ring:Adding Multi Tenancy with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ring:Adding Multi Tenancy AI skill free?

Yes. It is published on GitHub by LerianStudio under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇