Skip to main content
skill GitHub Copilot official · GitHub

pinecone-rag — GitHub Copilot skill: what it does, install

This skill guides Pinecone-based RAG pipelines and persistent agent memory. Use it for semantic document search, hybrid retrieval, or context shared across sessions.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill pinecone-rag
Open on GitHub

What pinecone-rag does

pinecone-rag walks through creating a Pinecone index, embedding documents, and retrieving matching content. It covers dense semantic search, hybrid search with BM25, and metadata filters. Original document text is stored with each vector so retrieval can return the text directly.

For document-based RAG, the skill shows how to assemble retrieved context for an LLM answer. For agent memory, it uses namespaces to keep data for agents or users separate. The setup requires Pinecone 6.0.0 or newer and Python 3.10+.

Install it when your project uses Pinecone for document retrieval or persistent agent memory. It is the wrong fit for local-only stores such as Chroma, FAISS, or pgvector.

What it helps with

  • index documents for semantic search
  • build a Pinecone-backed RAG pipeline
  • persist agent memory across sessions
  • combine semantic retrieval with exact keywords
  • isolate memory by agent or user namespace

Example prompts for the agent

  • Build a RAG system that searches PDF content through Pinecone and grounds LLM answers.
  • Set up persistent agent memory with a separate namespace for each user.
  • Add hybrid retrieval for a corpus containing exact API method names.

How to install pinecone-rag

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill pinecone-rag

2GitHub CLI

gh skill install github/awesome-copilot pinecone-rag

3Manually: put the files in place

.github/skills/pinecone-rag/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

llm-cost-optimizer Alireza Rezvani Audits token usage and cuts LLM API spend through model routing, caching, and prompt compression. Useful when API bills spike or before launching new AI endpoints. Claude Code 73installs claude-coach claude-skills This skill teaches Claude workflows and improves prompt habits through targeted tips. Use it when you want guided practice inside Claude Code. Claude Code 50installs 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 orchestration stablyai Coordinates supervised Orca workers with task DAGs, decision gates, and threaded messages. Fits workflows that split work across multiple agents. Claude Code CX Codex Cursor +1 349,200installs

Questions about pinecone-rag

How do I install pinecone-rag in GitHub Copilot?

Run npx skills add github/awesome-copilot --skill pinecone-rag. The skill file is then available at .github/skills/pinecone-rag/SKILL.md.

What does pinecone-rag do?

It guides the setup of Pinecone-based RAG pipelines and persistent agent memory. The workflow covers index configuration, vector upserts, dense search, hybrid search, and metadata filtering.

What does pinecone-rag require?

The skill requires Pinecone 6.0.0 or newer and Python 3.10+. The index dimension must match the selected embedding model.

Source text

SKILL.md · Apache-2.0
---
name: pinecone-rag
description: >
  Build production RAG pipelines and persistent agent memory using Pinecone as
  the vector database backend. ALWAYS USE THIS SKILL when the user mentions
  Pinecone, wants to index documents for semantic search, build a
  retrieval-augmented generation system, store agent memory across sessions,
  implement hybrid search, or connect an LLM to a searchable knowledge base —
  even if they don't say "Pinecone" explicitly. Also use when the user asks
  about vector databases for RAG, namespace isolation for multi-tenant agents,
  embedding pipelines, or scaling a knowledge base beyond what local storage
  can handle. DO NOT use for local-only vector stores (Chroma, FAISS, pgvector)
  or pure keyword search with no semantic component.
license: Apache-2.0
compatibility: "pinecone>=6.0.0, Python 3.10+"
---

# Pinecone RAG Skill

This skill guides you through building a production RAG pipeline or persistent
agent memory system using Pinecone. Follow the workflow from start to finish —
don't skip steps or jump to code before understanding what the user actually
needs.

## Before you start — ask one question

Before writing any code, identify which of these two use cases applies:

**A — RAG over documents**: User wants to index a corpus (PDFs, docs, code,
web pages) and retrieve relevant chunks to ground LLM responses.

**B — Agent memory**: User wants an agent to remember facts, decisions, or
context across sessions or across multiple agents sharing a knowledge base.

The setup is similar but the namespace strategy and retrieval patterns differ.
If the user hasn't said, ask: *"Is this for document retrieval, agent memory,
or both?"* Then follow the relevant workflow below.

---

## Step 1 — Choose your index configuration

Pick the index type before writing any code. Getting this wrong means
re-creating the index later.

**Serverless (recommended for most cases)**
```python
from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key="PINECONE_API_KEY")

if "my-index" not in pc.list_indexes().names():
    pc.create_index(
        name="my-index",
        dimension=1536,        # must match your embedding model exactly
        metric="cosine",
        spec=ServerlessSpec(cloud="aws", region="us-east-1")
    )
index = pc.Index("my-index")
```

**Pod-based (for consistent high-throughput production)**
```python
from pinecone import PodSpec

pc.create_index(
    name="my-index-prod",
    dimension=1536,
    metric="cosine",
    spec=PodSpec(environment="us-east1-gcp", pod_type="p1.x1")
)
```

**Dimension quick reference — match this exactly to your embedding model:**
| Model | Dimension |
|---|---|
| `text-embedding-3-small` | 1536 |
| `text-embedding-3-large` | 3072 |
| `voyage-3` / `voyage-multimodal-3` | 1024 |
| `BAAI/bge-large-en-v1.5` | 1024 |
| `intfloat/multilingual-e5-large` (Arabic, Malay, Chinese) | 1024 |

> **Checkpoint**: Index exists, dimension matches embedding model, `index.describe_index_stats()` returns without error.

---

## Step 2 — Embed and upsert documents

Always batch upserts — never upsert one vector at a time.

```python
from openai import OpenAI

client = OpenAI()

def embed(texts: list[str]) -> list[list[float]]:
    res = client.embeddings.create(model="text-embedding-3-small", input=texts)
    return [r.embedding for r in res.data]

def upsert_docs(index, docs: list[dict], namespace: str = "default"):
    """docs = [{"id": "...", "text": "...", "metadata": {...}}]"""
    BATCH = 100
    for i in range(0, len(docs), BATCH):
        batch = docs[i:i + BATCH]
        vecs = [
            {
                "id": d["id"],
                "values": emb,
                "metadata": {**d.get("metadata", {}), "text": d["text"]}
            }
            for d, emb in zip(batch, embed([d["text"] for d in batch]))
        ]
        index.upsert(vectors=vecs, namespace=namespace)
```

**Always store the original text in metadata** — this avoids a second lookup
at retrieval time.

> **Checkpoint**: `index.describe_index_stats()` shows vector count > 0 in the
> target namespace.

---

## Step 3 — Choose retrieval strategy

### Dense (semantic) search — use for most cases
```python
def search(index, query: str, top_k: int = 5, namespace: str = "default",
           filter: dict = None) -> list[dict]:
    [q_emb] = embed([query])
    results = index.query(
        vector=q_emb, top_k=top_k, namespace=namespace,
        include_metadata=True, filter=filter
    )
    return [{"text": m.metadata["text"], "score": m.score, "id": m.id}
            for m in results.matches]
```

### Hybrid search (semantic + BM25 keyword) — use when corpus has exact terminology
Use hybrid when the domain has precise terms that semantic search misses:
legal citations, medical codes, product SKUs, API method names.

```python
from pinecone_text.sparse import BM25Encoder

bm25 = BM25Encoder().default()
bm25.fit([d["text"] for d in docs])  # fit once on your corpus

def hybrid_search(index, query: str, top_k: int = 5, alpha: float = 0.7):
    """alpha=1.0 is pure dense; alpha=0.0 is pure sparse."""
    dense = [v * alpha for v in embed([query])[0]]
    sparse_raw = bm25.encode_queries(query)
    sparse = {
        "indices": sparse_raw["indices"],
        "values": [v * (1 - alpha) for v in sparse_raw["values"]]
    }
    return index.query(vector=dense, sparse_vector=sparse,
                       top_k=top_k, include_metadata=True).matches
```

### Metadata filtering — use to scope results before semantic ranking
```python
# Exact match
results = index.query(vector=emb, filter={"source": {"$eq": "confluence"}})

# Combined filter
results = index.query(vector=emb, filter={
    "$and": [
        {"category": {"$eq": "engineering"}},
        {"language": {"$in": ["en", "ar"]}}
    ]
})
```

> **Checkpoint**: A test query returns relevant results with scores > 0.7 for
> clearly matching content.

---

## Step 4A — Full RAG pipeline (document use case)

```python
def rag_answer(index, question: str, namespace: str = "default",
               model: str = "gpt-4o-mini") -> str:
    hits = search(index, question, top_k=5, namespace=namespace)
    context = "\n\n".join(h["text"] for h in hits)

    return client.chat.completions.create(
        model=model,
        messages=[
            {
                "role": "system",
                "content": (
                    "Answer using only the provided context. "
                    "If the answer isn't in the context, say so.\n\n"
                    f"Context:\n{context}"
                )
            },
            {"role": "user", "content": question}
        ]
    ).choices[0].message.content
```

---

## Step 4B — Agent memory (memory use case)

Use namespaces to isolate each agent's or user's memories completely.
Namespace per agent prevents memory bleed across users or sessions.

```python
import time, hashlib

def remember(index, agent_id: str, content: str,
             memory_type: str = "fact"):
    """Store a memory for an agent."""
    mem_id = hashlib.md5(
        f"{agent_id}{content}{time.time()}".encode()
    ).hexdigest()
    [emb] = embed([content])
    index.upsert(
        vectors=[{
            "id": mem_id,
            "values": emb,
            "metadata": {
                "text": content,
                "type": memory_type,
                "timestamp": time.time(),
                "agent_id": agent_id
            }
        }],
        namespace=f"agent_{agent_id}"
    )

def recall(index, agent_id: str, query: str,
           top_k: int = 5) -> list[str]:
    """Recall relevant memories for an agent."""
    return [h["text"] for h in
            search(index, query, top_k=top_k,
                   namespace=f"agent_{agent_id}")]

def forget(index, agent_id: str):
    """Wipe all memories for an agent (e.g., on user request)."""
    index.delete(delete_all=True, namespace=f"agent_{agent_id}")
```

---

## Step 5 — Wire it together and test end to end

Run a quick smoke test before integrating into the larger system:

```python
# Smoke test
upsert_docs(index, [
    {"id": "t1", "text": "Pinecone is a vector database for semantic search."},
    {"id": "t2", "text": "RAG combines retrieval with language model generation."},
])

hits = search(index, "What is Pinecone?")
assert hits[0]["score"] > 0.7, f"Expected high similarity, got {hits[0]['score']}"
print("Smoke test passed:", hits[0]["text"])
```

> **Checkpoint**: Smoke test passes. End-to-end: index → upsert → query →
> LLM response works without errors.

---

## Common pitfalls — fix these before they become bugs

- **Dimension mismatch**: always verify `len(embed(["test"])[0])` matches
  the index dimension before your first upsert.
- **Missing text in metadata**: if you don't store `"text"` in metadata,
  you'll need a second lookup to get the actual content at query time.
- **Single-vector upserts in a loop**: always batch in chunks of 100.
- **No namespace strategy**: decide upfront — one namespace per user/agent
  prevents cross-tenant data leaks that are hard to fix later.
- **Fitting BM25 on a small corpus**: BM25 needs a representative corpus to
  build good term frequencies. Fit on at least a few hundred documents.

## When NOT to use this skill

Use a different approach when:
- The dataset fits in memory and latency doesn't matter → use FAISS or Chroma
- You're already on PostgreSQL and want to avoid a new service → use pgvector
- You need sub-5ms p99 latency with no external API calls → local vector store
- The user explicitly wants a different vector DB (Weaviate, Qdrant, etc.)

© github · Apache-2.0 · github/awesome-copilot

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