Context Window Text Chunking — AI skill for Claude Code
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:
- Splits the document into paragraphs (blank-line-separated blocks).
- Greedily packs whole paragraphs into a chunk until the next paragraph would push it past your target size (measured in words or characters).
- Starts a new chunk at that point — the boundary always falls between two paragraphs, never inside one.
- 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. - 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 |
Related Skills
Second Brain Cc
Persistent memory + working protocol for AI coding agents (Claude Code). Numbered Markdown vault, stdlib SQLit
Second Brain AI
A second brain that works for you: an Obsidian vault maintained by an AI agent (Claude Code), with hand-off no
Qiaomu Design
偏执型设计顾问:反 AI 味设计 + 风格试衣间 + 58 站设计系统库的 Claude Code Skill Opinionated design advisor for Claude Code: anti-gener
Address PR Feedback
Address any PR feedback we've received on this PR. This may be from an AI or a human, some might be inline wit
Claude Orchestrator
Claude Code plugin: split a task into subtasks, send each subtask to a subagent on a fitting model, and see th
Driftwatch
Checks the work AI coding agents did for you for changes they didn't tell you about: rules they made up, thing
Related Agents
Poster Text Editor
Use to rewrite or restructure TEXT on an academic poster: turn a paragraph (introduction, research-question su
Structure Analyst
Studies the examples/ folder (past works, templates, rubrics) and returns the ideal structure for a given assi
Create Character
D&D character creation wizard. Use PROACTIVELY when players want to create new characters. Guides through race