/recursive-decomposition:recursive-decompositionfrom recursive-decomposition
Decomposes large codebases, multi-document analyses, and PDF aggregation tasks using recursive sub-agents to avoid context rot. Based on the Recursive Language Models paper (2025).
Ships in recursive-decomposition. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Long inputs rot. Details get missed, distant parts get glued together by guesswork, and the reasoning drifts. The RLM paper calls it context rot. Do not load the whole input into the window. Treat it as an environment you query: size it, narrow it, split it, hand independent parts to sub-agents, verify on a small window, synthesise in code. Based on Recursive Language Models (Zhang, Kraska, Khattab, 2025).
/recursive-decomposition: apply the protocol below to the current task./recursive-decomposition <path or question>: size that input first, then run the protocol on it.Fit is not the test. Dense work can rot inside a million-token window. In the paper, OOLONG-Pairs is 32k tokens and GPT-5 scores 0.1% F1; RLM(depth=1) reaches 58.0% (arXiv:2512.24601, Table 1). 30k and 50k below are harness caps.
| Situation | Approach |
|---|---|
| One file, one function, or a single needle | Read directly |
| Linear aggregate or list-everything, and completeness matters | Decompose (this skill) |
| Pairwise, quadratic, or multi-hop across scattered sources | Decompose, even under 30k tokens |
| 10+ files or 50k+ tokens | Decompose |
| Under 30k tokens and a localised answer | Read directly |
find), lines (wc -l), bytes (ls -lh), pages for PDFs.npx -y @firecrawl/anydoc FILE -o .firecrawl/FILE.md) from the Firecrawl convert-documents-to-markdown skill. Use cloud firecrawl parse for OCR (--ocr hosted / firecrawl parse), -Q, or -S. Never dump the binary into context. Cloud parse caps at 50 MB and about 1 credit per PDF page; split first if larger.grep -n "function") and bodies later; tables of contents and abstracts before full text| Need | Use |
|---|---|
| Find files | the file search or glob tool, or find |
| Find content | the content search or grep tool, never a full read |
| Size | wc -l, ls -lh, page count (pdfinfo if present) |
| Read | the file reader with an offset and a limit, or sed -n 'START,ENDp' |
| PDF or Office file | anydoc first (npx -y @firecrawl/anydoc FILE -o .firecrawl/out.md), then grep the markdown. Cloud firecrawl parse for OCR, -Q, or -S. Else pdfinfo and a split. Never a full binary read |
| Delegate | the sub-agent or task tool, one brief per batch |
| Aggregate | a scratch file or structured notes, then one final pass |
Tool names differ between agents (Claude Code, Codex, Cursor, Gemini CLI); map the row to your agent's equivalent.
"Find all error handling patterns." Glob the source files, grep catch|throw|Error|except, batch the matches by module (5 to 10 files), one sub-agent per batch with a fixed report schema, merge into a categorised summary with file references. Worked example: references/codebase-analysis.md.
"What features are planned across all PRDs?" Glob the documents, size them, define an extraction schema (name, priority, status, quarter), one sub-agent per document group, deduplicate and categorise, spot-check three entries against the sources. Worked example: references/document-aggregation.md.
"Summarise all TODO comments." Grep TODO|FIXME|HACK, group by module, extract context and priority per group, produce a prioritised list.
Glob *.pdf, size bytes and page count (pdfinfo). Over 100 pages or 30 MB: do not ingest. Convert with anydoc to .firecrawl/ (Firecrawl skill convert-documents-to-markdown), then grep and chunk the markdown. If anydoc exits 3 (scanned pages), rerun with --ocr hosted or firecrawl parse (Firecrawl skill firecrawl-parse, 50 MB / ~1 credit per page). Batch by document, depth 1, spot-check titles against PDF metadata.
A one-page convert-to-markdown job is not this skill. Hand it to anydoc or firecrawl parse alone.
Split the output into sections, generate each independently, store intermediate results in a file, stitch them with a coherence pass.
Decomposition spends coordination tokens. In the paper (arXiv:2512.24601, Table 1 and Figure 1), RLM(GPT-5, depth=1) scored 91.3% on BrowseComp-Plus (6 to 11M tokens) at $0.99 average, versus 70.5% for compaction. On OOLONG it beat GPT-5 by 28.4%. On OOLONG-Pairs it reached 58.0% F1 against a 0.1% base. Figure 1 scales inputs from 2^13 to 2^20 tokens. Median cost stays comparable to the base model; averages can rise on outlier trajectories. Thresholds: references/cost-analysis.md.
| Anti-pattern | Fix |
|---|---|
| Reading everything first "to get context" | Size, filter, then read by range |
| Dumping a PDF binary into the window | Parse to markdown, then grep and chunk |
| Decomposing a single needle or one-file lookup | Read directly |
| Sub-agents without the question or the schema | Self-contained briefs |
| Sub-agents that spawn sub-agents | Depth 1: they answer, they do not delegate |
| Trusting the merged answer | Spot-check on a small window |
| Re-querying the same content in several sub-agents | Partition once, disjoint batches |
evals/README.md (opens in a new tab)evals/evals.json (opens in a new tab)evals/gold/pdf-corpus.json (opens in a new tab)evals/trigger-queries.json (opens in a new tab)references/codebase-analysis.md (opens in a new tab)references/cost-analysis.md (opens in a new tab)references/document-aggregation.md (opens in a new tab)references/rlm-strategies.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub massimodeluisa/recursive-decomposition-skill --plugin recursive-decompositionOther plugins' skills for the same job