/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
$ npx -y skills add google/skills --skill agent-platform-rag-engine-management --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/agent-platform-rag-engine-management
Context preview
The summary Claude sees to decide when to auto-load this skill.
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
SKILL.md
agent-platform-rag-engine-management.SKILL.mdname: agent-platform-rag-engine-management
metadata:
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:
gcloud auth login
gcloud auth application-default login2. **Virtual Environment**: Create and activate a dedicated virtual environment:
python3 -m venv ~/rag_agent_venv
source ~/rag_agent_venv/bin/activate3. **Install Dependencies**: Install the required Agent Platform SDKs:
pip install google-cloud-aiplatform google-genai
4. **Execution**: Advise the user that every time they execute a Python snippet, they must ensure this virtual environment is activated first.
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
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).
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(Read more
name: agent-platform-rag-engine-management metadata: 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:
gcloud auth login
gcloud auth application-default login2. **Virtual Environment**: Create and activate a dedicated virtual environment:
python3 -m venv ~/rag_agent_venv
source ~/rag_agent_venv/bin/activate3. **Install Dependencies**: Install the required Agent Platform SDKs:
pip install google-cloud-aiplatform google-genai
4. **Execution**: Advise the user that every time they execute a Python snippet, they must ensure this virtual environment is activated first.
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
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).
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(This repository contains Agent Skills for Google products and technologies, including Google Cloud. This repository is under active development.
Repo: google/skills
Other skills on google-skills.
- /data-manager-api-audience-ingestion
Guides developers through managing (adding, removing, and clearing) audience members for Google products using the Data Manager API and its associated client libraries. Use this skill when the user wants to upload audience members, remove specific users, or clear/replace an
Open skill - /data-manager-api-event-ingestion
Guides developers through implementing event and conversion ingestion to Google products using the Data Manager API /v1/events/ingest endpoint and its associated client libraries. Use this skill when the user wants to upload offline conversions, enhanced conversions for leads,
Open skill - /data-manager-api-setup
Guides developers through client library installation and authentication setup steps for the Data Manager API. Use this skill when a user is getting started with the Data Manager API and needs to setup their local environment, install the client library, or setup access to the
Open skill - /google-ads-api-account-diagnostics
Diagnoses Google Ads account performance issues such as conversion loss (value or volume), low lead flow/volume, and lost impression share (opportunities) due to ad rank, bids, or budgets. Use when troubleshooting sudden performance drops, analyzing campaign impression share
Open skill - /google-ads-api-mcp-setup
Guides developers through downloading, configuring, and installing the official open-source Google Ads MCP Server. Use this skill when a user wants to connect their AI assistant (such as Gemini, Claude Code, or Cursor) to their Google Ads account to query campaigns or retrieve
Open skill - /google-ads-api-quickstart
Guides developers through Google Ads API quickstart: credential setup, choosing from 6 client libraries/REST, configuring environments, and running a "retrieve campaigns" script. Troubleshoots common setup errors: USER_PERMISSION_DENIED, login_customer_id issues, and
Open skill

