saas-multitenancy

saas-multitenancy is a skill for Claude Code, Codex from TheWayWithin/agent-11. It costs 6 tokens per session (2,000 once invoked), scanned A, original, MIT.

A guide to building SaaS software for multiple separate customers, called tenants, while keeping each customer's data isolated. It covers tenant context, organizations, teams, roles, routing, and database row-level security, which lets a database restrict rows by tenant.

In plain words
What is it for?
Designing tenant-scoped APIs and queries, setting up organization hierarchies, provisioning tenants, and enforcing isolation with database rules.
Why use it?
It reduces the risk of one customer seeing or changing another customer's data. It also provides patterns for handling shared databases and tenant-specific requests consistently.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/thewaywithin/agent-11/saas-multitenancy
Any agent
npx skills add TheWayWithin/agent-11 --skill saas-multitenancy
Clone the repo
git clone --depth 1 https://github.com/TheWayWithin/agent-11

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for saas-multitenancy

README.md
[![agentmods](https://agentmods.dev/badge/skills/thewaywithin/agent-11/saas-multitenancy.svg)](https://agentmods.dev/skills/thewaywithin/agent-11/saas-multitenancy)
Your own site
<a href="https://agentmods.dev/skills/thewaywithin/agent-11/saas-multitenancy"><img src="https://agentmods.dev/badge/skills/thewaywithin/agent-11/saas-multitenancy.svg" alt="Measured on agentmods" height="20"></a>
Per session 6 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,000 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00006 $0.02000
Opus 5 $0.00003 $0.01000
Sonnet 5 $0.00001 $0.00400
Haiku 4.5 $0.00001 $0.00200

Measured today against content hash 265104d05518, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

saas-multitenancy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/saas-multitenancy/SKILL.md · 312 lines

How it starts

The opening of the file, as written. The whole thing — 312 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SaaS Multi-Tenancy

Capability

Implement robust multi-tenant architecture for SaaS applications with proper data isolation, tenant context management, and scalable patterns. Covers shared database with row-level security, tenant-scoped queries, and organization/team hierarchies.

Use Cases

  • Data isolation between tenants (organizations/workspaces)
  • Team/organization hierarchy with roles
  • Tenant-scoped API endpoints
  • Subdomain or path-based tenant routing
  • Tenant provisioning and onboarding
  • Cross-tenant admin operations

Patterns

Row-Level Security (RLS) Pattern

When to use: Shared database with multiple tenants needing data isolation

Implementation: Use database-level RLS policies to enforce tenant isolation. Every query automatically filters by tenant.

-- Enable RLS on tenant tables
ALTER TABLE projects ENABLE ROW LEVEL SECURITY;

-- Create tenant isolation policy
CREATE POLICY tenant_isolation ON projects
  USING (tenant_id = current_setting('app.current_tenant_id')::uuid);

-- Create policy for insert
CREATE POLICY tenant_insert ON projects
  FOR INSERT
  WITH CHECK (tenant_id = current_setting('app.current_tenant_id')::uuid);

-- Create policy for update/delete
CREATE POLICY tenant_modify ON projects
  FOR ALL
  USING (tenant_id = current_setting('app.current_tenant_id')::uuid);
// Middleware to set tenant context
async function setTenantContext(tenantId: string) {
  // Set session variable for RLS
  await db.execute(
    sql`SELECT set_config('app.current_tenant_id', ${tenantId}, true)`
  );
}

// Usage in API route
async function handleRequest(req: Request) {
  const tenantId = await getTenantFromSession(req);
  await setTenantContext(tenantId);

  // All subsequent queries automatically filtered
  const projects = await db.query.projects.findMany();
  return projects; // Only returns tenant's projects
}

Tenant Context Middleware

When to use: Every request needs tenant context for data access

Read the full file on GitHub · 312 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 312 lines · 6 tokens per session scan A 265104d05518

Subscribe to this mod's changes

saas-multitenancy is a skill published in the GitHub repository TheWayWithin/agent-11 (15 stars, last pushed 13d ago), licensed MIT. It adds 6 tokens to every session and 2,000 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.