chunking-strategy
Provides chunking strategies for RAG systems. Generates chunk size recommendations (256-1024 tokens), overlap percentages (10-20%), and semantic boundary detection methods. Validates semantic coherence and evaluates retrieval precision/recall metrics. Use when building retrieval-augmented generation systems, vector databases, or processing large documents.
Security Assessment
About chunking-strategy
This skill provides chunking strategies for retrieval-augmented generation (RAG) systems, vector databases, and large-document processing. It addresses a core RAG quality problem: how to split documents so that retrieval returns coherent, relevant passages. Poor chunking causes weak precision and recall, and the skill offers concrete, source-grounded guidance on chunk sizes (256-1024 tokens), overlap percentages (10-20%), and boundary detection methods rather than leaving those choices to guesswork.
It organizes chunking into five levels: fixed-size, recursive character, structure-aware (Markdown, code, tables, PDFs), semantic (embedding-based boundary detection with a similarity threshold), and advanced methods such as late chunking and contextual retrieval. It walks through an implementation pipeline (pre-process, select parameters, process and validate, evaluate and iterate) with specific tuning heuristics: reduce chunk size by 25% if precision falls below 0.7, increase overlap by 10% if recall drops below 0.6. It includes runnable Python validation snippets using sentence-transformers to measure semantic cohesion, retrieval precision, and chunk-size distribution, plus example code using LangChain's RecursiveCharacterTextSplitter and Python's `ast` module for code-aware chunking. A set of reference files covers semantic methods, advanced strategies, tools, evaluation, and visualization.
It targets ML and data engineers, RAG and search practitioners, and teams performance-tuning existing pipelines with poor retrieval quality. The declared allowed tools are Read, Write, and Bash, and the validation commands require Python libraries such as sentence-transformers, scikit-learn, and numpy.
FAQ
When should I use this skill?
When building or optimizing RAG systems, vector search pipelines, or document chunking workflows, or when performance-tuning an existing system that has poor retrieval quality.
What chunk size and overlap does it recommend?
Start around 512 tokens with 10-20% overlap; use 256 for factoid queries and up to 1024 for analytical ones. A rule of thumb is chunk size equal to the embedding model's context window divided by four.
What are the prerequisites for the validation commands?
The included evaluation snippets run Python and require libraries such as sentence-transformers (with the all-MiniLM-L6-v2 model), scikit-learn, and numpy. LangChain is used in one chunking example.
How does it decide when chunking is good enough?
It measures precision and recall and iterates: if precision is below 0.7 it reduces chunk size by 25%, and if recall is below 0.6 it increases overlap by 10%, while also watching latency and memory usage.
Does it cover advanced or semantic chunking?
Yes. It documents embedding-based semantic boundary detection, clustering-based boundaries, topic modeling, named-entity and dependency-aware methods, plus late chunking and contextual retrieval, in its reference files.
All Files
9 filesInstall chunking-strategy
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
giuseppe-trisciuoglio/developer-kit