Back to list
jpoutrin

rag-cag-security

by jpoutrin

Claude Code Marketplace Plugin to dev like a pro in a multi-agent fashion

4🍴 0📅 Jan 22, 2026

SKILL.md


name: rag-cag-security description: Security patterns for RAG and CAG systems with multi-tenant isolation. Use when building retrieval-augmented or cache-augmented generation systems that require tenant isolation, access control, and secure data handling.

RAG/CAG Security Skill

This skill provides security patterns for RAG and CAG systems.

Multi-Tenant Architecture

Tenant Isolation Strategies

  1. Namespace Isolation - Separate vector namespaces per tenant
  2. Metadata Filtering - Filter by tenant_id at query time
  3. Separate Collections - Isolated collections per tenant
# Metadata filtering approach
results = vector_store.similarity_search(
    query,
    filter={"tenant_id": current_user.tenant_id}
)

Access Control

Document-Level Permissions

@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
    )

Prompt Injection Prevention

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)

Data Classification

LevelDescriptionHandling
PublicOpen informationNo restrictions
InternalCompany-onlyTenant isolation
ConfidentialSensitiveEncryption + audit
RestrictedHighly sensitiveNeed-to-know basis

Security Checklist

  • Tenant isolation implemented
  • Document-level access control
  • Retrieved content sanitized
  • Audit logging enabled
  • Data encryption at rest
  • Secure API authentication

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon