Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when splitting extracted text into chunks for LLM context windows or RAG ingestion. Covers chunk size, overlap, markdown/yaml/semantic chunkers, tokenizer-based sizing, and the standalone `chunk` command.
.claude/skills/xberg-io-chunking/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 33% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 110% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -24% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 40% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 9% | 0% |
<!-- AI-RULEZ :: GENERATED FILE — DO NOT EDIT Content-Hash: blake3:0b5cd4bec9d2a8f3452e07139ef56d6b87f9f7990714d15483a03435e751af59 Source-Hash: blake3:ef1fa958e3b61fa61d2a2275a9c04dfab5c94186e3351a2216afb25cbb36ff1a Schema-Version: v1 -->
Use this when feeding documents into an LLM context window or a vector store. Xberg chunks two ways: inline during extraction (chunks land on each document's chunks field), or standalone via the chunk command for text you already have. Sizing is character-based by default, or token-based when a tokenizer model is supplied.
Turn on chunking with --chunk and the chunks appear on the structured result under chunks:
bash# 1000-char chunks, 200-char overlap (defaults when --chunk is on) xberg extract report.pdf --chunk --format json | jq '.chunks | length' # Explicit size + overlap xberg extract report.pdf --chunk --chunk-size 1500 --chunk-overlap 300 --format json
Overlap must be smaller than chunk size — the CLI rejects --chunk-overlap >= --chunk-size. When you set only --chunk-overlap against an existing config, an overlap that exceeds the size is clamped to chunk_size / 4.
chunk commandChunk text you already have, from --text or stdin. Output defaults to JSON:
bash# From a flag xberg chunk --text "long document text ..." --chunk-size 800 --chunk-overlap 100 # From stdin (pipe extracted content straight in) xberg extract notes.md | xberg chunk --chunk-size 500 --format json
JSON output carries chunks (array of strings), chunk_count, the resolved config (max_characters, overlap, chunker_type), and input_size_bytes. Use --format text for a human-readable dump with --- chunk N --- separators.
> Note: in the JSON output, chunker_type is rendered capitalized ("Text", > "Markdown", "Yaml", "Semantic") because it is emitted via Rust's Debug > formatting, whereas the --chunker-type input flag is lowercase > (text, markdown, yaml, semantic). Lowercase the value before > comparing if you parse it back.
--chunker-type selects the splitting strategy (standalone chunk command):
| Type | Behavior | | ---------- | ------------------------------------------------------------------- | | text | Default. Plain character-window splitting with overlap. | | markdown | Markdown-aware — splits on structure (headings, blocks) where possible. | | yaml | YAML-aware splitting for structured config/data documents. | | semantic | Topic-boundary splitting driven by --topic-threshold (0.0–1.0, default 0.75). |
bash# Markdown-aware chunking keeps headings and blocks intact xberg chunk --text "$(cat README.md)" --chunker-type markdown # Semantic chunking — lower threshold = more, smaller topic chunks xberg chunk --text "$(cat transcript.txt)" --chunker-type semantic --topic-threshold 0.6
By default --chunk-size counts characters. To size chunks by tokens for a specific model, pass --chunking-tokenizer with a HuggingFace tokenizer id. On the extract command this implicitly enables chunking. Requires the chunking-tokenizers feature (present in the default CLI build).
bash# Size chunks by GPT-4o tokens during extraction xberg extract report.pdf --chunking-tokenizer Xenova/gpt-4o --format json # Or on the standalone command xberg chunk --text "$(cat doc.txt)" --chunking-tokenizer Xenova/gpt-4o --chunk-size 512
With a tokenizer set, --chunk-size is interpreted in tokens, not characters.
Field names in config files are snake_case under [chunking]:
toml[chunking] max_characters = 1000 overlap = 200 chunker_type = "markdown"
bashxberg extract report.pdf --config xberg.toml --format json
> CLI flags map to config fields as --chunk-size → max_characters and > --chunk-overlap → overlap. In config files use the snake_case names.
From Python, enable chunking on the config and read the chunks off the document in the result envelope (result.results[0].chunks):
pythonfrom xberg import ExtractInput, extract, ExtractionConfig, ChunkingConfig config = ExtractionConfig( chunking=ChunkingConfig(max_characters=1000, overlap=200), ) result = await extract(ExtractInput(uri="report.pdf"), config) for chunk in result.results[0].chunks or []: print(len(chunk.content))
> The public Python ChunkingConfig (a dataclass) uses constructor kwargs > max_characters / overlap; the Rust core struct fields are also > max_characters / overlap. TOML/JSON config keys are max_chars / > max_overlap (with max_characters / overlap accepted as serde aliases), > and dict-form config passed to ExtractionConfig likewise accepts the > max_chars / max_overlap aliases; Node's ChunkingConfig interface uses > maxCharacters / overlap. See references/python-api.md and > references/rust-api.md in the sibling xberg skill.
10–20% overlap. Use markdown chunking for docs to keep sections whole.
overlap; size by tokens to stay under the model window.
semantic chunker; tune --topic-thresholddown for finer splits, up for coarser ones.
extract; clamped to size / 4 whenonly overlap is changed against an existing config.
--chunking-tokenizer errors if theCLI was built without chunking-tokenizers. The default build includes it.
chunk command bails on empty text;provide --text or pipe non-empty stdin.
See references/configuration.md for the full [chunking] schema and references/cli-reference.md for every chunk flag.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 13,095 | 5,937 | -55% | 1 | 1 | 0% | 2,034 | 2,713 | +33% | 0 | 0 | — |
case-02 | fail→pass | 10,530 | 8,170 | -22% | 1 | 1 | 0% | 1,460 | 3,060 | +110% | 0 | 0 | — |
case-03 | fail→pass | 23,090 | 18,217 | -21% | 1 | 1 | 0% | 3,323 | 2,533 | -24% | 0 | 0 | — |
case-04 | fail→pass | 9,829 | 3,513 | -64% | 1 | 1 | 0% | 1,613 | 2,255 | +40% | 0 | 0 | — |
case-05 | fail→pass | 14,444 | 3,790 | -74% | 1 | 1 | 0% | 2,129 | 2,319 | +9% | 0 | 0 | — |
case-06 | fail→pass | 32,025 | 4,487 | -86% | 1 | 1 | 0% | 3,216 | 2,447 | -24% | 0 | 0 | — |
case-07 | fail→pass | 18,430 | 4,409 | -76% | 1 | 1 | 0% | 3,355 | 2,393 | -29% | 0 | 0 | — |
case-08 | fail→pass | 14,943 | 3,061 | -80% | 1 | 1 | 0% | 1,979 | 2,106 | +6% | 0 | 0 | — |
case-09 | fail→pass | 15,821 | 8,387 | -47% | 1 | 1 | 0% | 2,403 | 2,922 | +22% | 0 | 0 | — |
case-10 | fail→pass | 7,967 | 3,841 | -52% | 1 | 1 | 0% | 1,146 | 2,213 | +93% | 0 | 0 | — |
case-11 | fail→pass | 18,465 | 9,021 | -51% | 1 | 1 | 0% | 2,821 | 3,061 | +9% | 0 | 0 | — |
case-12 | pass→pass | 14,343 | 3,757 | -74% | 1 | 1 | 0% | 2,040 | 2,245 | +10% | 0 | 0 | — |
case-13 | fail→fail | 16,652 | 2,853 | -83% | 1 | 1 | 0% | 2,656 | 2,086 | -21% | 0 | 0 | — |
case-14 | fail→pass | 15,176 | 7,130 | -53% | 1 | 1 | 0% | 2,677 | 2,719 | +2% | 0 | 0 | — |
case-15 | fail→pass | 13,595 | 3,750 | -72% | 1 | 1 | 0% | 1,758 | 2,208 | +26% | 0 | 0 | — |
case-16 | fail→pass | 15,793 | 7,090 | -55% | 1 | 1 | 0% | 2,257 | 2,780 | +23% | 0 | 0 | — |
case-17 | fail→pass | 21,599 | 3,763 | -83% | 1 | 1 | 0% | 2,519 | 2,216 | -12% | 0 | 0 | — |
case-18 | fail→pass | 31,600 | 4,491 | -86% | 1 | 1 | 0% | 5,142 | 2,373 | -54% | 0 | 0 | — |
case-19 | fail→pass | 11,905 | 4,954 | -58% | 1 | 1 | 0% | 1,742 | 2,485 | +43% | 0 | 0 | — |
case-20 | pass→pass | 10,206 | 8,867 | -13% | 1 | 1 | 0% | 1,836 | 3,145 | +71% | 0 | 0 | — |
case-21 | pass→pass | 12,780 | 10,052 | -21% | 1 | 1 | 0% | 2,072 | 3,558 | +72% | 0 | 0 | — |
case-22 | pass→pass | 15,480 | 10,701 | -31% | 1 | 1 | 0% | 2,741 | 3,448 | +26% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +77 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 9/19/2026 | +61% |
| gemini-3.6-flash | verified | 9/9/2026 | +48% |
| gemini-3.6-flash | verified | 9/2/2026 | +64% |
| gemini-3.6-flash | verified | 8/18/2026 | +59% |
| gemini-3.6-flash | verified | 8/13/2026 | +82% |
Other measured skills in the registry, with their headline benchmark lift.