rag-cag-security

rag-cag-security is a skill for Claude Code from jpoutrin/product-forge. It costs 47 tokens per session (473 once invoked), scanned A, original, MIT.

Security guidance for RAG and CAG systems. It explains how to keep each customer’s data separate, restrict document access, and reduce instruction attacks hidden in retrieved text.

In plain words
What is it for?
Use it to design tenant isolation, document permissions, data classification, and safeguards for retrieved context.
Why use it?
It addresses the risk of an AI system returning another customer’s documents or following untrusted instructions from its data.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the rag-cag plugin — 2 skills, 1 agent shipped together

Good fit Use it to design tenant isolation, document permissions, data classification, and safeguards for retrieved context.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jpoutrin/product-forge/rag-cag-security
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add jpoutrin/product-forge --skill rag-cag-security
Clone the repo
git clone --depth 1 https://github.com/jpoutrin/product-forge

Made for: Claude Code.

Or install rag-cag, the plugin that ships this one along with the rest of its 2 skills, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rag-cag-security

README.md
[![agentmods](https://agentmods.dev/badge/skills/jpoutrin/product-forge/rag-cag-security/github.svg)](https://agentmods.dev/skills/jpoutrin/product-forge/rag-cag-security)
Your own site
<a href="https://agentmods.dev/skills/jpoutrin/product-forge/rag-cag-security"><img src="https://agentmods.dev/badge/skills/jpoutrin/product-forge/rag-cag-security/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rag-cag-security

Your own site · 80×15
<a href="https://agentmods.dev/skills/jpoutrin/product-forge/rag-cag-security"><img src="https://agentmods.dev/badge/skills/jpoutrin/product-forge/rag-cag-security.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 473 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00047 $0.00473
Opus 5.5 $0.00019 $0.00189
Sonnet 5.5 $0.00009 $0.00095
Haiku 4.5 $0.00005 $0.00047

Measured 1mo ago against content hash 56b88c8ee6a9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

rag-cag-security scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/rag-cag/skills/rag-cag-security/SKILL.md · 79 lines

What it actually says

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

Level Description Handling
Public Open information No restrictions
Internal Company-only Tenant isolation
Confidential Sensitive Encryption + audit
Restricted Highly sensitive Need-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
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 79 lines · 47 tokens per session scan A 56b88c8ee6a9

Subscribe to this mod's changes

rag-cag-security is a skill published in the GitHub repository jpoutrin/product-forge (16 stars, last pushed 7mo ago), licensed MIT. It adds 47 tokens to every session and 473 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

agent-platform-rag-engine-management

Manage and query Agent Platform RAG Engine Corpora and retrieve grounded contexts using the Google GenAI SDK. Use when listing RAG corpora or files, inspecting a corpus, retrieving contexts, or generating content grounded in a RAG corpus. Do not use for standard database queries (use SQL/Spanner skills), Google…

google/skills · 85 tokens

llm-app-patterns

Production-ready patterns for building LLM applications. Covers RAG pipelines, agent architectures, prompt IDEs, and LLMOps monitoring. Use when designing AI applications, implementing RAG, building agents, or setting up LLM observability.

davila7/claude-code-templates · 54 tokens

9router-embeddings

Generate vector embeddings via 9Router /v1/embeddings using OpenAI / Gemini / Mistral / Voyage / Nvidia / GitHub embedding models for RAG, semantic search, similarity. Use when the user wants embeddings, vectors, RAG, semantic search, or to embed text.

decolua/9router · 66 tokens

similarity-search-patterns

Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.

foryourhealth111-pixel/Vibe-Skills · 30 tokens

embedding-strategies

Select and optimize embedding models for semantic search and RAG applications. Use when choosing embedding models, implementing chunking strategies, or optimizing embedding quality for specific domains.

foryourhealth111-pixel/Vibe-Skills · 37 tokens

edd

Eval-driven development loop for this repo (rag-loop, an aircraft-systems RAG app on LangGraph, OpenAI, Qdrant Cloud, and TruLens). Use when the user wants to run an experiment, inspect feedback metrics, or decide keep-or-reject on a config/prompt change.

truera/trulens · 63 tokens