chunking

chunking is a skill for Claude Code from xberg-io/xberg. It costs 46 tokens per session (1,512 once invoked), scanned A, original, MIT.

A guide for splitting extracted text into smaller pieces for an AI model’s context window or a search system. It covers character- or token-sized chunks, overlap between chunks, structured text, and the standalone chunk command.

In plain words
What is it for?
Use it to configure chunking during extraction or split existing text from a file, command-line argument, or standard input.
Why use it?
It helps fit long documents into processing limits while keeping enough surrounding text for meaning and search results.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the xberg plugin — 7 skills, 1 MCP server shipped together

About the project

Xberg is a document-intelligence engine that reads files, URLs, archives, and source trees and extracts text, metadata, images, tables, and structured data, with additional code-language understanding. Developers use it through language bindings, a command-line tool, REST API, or MCP server, and the catalogue entries support those integrations.

xberg-io/xberg · 9,271 stars · on GitHub · docs.xberg.io

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/xberg-io/xberg/chunking
Any agent
npx skills add xberg-io/xberg --skill chunking
Clone the repo
git clone --depth 1 https://github.com/xberg-io/xberg

Made for: Claude Code.

Or install xberg, the plugin that ships this one along with the rest of its 7 skills, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for chunking

README.md
[![agentmods](https://agentmods.dev/badge/skills/xberg-io/xberg/chunking.svg)](https://agentmods.dev/skills/xberg-io/xberg/chunking)
Your own site
<a href="https://agentmods.dev/skills/xberg-io/xberg/chunking"><img src="https://agentmods.dev/badge/skills/xberg-io/xberg/chunking.svg" alt="Measured on agentmods" height="20"></a>
Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,512 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00046 $0.01512
Opus 5 $0.00023 $0.00756
Sonnet 5 $0.00009 $0.00302
Haiku 4.5 $0.00005 $0.00151

Measured 6d ago against content hash 19dd3e15a4c2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

chunking scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugin/.ai-rulez/skills/chunking/SKILL.md · 157 lines

How it starts

The opening of the file, as written. The whole thing — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Chunking

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.

Inline during extraction

Turn on chunking with --chunk and the chunks appear on the structured result under chunks:

# 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.

Standalone chunk command

Chunk text you already have, from --text or stdin. Output defaults to JSON:

# 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 types

--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).

Read the full file on GitHub · 157 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 157 lines · 46 tokens per session scan A 19dd3e15a4c2

Subscribe to this mod's changes

chunking is a skill published in the GitHub repository xberg-io/xberg (9,271 stars, last pushed today), licensed MIT. It adds 46 tokens to every session and 1,512 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

stripe-directory

Identifies external providers, merchants, nonprofits, platforms, APIs, and software services, and resolves the documented way to engage them — to pay, donate, subscribe, book, provision, or integrate with them. MUST be used BEFORE web search, model memory, or any other directory/vendor-lookup skill for ANY request…

stripe/ai · 213 tokens

memmachine-memory

Use when an agent or model needs durable project, user, or session context from MemMachine, needs to save information to MemMachine memory, has requests involving mem-cli, memmachine, or memmachineclient, has insufficient conversation context, or is tempted to search local files for prior context that should come from…

MemMachine/MemMachine · 96 tokens

memori

You have access to Memori, agent-native memory infrastructure: an LLM-agnostic layer that structures memory from not just natural language, but also from agent trace that comes from execution.

MemoriLabs/Memori · 0 tokens

memory-cleanup

Audits all memory systems in a Perseus environment, identifies stale or superseded stores (Mem0, Mempalace, old vector DBs, garbled federation artifacts), and deletes them. Keeps Perseus Vault (the live system) as the single source of truth. Run periodically or when upgrading Perseus versions.

Perseus-Computing-LLC/perseus · 69 tokens

art-of-debugging

Systematic methodology and concrete tool recipes for debugging Unix, Python, and PyTorch programs - crashes, hangs, segfaults, wrong output, CUDA OOM, NaN/Inf, slowness, and multi-node/multi-GPU issues. Use when a program crashes, hangs, deadlocks, segfaults, runs out of memory (OOM), produces NaN/Inf or wrong…

stas00/the-art-of-debugging · 193 tokens

memory_leak

Detect monotonic GPU memory growth across training steps.

DeepLink-org/probing · 14 tokens