collection-migration
Migrate and sync vector database collections across environments
What this skill does
# Collection Migration Skill
> Safely move, rename, merge, and manage RAG collections.
## Overview
As projects evolve, you may need to:
- Rename collections (project renamed)
- Merge collections (consolidating knowledge)
- Split collections (grew too large)
- Archive collections (project ended)
- Clone collections (forking a project)
This skill provides safe procedures for each operation.
## Prerequisites
```bash
pip install qdrant-client
```
## Safety Principles
1. **Always backup first** - Export before any destructive operation
2. **Verify after migration** - Run validation checks
3. **Preserve metadata** - Don't lose document provenance
4. **Atomic operations** - Complete fully or rollback
## Operation 1: Export Collection
**Use case**: Backup or transfer to another environment
```python
#!/usr/bin/env python3
"""Export a collection to JSON."""
import json
from datetime import datetime
from qdrant_client import QdrantClient
def export_collection(
collection_name: str,
output_path: str = None,
qdrant_url: str = "http://localhost:6333"
) -> str:
"""
Export collection to JSON file.
Args:
collection_name: Name of collection to export
output_path: Output file path (default: {collection}_{timestamp}.json)
qdrant_url: Qdrant server URL
Returns:
Path to exported file
"""
client = QdrantClient(url=qdrant_url)
# Get all points
results = client.scroll(
collection_name=collection_name,
limit=100000,
with_payload=True,
with_vectors=True
)
points = results[0]
# Build export data
export_data = {
"collection_name": collection_name,
"exported_at": datetime.now().isoformat(),
"document_count": len(points),
"documents": [
{
"id": str(p.id),
"content": p.payload.get("content", ""),
"metadata": {k: v for k, v in p.payload.items() if k != "content"},
"vector": p.vector
}
for p in points
]
}
# Write to file
if output_path is None:
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
output_path = f"{collection_name}_{timestamp}.json"
with open(output_path, "w") as f:
json.dump(export_data, f, indent=2)
print(f"✅ Exported {len(points)} documents to {output_path}")
return output_path
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
print("Usage: python export_collection.py <collection_name> [output_path]")
sys.exit(1)
collection = sys.argv[1]
output = sys.argv[2] if len(sys.argv) > 2 else None
export_collection(collection, output)
```
## Operation 2: Import Collection
**Use case**: Restore from backup or import shared collection
```python
#!/usr/bin/env python3
"""Import a collection from JSON export."""
import json
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct
def import_collection(
input_path: str,
new_name: str = None,
qdrant_url: str = "http://localhost:6333",
skip_vectors: bool = False
) -> str:
"""
Import collection from JSON file.
Args:
input_path: Path to exported JSON file
new_name: New collection name (default: use original name)
qdrant_url: Qdrant server URL
skip_vectors: If True, regenerate embeddings instead of using exported ones
Returns:
Name of imported collection
"""
with open(input_path) as f:
data = json.load(f)
collection_name = new_name or data["collection_name"]
client = QdrantClient(url=qdrant_url)
# Check if collection exists
existing = [c.name for c in client.get_collections().collections]
if collection_name in existing:
raise ValueError(f"Collection '{collection_name}' already exists. Use different name or delete first.")
# Determine vector size from first document
if data["documents"] and data["documents"][0].get("vector"):
vector_size = len(data["documents"][0]["vector"])
else:
vector_size = 384 # Default for all-MiniLM-L6-v2
# Create collection
client.create_collection(
collection_name=collection_name,
vectors_config=VectorParams(size=vector_size, distance=Distance.COSINE)
)
# Prepare points
points = []
for doc in data["documents"]:
if skip_vectors or not doc.get("vector"):
continue # Would need to regenerate embeddings
payload = doc["metadata"] or {}
payload["content"] = doc["content"]
payload["imported_from"] = data["collection_name"]
payload["imported_at"] = data["exported_at"]
points.append(PointStruct(
id=hash(doc["id"]) % (2**63),
vector=doc["vector"],
payload=payload
))
# Batch insert
batch_size = 100
for i in range(0, len(points), batch_size):
batch = points[i:i + batch_size]
client.upsert(collection_name=collection_name, points=batch)
print(f"✅ Imported {len(points)} documents into '{collection_name}'")
return collection_name
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
print("Usage: python import_collection.py <input_path> [new_name]")
sys.exit(1)
input_path = sys.argv[1]
new_name = sys.argv[2] if len(sys.argv) > 2 else None
import_collection(input_path, new_name)
```
## Operation 3: Rename Collection
**Use case**: Project renamed, need to update collection name
```python
def rename_collection(
old_name: str,
new_name: str,
qdrant_url: str = "http://localhost:6333"
):
"""
Rename a collection (export + import + delete).
"""
# Export first (backup)
export_path = export_collection(old_name, qdrant_url=qdrant_url)
# Import with new name
import_collection(export_path, new_name=new_name, qdrant_url=qdrant_url)
# Delete old collection
client = QdrantClient(url=qdrant_url)
client.delete_collection(old_name)
print(f"✅ Renamed '{old_name}' to '{new_name}'")
```
## Operation 4: Merge Collections
**Use case**: Consolidating multiple projects, combining research
```python
def merge_collections(
source_collections: list,
target_collection: str,
qdrant_url: str = "http://localhost:6333",
deduplicate: bool = True
):
"""
Merge multiple collections into one.
Args:
source_collections: List of collection names to merge
target_collection: Name for merged collection
deduplicate: If True, skip duplicate content
"""
client = QdrantClient(url=qdrant_url)
# Determine vector size from first source
first_coll = client.get_collection(source_collections[0])
vector_size = first_coll.config.params.vectors.size
# Create or get target collection
existing = [c.name for c in client.get_collections().collections]
if target_collection not in existing:
from qdrant_client.models import Distance, VectorParams
client.create_collection(
collection_name=target_collection,
vectors_config=VectorParams(size=vector_size, distance=Distance.COSINE)
)
seen_hashes = set()
total_added = 0
total_skipped = 0
for source_name in source_collections:
print(f"Merging '{source_name}'...")
results = client.scroll(
collection_name=source_name,
limit=100000,
with_payload=True,
with_vectors=True
)
points = results[0]
for p in points:
content = p.payload.get("content", "")
# Deduplication
if deduplicate:
content_hash = hash(content)
if content_hash in seen_hashes:
total_skipped += 1
continue
seen_hashes.add(content_hash)
# TraRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.