Agent skill

Multi Tenant Architecture

by mblode in mblode/agent-skills

Designs tenant isolation, hostname routing, custom-domain lifecycle, and plan limits on Cloudflare or Vercel.

MITAuto-check passedBackend & APIs

Install Multi Tenant Architecture

skills CLI
$ npx skills add mblode/agent-skills --skill multi-tenant-architecture -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mblode/agent-skills multi-tenant-architecture --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mblode/agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/multi-tenant-architecture .claude/skills/multi-tenant-architecture && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
multi-tenant-architecture
GitHub stars
144
Token cost
~3.1k tokens
SKILL.md length
1,375 words
Files
8 (incl. references)
Skills in repo
28
Repo updated
First seen
Licence
MIT

At a glance

Designs tenant isolation, hostname routing, custom-domain lifecycle, and plan limits on Cloudflare or Vercel.

  • Asked to isolate tenant data
  • SKILL.md covers Contents, Platform dispatch (decide first), Reference files and Workflow (order matters), plus 4 more sections
  • Calls curl, rg and psql
  • Support custom domains

What it does

Multi Tenant Architecture is an agent skill from mblode/agent-skills. Designs tenant isolation, hostname routing, custom-domain lifecycle, and plan limits on Cloudflare or Vercel. Use when asked to "isolate tenant data", "support custom domains", "build a white-label platform", or assess PSL registration. For general module structure use codebase-architecture; for SEO content use seo.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files, including reference files (for example `evals/evals.json`, `references/cloudflare-platform.md` and `references/data-isolation.md`).

It sits in Backend & APIs, covering Multi-tenancy and On-page SEO. It works with Cloudflare and Vercel. The repository describes itself as: Nobody ships AI slop on purpose. These skills make sure you don’t. The licence is MIT.

When your agent uses it

  • Asked to isolate tenant data
  • Support custom domains
  • Build a white-label platform
  • Assess PSL registration

Example prompts

  • “isolate tenant data”
  • “support custom domains”
  • “build a white-label platform”
  • “/multi-tenant-architecture”

Requirements

  • Node.js

What it can do on your machine

Read from SKILL.md and the folder at commit 5a781a8. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • curl
    • rg
    • psql

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use curl, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Multi Tenant Architecture loads about 3.1k tokens when it runs, and up to ~13k if it reads all its reference files. Until then it costs about 86 tokens; SKILL.md has 1,375 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~86
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~13k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mblode/agent-skills at commit 5a781a8, republished under its MIT licence (© mblode). 1,375 words, ~3,098 tokens.

Download SKILL.mdSave it as .claude/skills/multi-tenant-architecture/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
multi-tenant-architecture
description
Designs tenant isolation, hostname routing, custom-domain lifecycle, and plan limits on Cloudflare or Vercel. Use when asked to "isolate tenant data", "support custom domains", "build a white-label platform", or assess PSL registration. For general module structure use codebase-architecture; for SEO content use seo.

Multi-Tenant Platform Architecture (Cloudflare or Vercel)

  • IS: platform choice, domain strategy and PSL, tenant identification, compute and data isolation, hostname routing, tenant context propagation, custom domains and SSL, per-tenant static files, and mapping platform limits to plans.
  • IS NOT: general folder structure or module contracts (use codebase-architecture), scaffolding a new repo (use scaffold-nextjs), or the content of per-tenant SEO files once routing serves them dynamically: sitemap entries, canonical URLs, structured data, indexing policy (use seo).

Contents

  • Platform dispatch (decide first)
  • Reference files
  • Workflow (order matters)
  • Gotchas
  • Output schema
  • Evidence commands
  • Related skills

Platform dispatch (decide first)

SignalsPlatformModel
Tenants upload or generate their own code; code-level isolation; edge compute on KV, D1, Durable Objects, R2CloudflareDispatch Worker in front of a dispatch namespace of per-tenant Workers; Cloudflare for SaaS for custom hostnames
Every tenant runs the same Next.js codebase and differs by content, branding, and plan; ISR, Server Components, Vercel deploysVercelOne deployment; proxy.ts resolves the tenant from the hostname; wildcard plus custom domains on the project
  • Pick one platform per product. Fronting a Vercel app with a Cloudflare proxy doubles the TLS and redirect layers and is the usual cause of redirect loops and failed certificate issuance.
  • Tenants shipping their own code on Vercel is the multi-project model (one Vercel project per tenant, created with the SDK). It follows the Cloudflare row's isolation reasoning; this skill's Vercel references cover the single-deployment model only.

Reference files

FileRead when
cloudflare-platform.mdCloudflare chosen: dispatch namespaces, routing, Cloudflare for SaaS custom hostnames, isolation modes, KV and D1 (steps 3 to 7)
vercel-platform.mdVercel chosen: proxy.ts resolution, App Router layout, Global Config lookups, per-tenant static files, custom subpaths, local dev (steps 4 to 7)
vercel-domains.mdVercel chosen: SDK domain lifecycle, DNS targets, verification, wildcard nameservers, SSL, troubleshooting (step 7)
data-isolation.mdStep 3 on either platform: shared schema with RLS, schema-per-tenant, database-per-tenant, and the Postgres/Supabase/Drizzle policy pattern
psl.mdStep 1 when tenants publish content or run code on sibling subdomains: eligibility, submission, interim cookie controls
limits-and-quotas.mdStep 8: Cloudflare, Vercel, and Neon limit names with the official source for each, to map onto plans

Workflow (order matters)

Copy this checklist to track progress:

text
Multi-tenant progress:
- [ ] Step 1: Domain strategy and PSL decision
- [ ] Step 2: Tenant identification strategy
- [ ] Step 3: Isolation model (compute and data)
- [ ] Step 4: Deterministic routing
- [ ] Step 5: Tenant context propagation
- [ ] Step 6: Tenant config and least-privilege bindings
- [ ] Step 7: Custom domains and per-tenant static files
- [ ] Step 8: Limits mapped to plans, evidence captured
  1. Choose the domain strategy
  • Put tenant workloads on a dedicated registrable domain (acme.app for tenants, acme.com for brand). One phishing tenant on x.acme.com puts the whole domain on blocklists, and a tenant cookie with Domain=acme.com reaches your dashboard.
  • Keep the dashboard and auth on a different apex from tenant subdomains (app.acme.com for the console, *.acme.app for tenants).
  • If tenants publish content or run code on sibling subdomains, submit the label directly above the tenant name (acme.app, or sites.acme.app for <tenant>.sites.acme.app) to the PSL and start now: there is no SLA. Tenant-owned custom domains need no PSL entry. Otherwise record No PSL with the reason.
  1. Choose tenant identification (one primary; custom domain as the upgrade path)
  • Subdomain tenant.acme.app: wildcard DNS plus wildcard certificate. The default.
  • Custom domain tenant.com: the tenant CNAMEs to you. Paying tenants; reputation shifts to them; needs the onboarding lifecycle in step 7.
  • Path acme.app/tenant: no per-tenant DNS or certificates, but no cookie isolation and no branding. Choose it only when tenants will never get a hostname.
  1. Define the isolation model
  • Compute, Cloudflare: one dispatch namespace in untrusted mode; per-invocation cpuMs and subRequests limits per plan; an outbound Worker if tenant code may call the internet.
  • Compute, Vercel: one deployment, tenant code never executes. If tenants must ship code, move to Vercel multi-project or Cloudflare rather than sandboxing inside the app.
  • Data: shared schema with tenant_id on every tenant-aware table plus RLS is the default; database-per-tenant for regulated or noisy tenants, selectable per plan. See data-isolation.md.
  1. Route deterministically (tenants never influence routing or see each other)
  • Cloudflare: a single */* route on the SaaS zone to the dispatch Worker; hostname -> tenant record (KV, D1 on miss) -> env.DISPATCHER.get(script); Worker not found -> 404.
  • Vercel: proxy.ts (Next.js 16; middleware.ts with runtime: 'nodejs' on 15) reads host, looks the tenant up in Global Config or the database, rewrites into the tenant segment; unknown hostname -> 404, never the brand site.
  • Let /.well-known through before any tenant rewrite. Route robots.txt, sitemap.xml, and llms.txt into the tenant segment so they vary per tenant.
  1. Propagate tenant context from one authority
  • Delete every inbound x-tenant-* header, set x-tenant-id, x-tenant-slug, x-tenant-plan from the resolved tenant, and forward them on the request (NextResponse.next({ request: { headers } })). Server Components read await headers(); route handlers read request.headers. Cloudflare: the dispatch Worker sets headers or passes parameters before fetch.
  • The proxy is routing, not authorization. Server Functions, route handlers, and jobs re-derive the tenant from the session and the data layer enforces it (RLS or tenant_id predicates).
  1. Bind only what the tenant needs
  • Cloudflare: each user Worker gets its own bindings (KV namespace, D1 database, R2 prefix); adding a binding is an explicit redeploy. No shared globals.
  • Vercel: Global Config holds only hostname -> { id, slug, plan }; the database is the source of truth and write-through happens when a domain verifies. Feature flags and branding come from the database keyed by tenant id.
Show full SKILL.md (529 more words)Show less
  1. Support custom domains and per-tenant static files
  • Lifecycle to design and record: add domain -> show DNS target -> verify ownership -> certificate issued -> mapping activated -> removal or failure path.
  • Cloudflare: Cloudflare for SaaS custom hostname on the SaaS zone, proxied fallback origin, customers.<you>.com CNAME target, http or txt validation, pre-validate before DNS cutover. See cloudflare-platform.md.
  • Vercel: projectsAddProjectDomain -> DNS values from the project's domain card -> _vercel TXT only if the domain is already on Vercel -> projectsVerifyProjectDomain -> Let's Encrypt HTTP-01. See vercel-domains.md.
  • robots.txt, sitemap.xml, llms.txt are route handlers inside the tenant segment with explicit Content-Type; nothing tenant-specific lives in /public. Their content is seo territory.
  1. Surface limits as plans and capture evidence
  • Fill the limits-to-plan table from limits-and-quotas.md, reading each current value from its source URL and dating it; enforce at the routing layer (Cloudflare limits, Vercel plan header plus server checks).
  • Nothing long-running in the request path: Cloudflare Queues or Workflows, Vercel background functions or cron.
  • Every tenant operation (create tenant, add domain, verify, remove) works over HTTP with the same authority as the UI; if it only works in the dashboard, the platform leaks into the UI.
  • Run the evidence commands and paste results into the output.

Gotchas

Platform and data gotchas live in the reference for that step; these fire before any reference loads.

  • Forwarding inbound tenant headers: curl -H "x-tenant-id: <other>" then serves another tenant's data. Delete or overwrite x-tenant-* on every path through the proxy or dispatch Worker, including paths that skip resolution (/.well-known, the brand site).
  • A hostname map keyed in a restricted alphabet (Global Config allows only ^[\w-]+$) needs a collision-free encoding or a hash; replacing dots with underscores maps a-b.example.com and a.b-example.com to one key. Keep the original hostname in the record and compare it on read.
  • Starting path-based with custom domains on the roadmap means URL rewrites, cookie changes, and DNS migration later.

Output schema

Length follows the decisions: drop any section the project does not face rather than filling it.

markdown
# Multi-tenant architecture

## Platform decision
- Platform: Cloudflare | Vercel
- Why this platform:
- Rejected platform and reason:

## Domain map
- Brand domain:
- Tenant domain:
- Tenant subdomains:
- Custom domains:
- PSL decision: Submit (suffix, owner, PR link, _psl TXT date) | No PSL (reason)

## Routing matrix
| Host pattern | Resolver | Destination | Unknown tenant behavior |
|---|---|---|---|

## Tenant context flow
- Authority: proxy.ts | dispatch Worker
- Headers set and stripped:
- Server read path:
- Data-layer enforcement:

## Isolation model
- Compute isolation:
- Data isolation (and per-plan variant):
- Config/binding isolation:

## Custom-domain lifecycle
1. DNS target:
2. Ownership verification:
3. Certificate provisioning:
4. Routing activation:
5. Removal/failure path:

## Limits-to-plan table
| Limit | Source URL / access date | Free | Pro | Enterprise | Enforcement point |
|---|---|---:|---:|---:|---|

## Validation evidence
| Check | Command | Expected | Result |
|---|---|---|---|

Evidence commands

Run against local or preview before calling the design done; mark N/A with a reason.

CheckCommandExpected
Tenant boundary exists in coderg -n "x-tenant-id|CREATE POLICY|FORCE ROW LEVEL SECURITY|DISPATCHER.get" .Hits in proxy or dispatch Worker and in the schema
Unknown host is 404curl -sI -H "Host: nope.acme.app" <url>404
Forged header ignoredcurl -s -H "Host: a.acme.app" -H "x-tenant-id: tenant-b" <url>/api/whoamiTenant A
Static files varycurl -s -H "Host: a.acme.app" <url>/robots.txt vs -H "Host: b.acme.app"Different bodies, Content-Type: text/plain
RLS holds for the app rolepsql -c "BEGIN; SET LOCAL ROLE app_user; SELECT set_config('app.tenant_id','<t1>',true); SELECT count(*) FROM posts; ROLLBACK;"Only tenant t1's rows
ACME path reachablecurl -sI -H "Host: tenant.com" <url>/.well-known/acme-challenge/testNot a redirect into the tenant segment
Limits currentAccess date next to each URL in the limits tableDated within the planning window
  • codebase-architecture: folder structure, module contracts, and the request-context pipeline for the application itself.
  • scaffold-nextjs: bootstrap the Next.js turborepo before applying these tenancy patterns.
  • seo: content of per-tenant robots.txt, sitemap.xml, llms.txt, canonical URLs, and structured data once routing serves them.

Maintenance only: evals/evals.json contains regression scenarios for changes to this skill; it does not load during a user task.

© mblode, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (references) in skills/multi-tenant-architecture of mblode/agent-skills.

  • SKILL.md
  • evals/evals.json
  • references/cloudflare-platform.md
  • references/data-isolation.md
  • references/limits-and-quotas.md
  • references/psl.md
  • references/vercel-domains.md
  • references/vercel-platform.md

Open the folder on GitHubat commit 5a781a8

Compare with similar skills

Multi Tenant Architecture next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Multi Tenant Architecture compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Multi Tenant Architecture this skillmblode/agent-skills144—~3.1kAutomated safety check: PassMIT
Golivemikehasa/golive-skill1.2k—~13kAutomated safety check: NotesMIT
Sandbox Manageressamamdani/openclaw-coolify154—~340Automated safety check: PassNone
Nitro Server Toolkitantfu/skills6k—~948Automated safety check: PassMIT
Tanstack StartMindrally/skills269—~2.1kAutomated safety check: PassApache-2.0
Gingiris B2b GrowthGingiris-1031/Competitor-analysis-tool110—~1.2kAutomated safety check: PassNone

Similar skills

  • Golive

    mikehasa/golive-skill

    Take an agent-written app from repo to live production on the user's OWN accounts, with providers they choose (hosting, database, auth, payments, email, domain/DNS).

    1.2k GitHub stars~13k tokensUpdated 5 days ago
    Backend & APIsAuto-check: notes
  • Sandbox Manager

    essamamdani/openclaw-coolify

    Create and manage isolated application sandboxes (Next.js, Python, PHP, etc.) with public URLs via Cloudflare.

    154 GitHub stars~340 tokensUpdated 2 mo ago
    Backend & APIsAuto-check passed
  • Reference for Nitro v3, the server toolkit behind Nuxt: file routing, route rules, caching, storage, tasks, websockets and deployment presets.

    6k GitHub stars~948 tokensUpdated today
    Backend & APIsAuto-check passed
  • Tanstack Start

    Mindrally/skills

    Best practices for TanStack Start, the full-stack React framework built on TanStack Router and Vite/Nitro.

    269 GitHub stars~2.1k tokensUpdated today
    Backend & APIsAuto-check passed
  • Gingiris B2b Growth

    Gingiris-1031/Competitor-analysis-tool

    🇺🇸 B2B SaaS Growth — PLG vs SLG Playbook — Diagnose whether your problem is distribution, pricing, or PMF.

    110 GitHub stars~1.2k tokensUpdated today
    Marketing & SEOAuto-check passed
  • Nuxt Content

    secondsky/claude-skills

    Nuxt Content v3 Git-based CMS for Markdown/MDC content sites.

    227 GitHub stars~4.3k tokensUpdated 11 days ago
    Frontend & DesignAuto-check passed

More from mblode/agent-skills

All 28 skills in this repo
  • Agent Ready

    mblode/agent-skills

    Implements agent-readiness on public sites and docs from Mintlify Agent Score, AFDocs, Is Agentic, Is It Agent Ready, or url-discovery-bench reports, or from server logs of agents 404ing on guessed…

    144 GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • Agent Skills Creator

    mblode/agent-skills

    Creates and improves portable Agent Skills with a validator, routing scenarios, and evidence-based keep, cut, merge, or retire decisions.

    144 GitHub stars~2.8k tokensUpdated today
    Auto-check passed
  • Chat History

    mblode/agent-skills

    Recovers decisions, previous fixes, research, and what followed a prompt from past AI conversations, with source evidence.

    144 GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • CI Speedup

    mblode/agent-skills

    Cuts the wait from push to green by measuring a pipeline's critical path from run timestamps, then splitting, sharding, trimming setup and sharing test module state, with a before/after ledger.

    144 GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • PR Babysitter

    mblode/agent-skills

    Monitors or repairs an open GitHub PR: CI failures, conflicts, review threads, and merge readiness, reporting state changes.

    144 GitHub stars~3.6k tokensUpdated today
    Auto-check passed
  • UI Animation

    mblode/agent-skills

    Builds, reviews, and measures UI motion, including springs, gestures, scroll effects, curve fitting from recordings, and sparse interface sound.

    144 GitHub stars~5.7k tokensUpdated today
    Auto-check passed

Categories

Questions about Multi Tenant Architecture

What does Multi Tenant Architecture do?

Designs tenant isolation, hostname routing, custom-domain lifecycle, and plan limits on Cloudflare or Vercel. Multi Tenant Architecture is an agent skill from mblode/agent-skills. Designs tenant isolation, hostname routing, custom-domain lifecycle, and plan limits on Cloudflare or Vercel.

When should I use Multi Tenant Architecture?

Multi Tenant Architecture fits situations like: asked to isolate tenant data; support custom domains; build a white-label platform; assess PSL registration.

How do I install Multi Tenant Architecture in Claude Code?

Run `npx skills add mblode/agent-skills --skill multi-tenant-architecture -a claude-code`. Or copy the skill folder (skills/multi-tenant-architecture in mblode/agent-skills) into .claude/skills/multi-tenant-architecture in your project. Claude Code loads it when a task matches its description.

How do I install Multi Tenant Architecture in Codex?

Run `npx skills add mblode/agent-skills --skill multi-tenant-architecture -a codex`. Or copy the skill folder (skills/multi-tenant-architecture in mblode/agent-skills) into .agents/skills/multi-tenant-architecture in your project. Codex loads it when a task matches its description.

Can I use Multi Tenant Architecture in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mblode/agent-skills --skill multi-tenant-architecture -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/multi-tenant-architecture, .gemini/skills/multi-tenant-architecture, .github/skills/multi-tenant-architecture and .opencode/skills/multi-tenant-architecture in your project.

What does Multi Tenant Architecture need to run?

Going by SKILL.md and its folder, Multi Tenant Architecture needs the command-line tools its instructions call (curl, rg and psql). Our summary lists: Node.js.

Does Multi Tenant Architecture access the network?

SKILL.md contains no URLs. Its commands use curl, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Multi Tenant Architecture safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Multi Tenant Architecture use?

Multi Tenant Architecture is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Multi Tenant Architecture use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 10k tokens, read only when the agent opens those files.

What are the alternatives to Multi Tenant Architecture?

Skills that share tags, products or a category with Multi Tenant Architecture: Golive (mikehasa/golive-skill, 1.2k stars), Sandbox Manager (essamamdani/openclaw-coolify, 154 stars), Nitro Server Toolkit (antfu/skills, 6k stars) and Tanstack Start (Mindrally/skills, 269 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Multi Tenant Architecture?

mblode (a GitHub user) maintains it in mblode/agent-skills, which has 144 GitHub stars. The repository holds 28 skills in this directory. The repository was last updated on October 8, 2026.

Source: mblode/agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.