Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Pinia Tenant Guard

    1

    Enforce strict data isolation and prevent state bleeding in multi-tenant Vue 3 and Pinia applications.

    $9.90

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Pinia Tenant Guard

    Pinia Tenant Guard

    Example session with this skill installed

    Audit my Pinia store for multi-tenant safety. It has an async fetchData function that sets loading to true, fetches from /api/items, and sets loading to false after the await.

    • Read your context and instructions
    • Compiled the pinia tenant guard

    I have audited your Pinia store. The current implementation violates

    Invariant 3 (Asynchronous Release Law) because it lacks a finally block, which will deadlock the UI if the API call fails. It also lacks a clearState action required by

    Invariant 2.

    Refactored Pinia Store

    import { ref } from 'vue'
    import { defineStore } from 'pinia'
    import { useTenantStore } from './tenantStore'
    
    export const useItemStore = defineStore('items', () => {
      const items = ref([])
      const loading = ref(false)
      const error = ref<string | null>(null)
      const tenantStore = useTenantStore()
    
      /**
       * INVARIANT 2: Universal Pre-Mutation Cache Invalidation
       * Essential to prevent State Bleeding during tenant transitions.
       */
      function clearState() {
        items.value = []
        loading.value = false
        error.value = null
      }
    
      /**
       * INVARIANT 3 & 4: Secure Async Pattern
       * Uses finally for deadlock prevention and explicit tenant filtering.
       */
      async function fetchData() {
        const tenantId = tenantStore.currentTenantId
        if (!tenantId) return
    
        loading.value = true
        error.value = null
    
        try {
          // Explicit tenant_id injection
          const { data } = await api.get('/items', { 
            params: { tenant_id: tenantId } 
          })
          items.value = data
        } catch (err: any) {
          error.value = err.message || 'Failed to fetch items'
          items.value = []
          throw err
        } finally {
          // Guaranteed release of UI spinners/buttons
          loading.value = false
        }
      }
    
      return { items, loading, error, fetchData, clearState }
    })
    

    Next steps

    1. Register the clearState method in your global switchTenant action.
    2. Update the calling component to use useTenantWatch instead of onMounted.
    3. Verify that your backend API validates the tenant_id parameter against the authenticated user's session.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Building multi-tenant B2B SaaS applications in Vue 3 exposes you to critical state management risks. Without strict isolation, sensitive data from one client account can "bleed" into the view of another during tenant switching. Standard lifecycle hooks like onMounted often fail to update when a global tenant ID changes, leading to stale data displays and broken UI states.

    What it does

    • Enforces State Isolation by mandating pre-mutation cache invalidation to prevent cross-tenant data leaks.
    • Automates Reactivity by replacing static onMounted fetches with reactive observers that trigger on tenant ID mutations.
    • Prevents UI Deadlocks through mandatory async release patterns that ensure loading states always resolve even on network failure.
    • Audits Query Payloads to ensure every database mutation and fetch explicitly includes the active tenant ID.
    • Optimizes Network Usage by preventing batch fetches of background views, focusing resources only on the active component.

    How it works

    1. Audit phase: Scan your existing Pinia stores and Vue components for "State Bleeding" vulnerabilities and lifecycle anti-patterns.
    2. Contract enforcement: Implement the clearState action in every domain store to flush caches before context shifts.
    3. Reactive refactoring: Replace static data calls with the useTenantWatch pattern to handle workspace switching instantly.
    4. Resilience check: Wrap all asynchronous store operations in strict try/catch/finally blocks to guarantee UI recovery.

    Frameworks & tools

    Specifically designed for Vue 3 (Composition API) and Pinia. Works with TypeScript-heavy SaaS architectures and applications using global tenant switchers or route-based multi-tenancy.

    Why this beats prompting it yourself

    Generic AI assistants often suggest onMounted for initial data fetching, which is a functional failure in multi-tenant environments. This skill applies a specific "Zero-Bleed Manifesto" that generic coding prompts ignore, ensuring your state management is architected for security rather than just convenience.

    Use cases

    • Multi-Tenant SaaS: Prevent Account Managers from seeing Data A while switching to Workspace B.
    • Franchise Dashboards: Ensure local operators only view and edit their specific store data.
    • Superadmin Portals: Allow seamless switching between client accounts without hard refreshes or stale data flickers.
    • Error-Prone APIs: Recover UI states automatically when tenant-scoped network requests time out or fail.

    Known limitations

    Does not provide backend-level Row Level Security (RLS) configurations. Requires the application to use the Vue 3 Composition API and Pinia.

    Requires Vue 3 Composition API and Pinia. Does not implement backend RLS or database-level isolation logic. Primary focus is frontend architectural safety.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 20 days ago

    Permissions

    Terminal / Shell
    Network Access
    Listed20 days ago
    Updated19 days ago

    What's inside

    Frequently Asked Questions

    This skill automates the implementation of a 'Zero-Bleed' architecture, replacing fragile lifecycle hooks with reactive observers and enforcing mandatory cache clearing to ensure data from one tenant never persists when switching to another.

    It is optimized for Vue 3 using the Composition API and Pinia state management; it is compatible with most modern AI coding agents that support multi-file refactoring and TypeScript.

    The skill includes a comprehensive audit pattern to identify vulnerabilities, a library of reactive 'TenantWatch' patterns for your components, and a standardized resilience framework for handling async store operations.

    No, this skill focuses strictly on front-end state isolation and UI resilience; you must still implement Row Level Security (RLS) or equivalent tenant-scoping on your backend API.

    Unlike generic prompts, this skill enforces a strict contract-based approach to state management that handles the complex edge cases of workspace switching that standard 'onMounted' patterns miss.

    New in Security