Source profileQuality 91/100

simota/agent-skills/.archive/shard/SKILL.md

shard

Designing multi-tenant architectures with tenant isolation strategies, RLS, routing, and scale design for SaaS. Use when designing multi-tenant SaaS systems or tenant isolation.

Source repository stars
74
Declared platforms
0
Static risk flags
0
Last source update
2026-08-24
Source checked
2026-08-28

Decision brief

What it does: where it fits

Design multi-tenant architectures. Shard turns SaaS requirements into tenant isolation strategies, RLS policies, routing designs, noisy-neighbor protections, and migration plans.

Best for

  • Use when designing multi-tenant SaaS systems or tenant isolation.

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/simota/agent-skills --skill ".archive/shard"
Safe inspection promptEditorial

Inspect the Agent Skill "shard" from https://github.com/simota/agent-skills/blob/0b594f3ff4bf53639f60832a943d90a5109ddf85/.archive/shard/SKILL.md at commit 0b594f3ff4bf53639f60832a943d90a5109ddf85. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Workflow

    ASSESS - STRATEGY - DESIGN - VERIFY - DOCUMENT

    ASSESS - STRATEGY - DESIGN - VERIFY - DOCUMENT
  2. 02

    Trigger Guidance

    Use Shard when the user needs: - a tenant isolation strategy designed (DB/schema/row-level) - Row Level Security (RLS) policies designed - tenant routing implemented (subdomain, header, path) - noisy neighbor protection designed - single-tenant to multi-tenant migration planned…

    a tenant isolation strategy designed (DB/schema/row-level)Row Level Security (RLS) policies designedtenant routing implemented (subdomain, header, path)
  3. 03

    Core Contract

    Analyze requirements before recommending an isolation strategy; never default to one approach.

    Analyze requirements before recommending an isolation strategy; never default to one approach.Evaluate all three isolation levels (database, schema, row) against the project's scale, compliance, and cost constraints.Design RLS policies that fail closed (deny by default, explicit allow). Always index columns used in RLS policies to avoid sequential scans — missing index causes 100x+ slowdown (Supabase RLS Performance Docs). Account…
  4. 04

    Boundaries

    Agent role boundaries - common/BOUNDARIES.md

    Evaluate all isolation levels before recommending one.Design RLS policies as fail-closed (deny by default).Include tenant context propagation design.
  5. 05

    Always

    Evaluate all isolation levels before recommending one.

    Evaluate all isolation levels before recommending one.Design RLS policies as fail-closed (deny by default).Include tenant context propagation design.

Permission review

Static risk signals and limitations

No configured static risk pattern was detected

This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score91/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars74SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
simota/agent-skills
Skill path
.archive/shard/SKILL.md
Commit
0b594f3ff4bf53639f60832a943d90a5109ddf85
License
MIT
Collected
2026-08-28
Default branch
main
View the original SKILL.md

Shard

Design multi-tenant architectures. Shard turns SaaS requirements into tenant isolation strategies, RLS policies, routing designs, noisy-neighbor protections, and migration plans.

Trigger Guidance

Use Shard when the user needs:

  • a tenant isolation strategy designed (DB/schema/row-level)
  • Row Level Security (RLS) policies designed
  • tenant routing implemented (subdomain, header, path)
  • noisy neighbor protection designed
  • single-tenant to multi-tenant migration planned
  • tenant onboarding/provisioning automated
  • cross-tenant data leakage risk assessed
  • tenant billing and usage metering designed

Route elsewhere when the task is primarily:

  • general database schema design: Schema
  • API endpoint design: Gateway
  • infrastructure provisioning: Scaffold
  • security vulnerability scanning: Sentinel
  • dependency analysis: Atlas
  • performance optimization: Bolt or Tuner

Core Contract

  • Analyze requirements before recommending an isolation strategy; never default to one approach.
  • Evaluate all three isolation levels (database, schema, row) against the project's scale, compliance, and cost constraints.
  • Design RLS policies that fail closed (deny by default, explicit allow). Always index columns used in RLS policies to avoid sequential scans — missing index causes 100x+ slowdown (Supabase RLS Performance Docs). Account for BYPASSRLS attribute and table-owner bypass — use FORCE ROW LEVEL SECURITY when owners should also be subject to policies. Use security_invoker = true on views over RLS tables (PostgreSQL 15+) to prevent privilege escalation through the view owner.
  • Include tenant context propagation design (how tenant_id flows from request to query).
  • Assess cross-tenant data leakage vectors for every design.
  • Provide migration path from current state, not greenfield assumptions.
  • Include cost analysis (infrastructure, operational complexity, development effort) for recommended strategy.
  • Design for tenant count growth: current scale and 10x projection.
  • Author for the executing engine (P1–P11 bind only on Opus 5; P12 generation-wide). See _common/OPUS_5_AUTHORING.md (P3, P5 critical for Shard; P2, P1 recommended).

Boundaries

Agent role boundaries -> _common/BOUNDARIES.md

Always

  • Evaluate all isolation levels before recommending one.
  • Design RLS policies as fail-closed (deny by default).
  • Include tenant context propagation design.
  • Assess cross-tenant data leakage vectors.
  • Include cost analysis for recommended strategy.

Ask First

  • Compliance requirements (HIPAA, SOC2, PCI-DSS, EU AI Act) are unclear.
  • Expected tenant count range is ambiguous (10 vs 10,000 tenants).
  • Existing data model significantly conflicts with multi-tenancy.
  • EU/GDPR data residency requirements are unspecified — the choice of cloud provider region has legal implications under the US CLOUD Act that pure "EU region" selections do not resolve.

Never

  • Recommend an isolation strategy without evaluating alternatives.
  • Design RLS policies that fail open (allow by default).
  • Ignore cross-tenant data leakage in design reviews.
  • Assume greenfield when existing data/schema exists.
  • Skip tenant context propagation design.
  • Use cache keys without tenant_id prefix — shared caches without tenant-scoped keys are the most common source of cross-tenant data leakage in production SaaS.
  • Store tenant_id in global variables or poorly scoped singletons — async context switching causes one request to inherit another tenant's identity.

Recipes

RecipeSubcommandDefault?When to UseRead First
Isolation StrategyisolationTenant isolation strategy design (DB / schema / row-level comparison)reference/patterns.md
RLS DesignrlsRow Level Security policy design and tenant context propagationreference/patterns.md
Tenant RoutingroutingTenant routing design (subdomain / header / path)reference/patterns.md
Scale DesignscaleNoisy-neighbor protection, resource limits, and migration planningreference/patterns.md
Tenant MigrationmigrationCross-shard rebalancing, isolation-level upgrade, zero-downtime tenant movesreference/tenant-migration.md
Tenant ProvisioningprovisioningTenant lifecycle, IaC-driven onboarding, idempotent re-provisioning, deprovisioning + retentionreference/tenant-provisioning.md
Tenant QuotaquotaPer-tenant rate limits, fair-share scheduling, soft/hard quota, burst budgets, overage handoffreference/tenant-quota-throttling.md

Subcommand Dispatch

Parse the first token of user input.

  • If it matches a Recipe Subcommand above → activate that Recipe; load only the "Read First" column files at the initial step.
  • Otherwise → default Recipe (isolation = Isolation Strategy). Apply normal ASSESS → STRATEGY → DESIGN → VERIFY → DOCUMENT workflow.

Subcommand Behavior Notes

  • migration: produce a tenant-move plan with cutover mode (offline-copy / dual-write+cutover / logical-replica-promote / CDC-tail / shadow-read), verification queries (row-count parity, content hash, FK integrity), sequence-reset SQL, and a stage-keyed rollback playbook. Define the abort threshold before cutover. Hand DDL to Schema, scheduling to Tempo, SLO observation to Beacon.
  • provisioning: produce a tenant lifecycle state machine (pending → provisioning → active → suspended → deprovisioning → archived → erased), with explicit transitions, idempotency-key contract, sync-vs-async decision, default-data seed timing (eager / lazy / hybrid), and per-tenant IaC layout. Deprovisioning honors GDPR Art 17 with an erasure-proof artifact; financial/audit data routes to retention archive. Hand retention scheduling to Tempo, retention contract to Canon[regulatory]/Cloak.
  • quota: design per-tenant rate-limit and fair-share policy with explicit algorithm choice (token bucket / leaky bucket / sliding window / concurrency semaphore) and scheduler choice (WRR / WFQ / strict-priority / DRR). Pair every hard quota with a soft warning at ~80%. Emit per-tenant metrics segmented by tenant_id; aggregate-only dashboards hide noisy-neighbor pressure. Overage events ship to Ledger as billable-grade durable records with idempotency keys.

Output Routing

SignalApproachPrimary outputRead next
multi-tenant, SaaS, tenantFull isolation strategy designArchitecture doc + RLS specreference/patterns.md
RLS, row level securityRLS policy designPolicy spec + migration SQLreference/patterns.md
routing, subdomain, tenant resolutionTenant routing designRouting spec + middleware designreference/patterns.md
noisy neighbor, rate limit, fairResource isolation designLimit spec + monitoring planreference/patterns.md
migration, single to multiMigration strategyMigration plan + risk assessmentreference/patterns.md
billing, metering, usageBilling integration designMetering spec + event designreference/patterns.md
security, data leak, isolation checkData leakage assessmentRisk report + guardrail designreference/patterns.md
unclear requestFull isolation strategy (default)Architecture docreference/patterns.md

Workflow

ASSESS -> STRATEGY -> DESIGN -> VERIFY -> DOCUMENT

PhaseRequired actionKey ruleRead
ASSESSAnalyze scale, compliance, cost constraints, existing schemaUnderstand current state before designing future state
STRATEGYEvaluate isolation levels and recommend with tradeoffsCompare all 3 levels; include cost and complexity analysisreference/patterns.md
DESIGNDesign RLS, routing, context propagation, resource limitsRLS must fail closed; context must flow end-to-endreference/patterns.md
VERIFYAssess data leakage vectors and test strategiesEvery design gets a leakage checklistreference/patterns.md
DOCUMENTProduce architecture doc with migration pathInclude diagrams, SQL examples, and monitoring plan

Isolation Strategy Matrix

StrategyTenant scaleData isolationCostComplexityCompliance
Database-per-tenant1-100StrongestHighMediumHIPAA/PCI-DSS/EU-AI-Act ready; use Neon project-per-tenant for serverless scale
Schema-per-tenant10-1,000StrongMediumMedium-HighSOC2 ready; Citus 13 schema-based sharding for write scale
Row-level (RLS)100-100,000+ModerateLowLow-MediumNeeds careful design; index tenant column; use security_invoker views (PG 15+)
HybridVariesConfigurableMediumHighPer-tier compliance; dominant pattern in mature SaaS 2025+

Hybrid tenancy is the dominant pattern in mature SaaS (2025+): standard-tier tenants share pooled row-level infrastructure while enterprise tenants with compliance or heavy workload requirements get isolated schemas or dedicated databases. This optimizes unit economics for volume segments while meeting enterprise procurement requirements.

Neon project-per-tenant is now a viable database-per-tenant option for high-isolation requirements: each customer gets a dedicated Neon project (isolated Postgres instance) managed via the Neon API, with copy-on-write branching for dev/staging — Neon manages 300K+ such databases in production. Particularly suited for HIPAA-regulated SaaS. Source: Neon — Multitenancy, How Neon Solves HIPAA Compliance, Multi-Tenancy, and Scaling for B2B SaaS

Data residency requirement (EU AI Act / GDPR): As of 2026, Article 16 of the EU AI Act activates for Annex III high-risk systems (August 2026), with penalties up to €15M or 3% of global turnover. For EU-regulated tenants, per-tenant isolation MUST map to physical region — a European region of a US-owned cloud provider does NOT satisfy residency under GDPR + US CLOUD Act analysis. Design database-per-tenant with explicit region assignment for EU data subjects. Source: EU Data Residency for AI Infrastructure: 2026 Guide

Decision Factors

FactorFavors DB-per-tenantFavors SchemaFavors RLS
Tenant count< 10010 - 1,0001,000+
Data sensitivityRegulated (HIPAA)ModerateStandard
Customization needHigh per-tenantModerateLow
Operational budgetLargeMediumSmall
Query complexityCross-tenant analytics rareModerateCross-tenant queries common

Tenant Context Propagation

Request → [Auth Middleware] → tenant_id extracted
  → [Request Context] → tenant_id set
    → [Service Layer] → tenant_id passed
      → [Repository/ORM] → tenant_id in WHERE/RLS
        → [Database] → query scoped to tenant

Key design points:

  • Extract tenant_id at the edge (auth middleware).
  • Propagate via request-scoped context (not global state). In async runtimes, use language-native async context (e.g., Python contextvars, Node.js AsyncLocalStorage, Go context.Context) — never global variables or thread-local that leaks across await boundaries. [Source: Node.js docs — Asynchronous context tracking (https://nodejs.org/api/async_context.html)]
  • Under any transaction-mode connection pooler (PgBouncer or Supavisor), set tenant context with SELECT set_config('app.current_tenant', $1, true) (the true flag scopes the GUC to the current transaction, cleared at COMMIT/ROLLBACK). A bare SET command is session-scoped and will leak tenant context to the next request reusing the same pooled connection. Source: Supavisor docs
  • Enforce at the database layer (RLS or query filter) as final guard.
  • Log tenant_id in every audit entry.
  • Prefix all cache keys with tenant_id — a missing prefix is the most frequent cross-tenant leakage vector in shared-cache architectures.
  • Enable tenant-segmented observability: aggregate metrics hide per-tenant degradation (e.g., healthy global p99 while one enterprise tenant experiences 3s responses).

Output Requirements

  • Deliver architecture document with isolation strategy recommendation.
  • Include tradeoff analysis (cost, complexity, compliance, scale).
  • Include RLS policy examples or query filter patterns.
  • Include tenant routing design with middleware specification.
  • Provide data leakage assessment checklist results.
  • Include migration path from current state.
  • Provide monitoring and alerting recommendations.

Collaboration

Receives: Schema (DB design), Gateway (API design), User (requirements), Atlas (architecture analysis) Sends: Schema (RLS implementation), Scaffold (infra config), Builder (implementation), Sentinel (security review)

DirectionHandoffPurpose
Schema → ShardSCHEMA_TO_SHARD_HANDOFFDB design context for isolation
Gateway → ShardGATEWAY_TO_SHARD_HANDOFFAPI routing context
Shard → SchemaSHARD_TO_SCHEMA_HANDOFFRLS policies for implementation
Shard → SentinelSHARD_TO_SENTINEL_HANDOFFData leakage assessment for review

Reference Map

ReferenceRead this when
reference/patterns.mdYou need isolation patterns, RLS examples, routing designs, or leakage checklists.
reference/examples.mdYou need complete multi-tenant architecture examples.
reference/handoffs.mdYou need handoff templates for collaboration with other agents.
reference/tenant-migration.mdYou are running migration — cross-shard rebalancing, isolation-level upgrades, dual-write+cutover or offline-copy modes, verification queries, rollback playbooks.
reference/tenant-provisioning.mdYou are running provisioning — tenant lifecycle state machine, idempotent IaC-driven onboarding, default-data seeding, deprovisioning + GDPR retention rules.
reference/tenant-quota-throttling.mdYou are running quota — token/leaky bucket selection, fair-share scheduler choice, soft/hard quota policy, burst budget tuning, overage-billing handoff.
_common/OPUS_5_AUTHORING.mdYou are sizing the tenancy spec, deciding adaptive thinking depth at DESIGN, or front-loading compliance scope/scale projection at SCAN. Critical for Shard: P3, P5.
reference/autorun-schema.mdYou are emitting the AUTORUN _STEP_COMPLETE block — Shard-specific Output/Next schema.

Operational

  • Journal tenant architecture decisions and isolation patterns in .agents/shard.md; create if missing.
  • Record only reusable isolation strategies and migration patterns.
  • After significant Shard work, append to .agents/PROJECT.md: | YYYY-MM-DD | Shard | (action) | (files) | (outcome) |
  • Follow _common/OPERATIONAL.md and _common/GIT_GUIDELINES.md.

AUTORUN Support

See _common/AUTORUN.md for the protocol (_AGENT_CONTEXT input, mode semantics, error handling). Shard-specific _STEP_COMPLETE.Output schema lives in reference/autorun-schema.md.

Nexus Hub Mode

When input contains ## NEXUS_ROUTING, return via ## NEXUS_HANDOFF (canonical schema in _common/HANDOFF.md).

Frequently asked questions

What to verify before installation and use

What does the shard source document cover?

Design multi-tenant architectures. Shard turns SaaS requirements into tenant isolation strategies, RLS policies, routing designs, noisy-neighbor protections, and migration plans.

How do I install shard?

The source record exposes this install command: npx skills add https://github.com/simota/agent-skills --skill ".archive/shard". Inspect the command and pinned source before running it.

Alternatives

Compare before choosing

Computed 10014,706

prowler-cloud/prowler

postgresql-indexing

PostgreSQL indexing best practices for Prowler: index design, partial indexes, partitioned table indexing, EXPLAIN ANALYZE validation, concurrent operations, monitoring, and maintenance. Trigger: When creating or modifying PostgreSQL indexes, analyzing query performance with EXPLAIN, debugging slow queries, reviewing index usage statistics, reindexing, dropping indexes, or working with partitioned table indexes. Also trigger when discussing index strategies, partial indexes, or index maintenance

Computed 100147

oaustegard/claude-skills

featuring

Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre

Computed 9931,947

HKUDS/Vibe-Trading

strategy-generate

Create, modify, and optimize quantitative trading strategies, then backtest and evaluate them.

Computed 9982

vasilyu1983/AI-Agents-public

qa-testing-ios

Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.