hyderhusainarastu

Context Window Text Chunking — AI skill for Claude Code

AI community

Paragraph-boundary-aware text chunker for fitting long documents into LLM context windows.

How to install Context Window Text Chunking

This entry records only its repository, not the path inside it, so there is no exact command to give. Open hyderhusainarastu/context-window-text-chunking and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Context Window Text Chunking does

Paragraph-boundary-aware text chunker for fitting long documents into LLM context windows. Optional overlap, word or character budgets, numbered output files and a no-content-dropped check. Python standard library only; usable as a CLI or an agent skill.

Alternatives in AI

  • LLM Aided OCR — Enhances Tesseract OCR output using LLMs (local or API) for error correction, smart chunking, and markdown for 3k ★
  • Fk Character Bible — Character Bible & Visual Consistency — AI Film Production 1.2k ★
  • Session Kit — Close the terminal windows, not the AI coding sessions 649 ★

README

Context-Window Text Chunking

Split a long text document into size-bounded chunks that fit an LLM context window, without ever cutting a paragraph in half. Optional overlap keeps a little shared context between consecutive chunks.

python3 scripts/chunk_text.py --input document.txt --out-dir chunks/ --chunk-size 2000 --overlap 200

What it does

Long documents — research papers, extracted-PDF text, transcripts, book chapters, log files — often exceed the context budget you want to spend on a single model request. Chopping the text every N characters is the easy way to solve this, and the easy way is also the wrong way: it routinely slices a sentence in half, or separates a claim from the evidence that follows it, right at the cut point.

This tool instead:

  1. Splits the document into paragraphs (blank-line-separated blocks).
  2. Greedily packs whole paragraphs into a chunk until the next paragraph would push it past your target size (measured in words or characters).
  3. Starts a new chunk at that point — the boundary always falls between two paragraphs, never inside one.
  4. Optionally repeats the last few paragraphs of each chunk at the start of the next one (--overlap), so a downstream model reading chunk N+1 has a little context carried over from chunk N.
  5. Writes numbered, sortable chunk files (chunk_01.txt, chunk_02.txt, ...) and verifies that no content was silently dropped along the way.

If a single paragraph is larger than your target chunk size, the tool keeps it whole and lets that one chunk run oversized rather than tearing the paragraph apart — and it tells you when that happens.

Works with

Surface How Status
Command line (any shell) scripts/chunk_text.py, Python 3 standard library tested 2026-11-23, Python 3.14
Claude Code native skill (SKILL.md) via ./install.sh --claude not tested
Codex, Cursor, Gemini CLI skill in .agents/skills via ./install.sh --agents