Google Gemini File Search for managed RAG with 100+ file formats. Use for document Q&A, knowledge bases, or encountering immutability errors, quota issues, polling failures. Supports Gemini 3 Pro/Flash (Gemini 2.5 legacy).
Manages fully managed RAG with Google Gemini File Search for 100+ document formats.
npx claudepluginhub secondsky/claude-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/README.mdreferences/error-catalog.mdreferences/setup-guide.mdscripts/README.mdscripts/create-store.tstemplates/README.mdStatus: Production Ready | Last Verified: 2025-11-18
Google Gemini File Search is fully managed RAG (Retrieval-Augmented Generation):
Key difference from other RAG:
Get API key: https://aistudio.google.com/apikey (Free tier: 1 GB storage, 1,500 requests/day)
bun add @google/genai
Version: 0.21.0+ | Node.js: 18+
import { GoogleGenerativeAI } from '@google/genai';
import fs from 'fs';
const ai = new GoogleGenerativeAI(process.env.GOOGLE_AI_API_KEY);
// Create store
const fileStore = await ai.fileSearchStores.create({
config: { displayName: 'my-knowledge-base' }
});
// Upload document
const operation = await ai.fileSearchStores.uploadToFileSearchStore({
name: fileStore.name,
file: fs.createReadStream('./manual.pdf'),
config: {
displayName: 'Installation Manual',
chunkingConfig: {
whiteSpaceConfig: {
maxTokensPerChunk: 500,
maxOverlapTokens: 50
}
}
}
});
// Poll until done
while (!operation.done) {
await new Promise(resolve => setTimeout(resolve, 1000));
operation = await ai.operations.get({ name: operation.name });
}
// Query documents
const model = ai.getGenerativeModel({
model: 'gemini-2.5-pro', // Only 2.5 Pro/Flash supported
tools: [{
fileSearchTool: {
fileSearchStores: [fileStore.name]
}
}]
});
const result = await model.generateContent('How do I install the product?');
console.log(result.response.text());
// Get citations
const grounding = result.response.candidates[0].groundingMetadata;
if (grounding) {
console.log('Sources:', grounding.groundingChunks);
}
Load references/setup-guide.md for complete walkthrough with batch uploads, error handling, and production checklist.
done: true (with timeout)Problem: Trying to update existing document
Solution: Delete + re-upload pattern
// Find and delete old version
const docs = await ai.fileSearchStores.documents.list({
parent: fileStore.name
});
const oldDoc = docs.documents.find(d => d.displayName === 'manual.pdf');
if (oldDoc) {
await ai.fileSearchStores.documents.delete({
name: oldDoc.name,
force: true
});
}
// Upload new version
await ai.fileSearchStores.uploadToFileSearchStore({
name: fileStore.name,
file: fs.createReadStream('manual-v2.pdf'),
config: { displayName: 'manual.pdf' }
});
Problem: Storage calculation wrong (3x multiplier)
Solution: Estimate before upload
const fileSize = fs.statSync('data.pdf').size;
const estimatedStorage = fileSize * 3; // Embeddings + metadata
if (estimatedStorage > 1e9) {
console.warn('⚠️ May exceed free tier 1 GB limit');
}
Problem: Using wrong model version
Solution: Use Gemini 2.5 only
// ✅ CORRECT
const model = ai.getGenerativeModel({
model: 'gemini-2.5-pro', // or gemini-2.5-flash
tools: [{ fileSearchTool: { fileSearchStores: [storeName] } }]
});
// ❌ WRONG
const model = ai.getGenerativeModel({
model: 'gemini-1.5-pro', // Not supported!
tools: [{ fileSearchTool: { fileSearchStores: [storeName] } }]
});
Load references/error-catalog.md for all 8 errors with detailed solutions including chunking, operation polling, metadata limits, and force delete requirements.
Cloudflare Vectorize - Global edge performance, custom embeddings, real-time R2 updates OpenAI Files API - Assistants API, conversational threads, very large collections (10,000+)
// Upload support docs with metadata
await ai.fileSearchStores.uploadToFileSearchStore({
name: fileStore.name,
file: fs.createReadStream('troubleshooting.pdf'),
config: {
displayName: 'Troubleshooting Guide',
customMetadata: {
doc_type: 'support',
category: 'troubleshooting',
language: 'en'
}
}
});
const files = ['doc1.pdf', 'doc2.md', 'doc3.docx'];
const uploadPromises = files.map(file =>
ai.fileSearchStores.uploadToFileSearchStore({
name: fileStore.name,
file: fs.createReadStream(file),
config: { displayName: file }
})
);
const operations = await Promise.all(uploadPromises);
// Poll all operations
for (const op of operations) {
let operation = op;
while (!operation.done) {
await new Promise(resolve => setTimeout(resolve, 1000));
operation = await ai.operations.get({ name: operation.name });
}
console.log('✅', operation.response.displayName);
}
// 1. List existing documents
const docs = await ai.fileSearchStores.documents.list({
parent: fileStore.name
});
// 2. Delete old version
const oldDoc = docs.documents.find(d => d.displayName === 'manual.pdf');
if (oldDoc) {
await ai.fileSearchStores.documents.delete({
name: oldDoc.name,
force: true
});
}
// 3. Upload new version
const operation = await ai.fileSearchStores.uploadToFileSearchStore({
name: fileStore.name,
file: fs.createReadStream('manual-v2.pdf'),
config: {
displayName: 'manual.pdf',
customMetadata: {
version: '2.0',
updated_at: new Date().toISOString()
}
}
});
// 4. Poll until done
while (!operation.done) {
await new Promise(resolve => setTimeout(resolve, 1000));
operation = await ai.operations.get({ name: operation.name });
}
Load references/setup-guide.md for additional patterns including code documentation search and internal knowledge bases.
references/setup-guide.md when:references/error-catalog.md when:100+ formats including:
Not supported: Images in PDFs (text extraction only), Audio files, Video files
Indexing (one-time): $0.15 per 1M tokens Storage: Free (10 GB - 1 TB depending on tier) Query embeddings: Free (retrieved context counts as input tokens)
Example: 1,000-page document ≈ 500k tokens → Indexing cost: $0.075 → Storage: ~1.5 GB (3x multiplier)
Technical docs: 500 tokens/chunk, 50 overlap Prose: 800 tokens/chunk, 80 overlap Legal: 300 tokens/chunk, 30 overlap
chunkingConfig: {
whiteSpaceConfig: {
maxTokensPerChunk: 500, // Smaller = more precise
maxOverlapTokens: 50 // 10% overlap recommended
}
}
References (references/):
setup-guide.md - Complete setup walkthrough (authentication, store creation, file upload, batch patterns, production checklist)error-catalog.md - All 8 documented errors with solutions (immutability, storage, chunking, metadata, costs, polling, force delete, model compatibility)Official Documentation:
Questions? Issues?
references/setup-guide.md for complete setupreferences/error-catalog.md for all 8 errorsThis skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.