Who it is forA developer or analyst whose agent or script has to process long documents without filling its context window with the whole text.
The problemAgents that load an entire paper or report spend most of their context on text they only needed to skim.
The outcomeThe agent reads the section map first, then pulls only the sections it needs at a chosen level.
What you need first
- Python 3.9 or newer, or the TextFold desktop app for macOS or Windows
- A model you already have, such as Claude Code, Codex, a ChatGPT plan, an API key, or a free OpenRouter setup
Steps
- Run
python3 -m pip install textfoldand connect a model in the first run, since a document not folded yet is folded first with that model. - Get the map of a document with
python3 -m textfold get https://arxiv.org/abs/2512.23916. - Get one section's points with
python3 -m textfold get 2512.23916 --level key --section 3. - Get the whole document in the TextFold format with
python3 -m textfold get report.pdf --jsonwhen a full structured copy is needed.
Prompt for your agent
Using the TextFold repo at github.com/chenxiachan/textfold, run `python3 -m textfold get <document> ` first without a level to read the section map, then run it again with `--level key --section <n>` for the one section that answers the task. Expected output: the section topics, then the points of that section with their reasons. Verify that each model-written line is marked as such before using it.
Caveat. The README does not say how long a first fold takes, so budget for a model call on each document the first time it is read.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for chenxiachan/textfold and "Let an agent read a document map first, then one section"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer