PluginBench
Skill
Review
Audit score 70

chunking-strategy

giuseppe-trisciuoglio/developer-kit

Optimize document chunking for RAG systems with size, overlap, and semantic boundary recommendations.

What is chunking-strategy?

Provides chunking strategies for retrieval-augmented generation systems, from fixed-size to semantic methods. Generates chunk size recommendations (256–1024 tokens), overlap percentages (10–20%), and boundary detection approaches. Use when building or tuning RAG pipelines, vector databases, or processing large documents for retrieval quality.

  • Recommends chunk sizes based on embedding model context windows and document type
  • Calculates optimal overlap percentages (10–20%) to preserve context
  • Detects semantic boundaries using embedding similarity (0.8 threshold)
  • Validates semantic coherence and chunk quality post-processing
  • Evaluates retrieval precision and recall metrics to guide iteration

How to install chunking-strategy

npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill chunking-strategy
Claude Code
Cursor
Windsurf
Cline

How to use chunking-strategy

  1. 1.Choose a chunking strategy (fixed-size, recursive, structure-aware, semantic, or advanced) based on your document type and use case
  2. 2.Pre-process documents to analyze structure, content types, and information density
  3. 3.Select parameters: chunk size (typically embedding model context / 4), overlap (10–20%), and strategy-specific settings
  4. 4.Apply the chunking strategy to your documents using provided code examples or libraries
  5. 5.Validate chunk quality by running coherence checks and measuring precision/recall metrics
  6. 6.Iterate: if precision < 0.7, reduce chunk size by 25%; if recall < 0.6, increase overlap by 10%

Use cases

Good for
  • Optimizing RAG systems with poor retrieval quality by tuning chunk size and overlap
  • Processing structured documents (Markdown, code, PDFs) while preserving semantic units
  • Building vector search pipelines with semantic chunking for complex, thematic documents
  • Implementing late chunking or contextual retrieval for high-precision requirements
  • Analyzing chunk size distribution and coherence across large document batches
Who it's for
  • RAG system builders and maintainers
  • Vector database engineers
  • Document processing pipeline developers
  • ML engineers optimizing retrieval quality
  • Teams working with multi-modal or structured content

chunking-strategy FAQ

What chunk size should I start with?

Start with 512 tokens and 10–20% overlap for most cases. Adjust down to 256 tokens for factoid queries or up to 1024 for analytical documents. Optimal size is roughly embedding model context window divided by 4.

How do I validate that my chunks are good?

Run semantic coherence checks (target 0.3–0.7 similarity), measure retrieval precision (target ≥ 0.7), and check chunk size distribution. Use the provided Python validation snippets to assess cohesion and retrieval metrics.

When should I use semantic chunking instead of fixed-size?

Use semantic chunking for complex documents with thematic shifts or when fixed-size chunking yields poor retrieval quality. Semantic methods are computationally expensive but preserve meaning better across boundaries.

What if my retrieval precision is too low?

Reduce chunk size by 25% and re-evaluate. If recall is too low, increase overlap by 10%. Monitor latency and memory usage as you iterate.

Can I use different strategies for different document types?

Yes. Use fixed-size for simple documents, recursive for structural boundaries, structure-aware for code/Markdown/PDFs, and semantic for complex thematic content. Test with representative documents before deployment.

Full instructions (SKILL.md)

Source of truth, from giuseppe-trisciuoglio/developer-kit.


name: chunking-strategy description: 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. allowed-tools: Read, Write, Bash

Chunking Strategy for RAG Systems

Overview

Provides chunking strategies for RAG systems, vector databases, and document processing. Recommends chunk sizes, overlap percentages, and boundary detection methods; validates semantic coherence; evaluates retrieval metrics.

When to Use

Use when building or optimizing RAG systems, vector search pipelines, document chunking workflows, or performance-tuning existing systems with poor retrieval quality.

Instructions

Choose Chunking Strategy

Select based on document type and use case:

  1. Fixed-Size Chunking (Level 1)

    • Use for simple documents without clear structure
    • Start with 512 tokens and 10-20% overlap
    • Adjust: 256 for factoid queries, 1024 for analytical
  2. Recursive Character Chunking (Level 2)

    • Use for documents with structural boundaries
    • Hierarchical separators: paragraphs → sentences → words
    • Customize for document types (HTML, Markdown, JSON)
  3. Structure-Aware Chunking (Level 3)

    • Use for structured content (Markdown, code, tables, PDFs)
    • Preserve semantic units: functions, sections, table blocks
    • Validate structure preservation post-split
  4. Semantic Chunking (Level 4)

    • Use for complex documents with thematic shifts
    • Embedding-based boundary detection with 0.8 similarity threshold
    • Buffer size: 3-5 sentences
  5. Advanced Methods (Level 5)

    • Late Chunking for long-context models
    • Contextual Retrieval for high-precision requirements
    • Monitor computational cost vs. retrieval gain

Reference: references/strategies.md.

Implement Chunking Pipeline

  1. Pre-process documents

    • Analyze structure, content types, information density
    • Identify multi-modal content (tables, images, code)
  2. Select parameters

    • Chunk size: embedding model context window / 4
    • Overlap: 10-20% for most cases
    • Strategy-specific settings
  3. Process and validate

    • Apply chunking strategy
    • Validate coherence: run evaluate_chunks.py --coherence (see below)
    • Test with representative documents
  4. Evaluate and iterate

    • Measure precision and recall
    • If precision < 0.7: reduce chunk_size by 25% and re-evaluate
    • If recall < 0.6: increase overlap by 10% and re-evaluate
    • Monitor latency and memory usage

Reference: references/implementation.md.

Validate Chunk Quality

Run validation commands to assess chunk quality:

# Check semantic coherence (requires sentence-transformers)
python -c "
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
chunks = [...]  # your chunks
embeddings = model.encode(chunks)
similarity = (embeddings @ embeddings.T).mean()
print(f'Cohesion: {similarity:.3f}')  # target: 0.3-0.7
"

# Measure retrieval precision
python -c "
relevant = sum(1 for c in retrieved if c in relevant_chunks)
precision = relevant / len(retrieved)
print(f'Precision: {precision:.2f}')  # target: >= 0.7
"

# Check chunk size distribution
python -c "
import numpy as np
sizes = [len(c.split()) for c in chunks]
print(f'Mean: {np.mean(sizes):.0f}, Std: {np.std(sizes):.0f}')
print(f'Min: {min(sizes)}, Max: {max(sizes)}')
"

Reference: references/evaluation.md.

Examples

Fixed-Size Chunking

from langchain.text_splitter import RecursiveCharacterTextSplitter

splitter = RecursiveCharacterTextSplitter(
    chunk_size=256,
    chunk_overlap=25,
    length_function=len
)
chunks = splitter.split_documents(documents)

Structure-Aware Code Chunking

import ast

def chunk_python_code(code):
    tree = ast.parse(code)
    chunks = []
    for node in ast.walk(tree):
        if isinstance(node, (ast.FunctionDef, ast.ClassDef)):
            chunks.append(ast.get_source_segment(code, node))
    return chunks

Semantic Chunking

def semantic_chunk(text, similarity_threshold=0.8):
    sentences = split_into_sentences(text)
    embeddings = generate_embeddings(sentences)
    chunks, current = [], [sentences[0]]
    for i in range(1, len(sentences)):
        sim = cosine_similarity(embeddings[i-1], embeddings[i])
        if sim < similarity_threshold:
            chunks.append(" ".join(current))
            current = [sentences[i]]
        else:
            current.append(sentences[i])
    chunks.append(" ".join(current))
    return chunks

Best Practices

Core Principles

  • Balance context preservation with retrieval precision
  • Maintain semantic coherence within chunks
  • Optimize for embedding model context window constraints

Implementation

  • Start with fixed-size (512 tokens, 15% overlap)
  • Iterate based on document characteristics
  • Test with domain-specific documents before deployment

Pitfalls to Avoid

  • Over-chunking: context-poor small chunks
  • Under-chunking: missing information in oversized chunks
  • Ignoring semantic boundaries and document structure
  • One-size-fits-all for diverse content types

Constraints and Warnings

Resource Considerations

  • Semantic methods require significant compute resources
  • Late chunking needs long-context embedding models
  • Complex strategies increase processing latency
  • Monitor memory for large document batches

Quality Requirements

  • Validate semantic coherence post-processing
  • Test with representative documents before deployment
  • Ensure chunks maintain standalone meaning
  • Implement error handling for malformed content

References

Related skills

More from giuseppe-trisciuoglio/developer-kit and the wider catalog.

CLclean-architecture logo

clean-architecture

giuseppe-trisciuoglio/developer-kit

Clean Architecture, Hexagonal Architecture, and DDD patterns for Spring Boot 3.5+ applications.

1.5k installsAudited
COcodex logo

codex

giuseppe-trisciuoglio/developer-kit

Provides Codex CLI delegation workflows for complex code generation and development tasks using OpenAI's GPT-5.3-codex models, including English prompt formulation, execution flags, sandbox modes, and safe result handling. Use when the user explicitly asks to use Codex for complex programming tasks such as code generation, refactoring, or architectural analysis. Triggers on "use codex", "delegate to codex", "run codex cli", "ask codex", "codex exec", "codex review".

1.0k installs
COconstitution logo

constitution

giuseppe-trisciuoglio/developer-kit

Creates, updates, validates, and displays the architectural DNA of a project through two shared documents: docs/specs/architecture.md (technology stack, architectural rules, security constraints, AI guardrails) and docs/specs/ontology.md (domain glossary / Ubiquitous Language). Use BEFORE brainstorm as a project setup step, or at any point in the SDD lifecycle to validate specs/tasks against architecture principles. Triggers on 'create constitution', 'update constitution', 'constitution check', 'validate against constitution', 'project principles', 'architectural guardrails', 'setup project architecture', 'define ontology'.

629 installsAudited
COcopilot-cli logo

copilot-cli

giuseppe-trisciuoglio/developer-kit

Provides GitHub Copilot CLI task delegation in non-interactive mode with multi-model support (Claude, GPT, Gemini), permission controls, output sharing, and session resume. Use when users ask to hand work to Copilot, compare models, or run Copilot programmatically from Claude Code.

1.1k installs
CRcreate-pr-from-spec logo

create-pr-from-spec

giuseppe-trisciuoglio/developer-kit

Create GitHub Pull Request from specification using pull_request_template.md. Use when: spec needs to be converted to PR, spec is ready for review/merge, need to automate PR creation from specification file with template-based body and title.

649 installsAudited
DOdocs-updater logo

docs-updater

giuseppe-trisciuoglio/developer-kit

Provides automated documentation updates by analyzing git changes between the current branch and the last release tag. Performs git diff analysis to identify modifications, then updates README.md, CHANGELOG.md following Keep a Changelog standard, and discovers documentation folders for contextual updates. Use when preparing a release, maintaining documentation sync, or before creating a pull request. Triggers on "update docs", "update changelog", "sync documentation", "update readme", "prepare release documentation".

1.1k installsAudited