Works with the AI Agents you already use
Pinia Tenant Guard
Enforce strict data isolation and prevent state bleeding in multi-tenant Vue 3 and Pinia applications.
$9.90
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
- Register the
clearStatemethod in your globalswitchTenantaction. - Update the calling component to use
useTenantWatchinstead ofonMounted. - Verify that your backend API validates the
tenant_idparameter 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
onMountedfetches 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
- Audit phase: Scan your existing Pinia stores and Vue components for "State Bleeding" vulnerabilities and lifecycle anti-patterns.
- Contract enforcement: Implement the
clearStateaction in every domain store to flush caches before context shifts. - Reactive refactoring: Replace static data calls with the
useTenantWatchpattern to handle workspace switching instantly. - Resilience check: Wrap all asynchronous store operations in strict
try/catch/finallyblocks 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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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