From rag-cag
Provides security patterns for RAG/CAG systems including multi-tenant isolation strategies, document-level access control, prompt injection prevention, data classification, and checklists. Use for secure retrieval- or cache-augmented generation with tenant isolation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rag-cag:rag-cag-securityThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill provides security patterns for RAG and CAG systems.
This skill provides security patterns for RAG and CAG systems.
# Metadata filtering approach
results = vector_store.similarity_search(
query,
filter={"tenant_id": current_user.tenant_id}
)
@dataclass
class Document:
id: str
content: str
tenant_id: str
access_groups: list[str]
classification: str # public, internal, confidential
def can_access(user: User, doc: Document) -> bool:
return (
user.tenant_id == doc.tenant_id
and any(g in doc.access_groups for g in user.groups)
and user.clearance >= doc.classification
)
def sanitize_retrieved_context(chunks: list[str]) -> str:
"""Sanitize retrieved chunks before including in prompt."""
sanitized = []
for chunk in chunks:
# Remove potential instruction patterns
cleaned = remove_instruction_patterns(chunk)
# Escape special characters
escaped = escape_prompt_chars(cleaned)
sanitized.append(escaped)
return "\n".join(sanitized)
| Level | Description | Handling |
|---|---|---|
| Public | Open information | No restrictions |
| Internal | Company-only | Tenant isolation |
| Confidential | Sensitive | Encryption + audit |
| Restricted | Highly sensitive | Need-to-know basis |
npx claudepluginhub jpoutrin/product-forge --plugin rag-cagGuides securing RAG system data against unauthorized access, modification, and poisoning. Covers access control, encryption, integrity verification, and audit logging for vector databases and knowledge stores.
Detects RAG pipelines that ingest external documents into LLM context without sanitization or trust gating. Flag vulnerable patterns like direct concatenation, unbounded retrieval, and SSRF-through-fetch.
Enforces 5-layer security for MCP servers and multi-agent pipelines: input validation, prompt injection prevention, SQL/NoSQL validation, user context propagation, and RBAC/ABAC authorization.