Skip to main content
skill Claude Code Gemini CLI CX Codex official · Google

agent-platform-rag-engine-management — Claude Code skill

Use this skill to inspect Agent Platform RAG Engine corpora, find their files, retrieve context, and draft grounded answers. It fits workflows built around RAG Engine in Google Cloud.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add google/skills --skill agent-platform-rag-engine-management -a claude-code
Open on GitHub

What agent-platform-rag-engine-management does

The skill uses the vertexai Python SDK to work with Agent Platform RAG Engine. It can list corpora and files, inspect a corpus, retrieve context for a query, and help generate an answer grounded in that corpus. It is not meant for standard database queries.

You need Google Cloud credentials with Application Default Credentials configured. The environment also needs google-cloud-aiplatform and google-genai; install them with pip if they are missing. Grounded content generation requires a separate confirmation that names the target corpus, model, and query.

Install it when your task involves Agent Platform RAG Engine. For Google Workspace RAG, gRAG, SQL, or Spanner queries, use a different tool.

What it helps with

  • find RAG Engine corpora in a project
  • inspect the files stored in a corpus
  • retrieve context for a question
  • draft an answer grounded in a corpus

Example prompts for the agent

  • List the Agent Platform RAG Engine corpora in my project.
  • Show me the files in this corpus and their names.
  • Retrieve context about remote work policies from this corpus.

How to install agent-platform-rag-engine-management

1Skills CLI (Vercel)

npx skills add google/skills --skill agent-platform-rag-engine-management -a claude-code

2Manually: put the files in place

~/.claude/skills/agent-platform-rag-engine-management/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/agent-platform-rag-engine-management/

From the same set172

The whole set →
bigquery-basics official google Manages BigQuery resources and runs SQL queries. Use it to create datasets, tables and views, or handle basic data ingestion and analysis. Claude Code Gemini CLI CX Codex 17,678installs cloud-run-basics official google This skill helps an agent manage Cloud Run services, jobs, and worker pools when a project needs HTTP deployment, scheduled work, or pull-based background processing. Claude Code Gemini CLI CX Codex 17,532installs gemini-api official google Connects Gemini API from Google Cloud Agent Platform to the agent. Gives access to Gemini models, multimodal input, function calling, and context caching. Claude Code Gemini CLI CX Codex 17,116installs google-cloud-recipe-auth official Google LLC This skill explains Google Cloud authentication and permissions. Use it when setting up IAM, ADC, or service accounts for local code and production workloads. Claude Code Gemini CLI CX Codex 15,450installs google-cloud-recipe-onboarding official Google LLC Guides a developer through a first Google Cloud project: CLI checks, sign-in, project setup and billing. It fits a personal first project. Claude Code Gemini CLI CX Codex 15,390installs cloud-sql-basics official google This skill helps create and explain Cloud SQL resources for MySQL, PostgreSQL, and SQL Server. Use it when setting up a database in Google Cloud. Claude Code Gemini CLI CX Codex 14,679installs google-cloud-waf-security official google This skill reviews Google Cloud workloads against the security pillar of the Well-Architected Framework and suggests actions for IAM, networks, data, and operations. Claude Code Gemini CLI CX Codex 14,620installs google-cloud-waf-cost-optimization official google Reviews Google Cloud workloads through the Well-Architected Cost Optimization pillar. Use it to inspect spending, resize resources, assess discounts, or find idle capacity. Claude Code Gemini CLI CX Codex 14,266installs

Similar

course-guide rohitg00 Finds AI Engineering from Scratch lessons for a topic, question, or bug and suggests a next action. Use it when you need a course route for what you are learning. Claude Code CX Codex Cursor +1 4,100installs core vercel-labs Defines the schema and component catalog for json-render and builds the system prompt that makes an AI emit JSON UI specs. Claude Code CX Codex Cursor +1 15,000installs python-mcp-server-generator official github Builds Python MCP servers that expose functions, APIs, or databases as tools for AI clients. Use it when starting a server with MCP Python SDK v2. GitHub Copilot 10,418installs skill-creator official anthropics Creates and refines skills, then tests them with prompts, evaluations, and performance checks. Claude Code Claude.ai 414,180installs writing-for-agents Matt Pocock Guidance for writing skills and agent-facing documents. Use it when editing AGENTS.md, CLAUDE.md, or reference files reached from them. Claude Code 466,719installs media-use heygen-com Finds or generates media for HyperFrames videos, including voiceovers, music, cutouts, and color grades. Stores files locally in assets. Claude Code CX Codex Cursor +1 1,100,000installs mcp-builder official anthropics This skill walks through building an MCP server in TypeScript or Python, from reading the protocol spec to writing tests and evaluation questions. Claude Code Claude.ai 130,949installs subagent-driven-development Jesse Vincent This skill runs an implementation plan through fresh subagents for independent tasks and reviews each result. Use it for multi-step work in one session. Claude Code CX Codex 237,746installs

Questions about agent-platform-rag-engine-management

How do I install agent-platform-rag-engine-management in Claude Code?

Run npx skills add google/skills --skill agent-platform-rag-engine-management -a claude-code.

What does agent-platform-rag-engine-management do?

It uses the vertexai Python SDK to list and inspect Agent Platform RAG Engine corpora, find files, retrieve context, and prepare grounded answers.

What does the skill need to run?

Configure Google Cloud credentials and Application Default Credentials, and make google-cloud-aiplatform and google-genai available. Grounded content generation also needs explicit confirmation.

Source text

SKILL.md · Apache-2.0
---
name: agent-platform-rag-engine-management
metadata:
  version: "1.0.1"
  category: AiAndMachineLearning
description: >-
  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 Workspace RAG, or other RAG products like gRAG.
---

# Agent Platform RAG Engine Management

This skill provides instructions on how to interact with Agent Platform RAG
Engine using the Agent Platform Python SDK. You MUST use the `vertexai` Python
SDK to perform RAG Engine operations, rather than raw REST calls or MCP tools,
because this code is intended to be run by external clients.

## Safety & Confirmation Tiers (CRITICAL)

Before executing any commands or scripts on behalf of the user, you must adhere
to the following safety tiers based on the action requested:

1.  **Tier R: Read-only (`list_corpora`, `list_files`, `get_corpus`,
    `retrieval_query`)**
    *   No confirmation needed. Execute immediately to gather information or
        retrieve grounded contexts.
2.  **Tier RC: Read-only but consumes Compute Resources
    (`client.models.generate_content`)**

    *   Requires **interactive confirmation** with 'Yes'/'No' options before
        executing grounded content generation. The confirmation prompt MUST
        clearly explain the proposed generation execution and its key parameters
        (e.g., target corpus ID, query text, target model). Natural-language
        paraphrases without specifying exact parameters are insufficient, as
        explicit parameter listing is required to ensure unambiguous user
        approval of the specific resource and configuration.
    *   **Same-turn restriction**: Do not execute the generation code in the
        same turn as presenting the confirmation prompt. Stop and wait for the
        user's reply; only execute after explicit 'Yes' / approval.
    *   **Gold Standard Example**:

        > I will perform grounded content generation with the following
        > parameters. Please confirm this information before I proceed:
        >
        > *   **Target Corpus ID**: `projects/123/locations/us/ragCorpora/abc`
        > *   **Target Model**: `gemini-2.5-pro`
        > *   **Query Text**: "What are the company policies on remote work?"
        >
        > Do you confirm? [Yes/No]

## Phase 0: Environment Setup

**CRITICAL**: Before running any of the Python snippets below, you must ensure
the environment is correctly initialized by following these steps:

1.  **Google Cloud Authentication**: Authenticate with your Google Cloud
    credentials and configure active Application Default Credentials (ADC) for
    Agent Platform access:

    ```bash
    gcloud auth login
    gcloud auth application-default login
    ```

2.  **Python Dependencies**: This skill needs `google-cloud-aiplatform` and
    `google-genai`, which the sandbox already provides. Do **not** create a
    virtual environment — it starts empty and hides packages the environment
    already provides, forcing a redundant install. Do not spend a separate
    command checking for them: run the snippet directly, and only if it fails
    with `ModuleNotFoundError`, install in the same command as the retry:

    ```bash
    pip install -q google-cloud-aiplatform google-genai && python3 - <<'PY'
    ...
    PY
    ```

3.  **Execution**: Run each snippet as a quoted heredoc, `python3 - <<'PY'` ...
    `PY`, rather than `python3 -c '...'`, whose nested quotes break easily.
    There is no environment to activate first. When one step needs several of
    the snippets below (for example, list the corpora and then the files in
    each), combine them into one script and one command. The
    `vertexai.preview.rag` deprecation warning printed on stderr is expected;
    keep using these snippets rather than switching clients because of it.

## Workflow Decision Tree

1.  **Information Gathering**: Has the user provided the Project ID, Region, and
    Corpus ID?

    *   **No** -> Proceed to [1. Listing Corpora and Files] to discover the
        necessary Resource Names and IDs. Only ask the user if discovery fails.
    *   **Yes** -> Proceed.

2.  **Task Type**: What does the user want to do?

    *   **List Corpora and Files** -> Proceed to [1. Listing Corpora and Files].
    *   **Inspect a Corpus** -> Proceed to [2. Getting / Inspecting a RAG Engine
        Corpus].
    *   **Search for Contexts** -> Proceed to [3. Retrieving Contexts].
    *   **Answer questions using RAG Engine** -> Proceed to [4. Answering the
        User with Retrieved Context].

> [!TIP]
>
> **Placeholder Parameter Replacement:** The Python scripts below use bracketed
> string placeholders (like `"{project_id}"`, `"{region}"`, and
> `"{corpus_id}"`). You **MUST** dynamically replace these placeholders with the
> actual Project ID, Region, and Corpus ID values provided in the user's prompt
> (or active context) before generating, providing, or executing the scripts.

## 1. Listing Corpora and Files (Discovery)

If you do not know the Resource Name of the corpus or file, you MUST list them
first to discover them. The SDK handles pagination automatically when converted
to a list, but you can also use manual pagination for large sets.

### 1.1 Listing and Discovering Corpora

```python
import vertexai
from vertexai.preview import rag

vertexai.init(project="{project_id}", location="{region}")

# Approach A: List ALL (Automatic Pagination)
# The SDK's Pager iterates through all pages for you.
all_corpora = list(rag.list_corpora())
print(f"Found {len(all_corpora)} corpora in total.")
for c in all_corpora:
    print(f"Corpus Name: {c.name} | Display Name: {c.display_name}")

# Approach B: Manual Pagination (for very large projects)
pager = rag.list_corpora(page_size=10)
# Process first page
for c in pager:
    print(f"Corpus: {c.display_name}")

# Get next page if needed
if pager.next_page_token:
    second_page = rag.list_corpora(
        page_size=10, page_token=pager.next_page_token
    )
```

### 1.2 Listing and Discovering Files

To understand what files (and types) are in a corpus, list them and inspect the
`display_name` (usually includes the extension).

```python
import vertexai
from vertexai.preview import rag

vertexai.init(project="{project_id}", location="{region}")
corpus_name = (
    "projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)

# List files with automatic pagination
files = list(rag.list_files(corpus_name=corpus_name))
print(f"Found {len(files)} files.")

for f in files:
    # High-level SDK RagFile objects usually have name, display_name,
    # description
    print(f"File: {f.display_name} | Resource: {f.name}")
    # Tip: Check extension to understand file type (PDF, TXT, etc.)
    if f.display_name.lower().endswith(".pdf"):
        print("  Type: PDF")
    elif f.display_name.lower().endswith(".txt"):
        print("  Type: Plain Text")
```

## 2. Getting / Inspecting an Agent Platform RAG Engine Corpus

To retrieve details about an existing Agent Platform RAG Engine corpus:

```python
import vertexai
from vertexai.preview import rag

vertexai.init(project="{project_id}", location="{region}")

# To get details of a specific corpus
corpus_name = (
    "projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)
corpus = rag.get_corpus(name=corpus_name)
print(f"Corpus Name: {corpus.name}")
print(f"Display Name: {corpus.display_name}")
```

## 3. Retrieving Contexts

To retrieve relevant contexts from a RAG Engine corpus based on a query. If no
contexts come back, that is a valid answer: report it with the corpus and query
you used. If a broader search is reasonable, try it in the same script (for
example a larger `similarity_top_k`) rather than as a separate command.

```python
import vertexai
from vertexai.preview import rag

vertexai.init(project="{project_id}", location="{region}")

corpus_name = (
    "projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)
query = "What is the speed of light?"

# Retrieve contexts
response = rag.retrieval_query(
    rag_corpora=[corpus_name],
    text=query,
    similarity_top_k=3
)

for context in response.contexts.contexts:
    print(f"Context text: {context.text}")
    print(f"Source: {context.source_uri}")
```

## 4. Answering the User with Retrieved Context

To use the retrieved context alongside an Agent Platform model to generate a
grounded response:

```python
from google import genai
from google.genai import types

client = genai.Client(enterprise=True, project="{project_id}", location="{region}")
corpus_name = (
    "projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)

# Define the Agent Platform RAG Engine tool pointing to the corpus
rag_tool = types.Tool(
    retrieval=types.Retrieval(
        vertex_rag_store=types.VertexRagStore(
            rag_resources=[types.VertexRagStoreRagResource(rag_corpus=corpus_name)],
            rag_retrieval_config=types.RagRetrievalConfig(
                top_k=3,
                filter=types.RagRetrievalConfigFilter(
                    vector_similarity_threshold=0.5,
                ),
            ),
        )
    )
)

# Generate content using the RAG Engine tool
response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="What is the speed of light?",
    config=types.GenerateContentConfig(
        tools=[rag_tool]
    )
)
print(response.text)
```

© google · Apache-2.0 · google/skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor