Token导航 LogoToken导航

Agent Skill · 前端设计

multi-tenant-saas-architecture(多租户 SaaS 架构)

multi-tenant-saas-architecture 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

multi-tenant-saas-architecture 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 3,611。

总安装 1,224周安装 51GitHub Stars 11下载 408核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:multi-tenant-saas-architecture(多租户 SaaS 架构)
来源仓库:https://github.com/peterbamuhigire/skills-web-dev
仓库路径:skills/multi-tenant-saas-architecture
安装命令:
npx skills add https://github.com/peterbamuhigire/skills-web-dev --skill multi-tenant-saas-architecture
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/peterbamuhigire/skills-web-dev --skill multi-tenant-saas-architecture

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。可结合来源仓库、安装命令和原始 README 继续核验具体用法。

安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。使用时需注意 API 调用频率限制和数据隐私边界。

来源仓库内路径:skills/multi-tenant-saas-architecture

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/peterbamuhigire/skills-web-dev --skill multi-t…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

multi-tenant-saas-architecture 怎么安装?

在终端执行 npx skills add https://github.com/peterbamuhigire/skills-web-dev --skill multi-tenant-saas…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

multi-tenant-saas-architecture 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

multi-tenant-saas-architecture 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

multi-tenant-saas-architecture 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

multi-tenant-saas-architecture 用的人多吗?

公开数据是累计安装 1,224 次,近一周安装 51 次,下载 408 次,GitHub 11 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

multi-tenant-saas-architecture 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
multi-tenant-saas-architecture

多租户 SaaS 架构 · 本页

1,22411需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Multi-Tenant SaaS Architecture

Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.

Use When

  • Designing tenancy for a new SaaS, or hardening an existing SaaS against cross-tenant leakage.
  • Splitting a SaaS into three panels (super admin, tenant/franchise admin, end user) with distinct scopes.
  • Designing per-tenant role overrides, permission priority ordering, and audit trails for privileged access.
  • Planning the session, JWT, and tenant_id plumbing that downstream database, API, security, and delivery skills rely on.

Do Not Use When

  • The task is a single-tenant app with no plan for tenancy — this skill's constraints add overhead with no benefit.
  • The work is about business-module composition rather than tenant boundaries — use modular-saas-architecture.
  • The work is pure schema shaping inside an already-defined tenant model — use database-design-engineering and mysql-best-practices.

Required Inputs

  • Context map and critical-flow table from system-architecture-design.
  • Access-pattern list from database-design-engineering (so isolation model matches real queries).
  • Threat model / abuse cases from vibe-security-skill.
  • Panel and user-type list from product requirements (super admin, tenant admin, end user, and their sub-types).

Workflow

  • Read this SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.
  • Apply the ordered guidance, checklists, and decision rules in this skill instead of cherry-picking isolated snippets.
  • Produce the tenant-isolation map, panel layout, permission model, and audit plan as the deliverables named in Outputs.

Quality Standards

  • Keep outputs execution-oriented, concise, and aligned with the repository's baseline engineering standards.
  • Preserve compatibility with existing project conventions unless the skill explicitly requires a stronger standard.
  • Prefer deterministic, reviewable steps over vague advice or tool-specific magic.

Anti-Patterns

  • Treating examples as copy-paste truth without checking fit, constraints, or failure modes.
  • Loading every reference file by default instead of using progressive disclosure.

Outputs

  • Tenant-isolation map, panel definitions, permission priority model, and audit plan (see the Outputs table below).
  • Clear assumptions, tradeoffs, or unresolved gaps when the task cannot be completed from available context alone.
  • References used, companion skills, or follow-up actions when they materially improve execution.

Evidence Produced

CategoryArtifactFormatExample
Data safetyTenant isolation noteMarkdown doc covering row-level vs schema-level isolation, RLS policies, and tenant-scoped indexesdocs/saas/tenant-isolation-note.md
SecurityTenant authorization auditMarkdown doc covering super-admin vs tenant-admin vs user privilege boundaries and authz testsdocs/saas/tenant-authz-audit.md

References

  • Use the references/ directory for deep detail after reading the core workflow below.
  • Use the documentation/ directory for supporting implementation detail or migration notes.

Production-grade multi-tenant SaaS architecture with three-panel separation, zero-trust enforcement, strict tenant isolation, and comprehensive audit trails. This skill defines the tenant and auth boundaries that every downstream module, API, and data query inherits.

Prerequisites

Load these first, in order:

  1. world-class-engineering — repository-wide quality bar.
  2. system-architecture-design — produces the context map and critical flows this skill consumes.
  3. database-design-engineering — produces the access-pattern list that shapes the isolation model.
  4. vibe-security-skill — produces the threat model and auth rules this skill encodes.

When this skill applies

  • Designing tenancy for a new SaaS from scratch.
  • Converting a single-tenant app to multi-tenant (see documentation/migration.md).
  • Auditing an existing SaaS for cross-tenant leakage, missing tenant_id filters, or un-audited admin actions.
  • Planning the three-panel file and route layout (/, /adminpanel/, /memberpanel/).
  • Designing the permission priority ladder (user deny > user grant > tenant override > role > default deny).
  • Defining what actions must be audited and how long audit records are retained.

Inputs

ArtifactProduced byRequired?Why
Context mapsystem-architecture-designrequireddefines services, panels, ownership
Critical-flow tablesystem-architecture-designrequiredshapes auth and session boundaries
Access-pattern listdatabase-design-engineeringrequiredchooses shared-DB-with-tenant_id vs DB-per-tenant
Threat modelvibe-security-skillrequiredinforms audit rules and abuse cases
Panel and user-type listproduct requirementsrequireddetermines role and scope per panel

Outputs

ArtifactConsumed byTemplate
Tenant-isolation map (isolation model + tenant_id rules per table)database-design-engineering, api-design-firstinline (this skill)
Panel definitions (super admin, tenant admin, end user)api-design-first, kubernetes-saas-deliveryinline
Permission priority model (user/tenant override/role/default deny)vibe-security-skill, api-design-firstinline + references/permission-model.md
Session and JWT plan (prefixing, lifetimes, rotation)api-design-first, vibe-security-skillinline
Audit event set and retention policyobservability-monitoring, reliability-engineeringinline
Migration plan (single-tenant to multi-tenant)database-design-engineering, deployment-release-engineeringdocumentation/migration.md

Non-negotiables

  • Every franchise/tenant-scoped table has tenant_id (or franchise_id) NOT NULL with a foreign key to tenants.
  • Every query on a tenant-scoped table includes tenant_id in the WHERE clause.
  • tenant_id is always extracted from session or JWT — never from client input (body, query, header).
  • Default authorisation decision is deny. Every action requires an explicit permission check.
  • Every super-admin action that touches tenant data is audited with actor, target tenant, and justification.
  • Cross-tenant access that should not exist returns 404 Not Found, never 403 Forbidden (403 confirms the resource exists).

Decision rules

Isolation model

Tenants share data schema AND tenants < ~10k AND regulated data not tenant-partitioned
    -> Shared DB, row-level tenant_id (default choice for this skill)

Strong regulatory boundary (HIPAA/PCI) per tenant
    -> Schema-per-tenant OR DB-per-tenant; app injects connection by tenant

Single very large tenant needs isolation from the rest
    -> Hybrid: shared DB for small tenants, dedicated DB for large tenant

Wrong choice failure modes:
- Shared DB without tenant_id discipline -> data leakage, impossible to audit
- DB-per-tenant at small scale -> migration and operational cost explodes
- Schema-per-tenant without tooling -> migrations drift across schemas

Panel placement of a new feature

Feature controls platform config, billing, tenant lifecycle, or impersonation
    -> /adminpanel/ (super_admin only, audited)

Feature is tenant-admin workspace (manage own tenant, staff, catalogue)
    -> /public/ root (tenant owners/staff, scoped by tenant_id)

Feature is self-service for end user (customer/member/student/patient)
    -> /memberpanel/ (own records only, scoped by tenant_id AND user_id)

Wrong choice failure modes:
- Admin feature in /public/ -> tenant users see platform levers
- Tenant feature in /memberpanel/ -> end users escalate to admin-only data
- End-user feature in /public/ -> collides with tenant admin routes

Permission resolution priority

1. actor is super_admin            -> ALLOW (always audit)
2. user_permissions.denied match   -> DENY
3. user_permissions.granted match  -> ALLOW
4. tenant_role_overrides match     -> ALLOW/DENY per is_enabled
5. role -> permission via template -> ALLOW
6. no match                        -> DENY

Wrong ordering failure mode: if role is checked before user deny, an
explicit revocation never takes effect. Always deny-before-grant at each tier.

Session prefix vs no prefix

One SaaS codebase hosts multiple apps on the same origin  -> prefix required
Only one app on origin AND no shared subdomain sessions   -> prefix optional
SSO / impersonation across apps planned                   -> prefix required

Without a prefix, two SaaS apps on the same host collide in $_SESSION and the
bug only appears in production when both apps are logged in.

Three-panel architecture

+-------------------------------------------------------------+
|                Shared Infrastructure Layer                  |
|  Data (tenant isolated) | Business Logic | Session system   |
+-------------------------------------------------------------+
         |                       |                    |
+--------v--------+    +---------v------+   +---------v-------+
|   /public/      |    |  /adminpanel/  |   |  /memberpanel/  |
| (ROOT)          |    |                |   |                 |
| Tenant Admin    |    |  Super Admin   |   |  End User       |
|  Workspace      |    |  System        |   |  Portal         |
| owner, staff    |    |  super_admin   |   |  member/student |
+-----------------+    +----------------+   +-----------------+

Important: /public/ root is the tenant-admin workspace, not an end-user panel. Confusing the two is the most common mistake.

File layout:

public/
  index.php           # Landing
  sign-in.php         # Login
  dashboard.php       # Tenant admin dashboard
  adminpanel/         # Super admin panel
    includes/
  memberpanel/        # End user portal
    includes/
  includes/           # Shared includes
  assets/

Panel definitions

PanelPathUsersScopeNotes
Tenant Admin/public/owner, staffsingle tenantall queries include tenant_id =?; cannot touch platform config
Super Admin/public/adminpanel/super_admincross-tenanttenant_id may be NULL; every action audited
End User/public/memberpanel/member, student, customer, patientown records within tenantqueries scoped by tenant_id AND user_id

Tenant isolation model

tenant_id rules per user type

User typetenant_id column
super_adminnullable
tenant ownerrequired, NOT NULL
tenant staffrequired, NOT NULL
member / student / customer / patientrequired, NOT NULL

Table pattern

CREATE TABLE students (
    id            BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    tenant_id     BIGINT UNSIGNED NOT NULL,
    first_name    VARCHAR(100) NOT NULL,
    last_name     VARCHAR(100) NOT NULL,
    email         VARCHAR(100),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON DELETE CASCADE,
    INDEX idx_tenant (tenant_id),
    INDEX idx_tenant_email (tenant_id, email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Composite indexes lead with tenant_id. utf8mb4_unicode_ci everywhere. Match file case exactly (Linux file systems are case-sensitive).

Query enforcement

// Extract tenant from session/JWT. Never from client input.
$tenantId = getSession('tenant_id');

// Regular users: filter by tenant_id
$stmt = $db->prepare('SELECT * FROM students WHERE tenant_id = ? AND id = ?');
$stmt->execute([$tenantId, $studentId]);

// Super admin: cross-tenant access is allowed but always audited
if (getSession('user_type') === 'super_admin') {
    auditLog('CROSS_TENANT_ACCESS', [
        'admin_user_id'      => getSession('user_id'),
        'target_tenant_id'   => $requestedTenantId,
        'action'             => 'VIEW_STUDENTS',
        'justification'      => $request['justification'] ?? null,
    ]);
}

Session and JWT plan

Session prefix system

define('SESSION_PREFIX', 'saas_app_');  // e.g. 'school_', 'restaurant_'

setSession('user_id', $userId);      // writes $_SESSION['saas_app_user_id']
$userId = getSession('user_id');     // reads $_SESSION['saas_app_user_id']

Session cookie settings

SettingValue
HttpOnlytrue
Secureauto-detect HTTPS (port 443 or $_SERVER['HTTPS'])
SameSiteStrict
Lifetime30 min idle
Regenerationon login and on privilege change
$isHttps = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
    || (int) $_SERVER['SERVER_PORT'] === 443;
ini_set('session.cookie_secure', $isHttps ? '1' : '0');

JWT for mobile and API

SettingValue
Access token lifetime15 min
Refresh token lifetime30 days
Rotationon every refresh
Revocationpersisted table keyed by jti

Permission model

Priority (highest first): user deny > user grant > tenant override > role permission > default deny. See references/permission-model.md for full schema, resolution algorithm, caching strategy, and seed data.

function hasPermission(userId, tenantId, permission) {
  if (user.type === 'super_admin') {
    auditLog('PERMISSION_BYPASS', { userId, permission });
    return true;
  }
  if (userPermissions.denied(userId, tenantId, permission)) return false;
  if (userPermissions.granted(userId, tenantId, permission)) return true;
  for (const role of getUserRoles(userId, tenantId)) {
    const override = tenantRoleOverride(tenantId, role.id, permission);
    if (override !== null) return override.isEnabled;
    if (roleHasPermission(role, permission)) return true;
  }
  return false; // default deny
}

Zero-trust checklist

  • tenant_id in every query on a tenant-scoped table (except super_admin with audit).
  • Prepared statements only — no string concatenation into SQL.
  • Permission check before every mutating operation.
  • MFA required for super-admin access.
  • Passwords stored as Argon2ID with per-user salt (32 chars) and server-wide pepper (64+ chars).
  • Account lockout after 5 failed attempts with exponential backoff.
  • Rate limiting: tenant 1000 req/min, user 100 req/min.
  • HTTPS + HSTS on all panels.
  • Super-admin actions audited with justification.
  • Cross-tenant access returns 404, not 403.

API design

# Tenant-scoped (default)
GET    /api/v1/orders          # list within tenant
POST   /api/v1/orders          # create within tenant
GET    /api/v1/orders/{id}     # show; 404 if wrong tenant
DELETE /api/v1/orders/{id}     # delete; 404 if wrong tenant

# Super admin (cross-tenant, audited)
GET    /api/v1/admin/tenants
POST   /api/v1/admin/impersonate

Response envelope:

{ "success": true, "data": {}, "meta": { "page": 1, "total": 100 } }

Error envelope:

{ "success": false, "error": { "code": "PERMISSION_DENIED", "message": "..." } }

Audit and compliance

Always audit: all super-admin actions, impersonation, permission changes, tenant creation/suspension, data exports, failed auth, cross-tenant access attempts.

{
  "id": "uuid",
  "timestamp": "2026-04-07T10:30:00Z",
  "actor_user_id": 123,
  "actor_type": "super_admin",
  "action": "IMPERSONATE_USER",
  "target_tenant_id": 456,
  "justification": "Support request #12345",
  "ip_address": "203.0.113.1",
  "changes": { "before": {}, "after": {} }
}

Retention: security logs 1 year, audit trails 7 years, operational logs 90 days.

Monitoring alerts

  • Cross-tenant access attempt (target = zero).
  • Super-admin login from new IP.
  • Failed auth spike > 100/min.
  • Database query without tenant_id on a tenant-scoped table.
  • API error rate > 5%.

Tenant lifecycle

PENDING -> ACTIVE -> SUSPENDED -> ARCHIVED

Archival is reversible until a configured retention cut-off; archived tenants are then hard-deleted via cascade.

Anti-patterns

  • Client-supplied tenant identifier. $franchiseId = $_POST['franchise_id']; — any user can set this to another tenant. Fix: always getSession('tenant_id') or read from the verified JWT claim.
  • Missing tenant scope on a query. SELECT * FROM students WHERE id =? — returns any student across any tenant. Fix: SELECT * FROM students WHERE tenant_id =? AND id =? and treat a missing row as 404.
  • Super-admin mutation without audit. deleteStudent($studentId); run from the super-admin panel with no log. Fix: wrap every super-admin mutation with auditLog('ADMIN_DELETE_STUDENT', [...]) capturing actor, target tenant, and justification.
  • Returning 403 for cross-tenant access. Confirms the resource exists and enables tenant-ID enumeration. Fix: map cross-tenant misses to 404 so the existence of the resource is hidden.
  • tenant_id nullable on a business table. tenant_id BIGINT NULL — allows rows with no owner, which every tenant query then excludes silently. Fix: tenant_id BIGINT UNSIGNED NOT NULL with a foreign key; backfill before flipping NOT NULL.
  • Session keys without a prefix in a multi-app host. Two apps on the same origin overwrite each other's $_SESSION['user_id']. Fix: SESSION_PREFIX per app, always go through setSession() / getSession().
  • Index order (status, tenant_id) instead of (tenant_id, status). Query planner cannot use the composite index to isolate one tenant's slice. Fix: lead every composite index with tenant_id.
  • Big-bang migration of every table at once. Raises rollback risk and produces hours of downtime. Fix: migrate one domain at a time with the six-step pattern in documentation/migration.md and verify no NULL tenant_id before flipping the column to NOT NULL.

Read next

  • database-design-engineering — schema, indexes, migration discipline once the isolation model is chosen.
  • api-design-first — REST conventions, auth model, and error envelope that this skill's panels depend on.
  • vibe-security-skill — threat modelling, abuse cases, and auth/authz matrix that feed this skill.
  • kubernetes-saas-delivery — per-tenant deploy, namespace isolation, and progressive rollout on top of this model.
  • modular-saas-architecture — when the platform also composes pluggable business modules inside the tenancy defined here.
  • mysql-best-practices — MySQL engine-specific execution of the schema patterns here.

References

  • references/database-schema.md — tenant, user, audit, and tenant-scoped table schemas with indexes and partitioning.
  • references/permission-model.md — RBAC schema, permission resolution algorithm, caching, middleware, hierarchical and conditional permissions.
  • documentation/migration.md — adding tenant_id safely, zero-downtime migration, single-to-multi-tenant phases, rollback.

平台分布

Codex

39.7%
按下载量换算162

Claude

28.2%
按下载量换算115

Cursor

19.13%
按下载量换算78

Gemini CLI

8.47%
按下载量换算35

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills