tenant-context-guide

Community

Maintain tenant context across requests

Authoronairmarc
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Developers often lose track of the tenant context in multi-tenant Laravel apps, leading to inconsistent data access or leaks.

Core Features & Use Cases

  • Automatic context propagation: Tenant context is resolved once and persisted across the request or job lifecycle.
  • Context switching in loops: Use TenantContext::applyById($tenantId, true) when iterating over multi-tenant records to switch context safely.
  • Safe default behavior: Avoid forgetting Context::forget by adhering to the recommended usage.
  • Use cases include middleware-initiated requests, queued jobs, and batch processing across tenants.

Quick Start

Switch to a tenant's context inside a loop using TenantContext::applyById($tenantId, true) before performing tenant-scoped work.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: tenant-context-guide
Download link: https://github.com/onairmarc/dotfiles/archive/main.zip#tenant-context-guide

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.