massimodeluisa/recursive-decomposition-skill / skills/recursive-decomposition
recursive-decomposition
VerifiedDecompose dense codebase-wide, multi-document, PDF, and aggregation work even when the input fits the context window, following Recursive Language Models (Zhang, Kraska, Khattab, 2025). Use when the user asks to analyse all files, a whole repo, all docs, large PDFs, or to aggregate or multi-hop across scattered sources. Skip one file, one function, a single needle, or a one-page PDF conversion. Triggers: long context, context rot, large codebase, many files, all files, big document, multi-document, PDF, aggregate, summarize everything, codebase-wide, multi-hop, recursive, sub-agents, map-reduce.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.5 KB |
| evals/README.md | markdown | 2.3 KB |
| evals/evals.json | config | 1.2 KB |
| evals/gold/pdf-corpus.json | config | 253 B |
| evals/trigger-queries.json | config | 3.0 KB |
| references/codebase-analysis.md | markdown | 2.9 KB |
| references/cost-analysis.md | markdown | 3.8 KB |
| references/document-aggregation.md | markdown | 3.5 KB |
| references/rlm-strategies.md | markdown | 4.9 KB |
references/cost-analysis.md
View on GitHub# Cost and when to decompose
When to read directly, when to split the work, and what the paper actually measured. Paper figures: Zhang, Kraska, Khattab, Recursive Language Models, arXiv:2512.24601 (v3).
30k and 50k below are harness caps, not a claim that a bigger window removes rot. Density first. In the paper, OOLONG-Pairs is 32k tokens (arXiv:2512.24601, Table 1).
## Decision
| Situation | Approach |
|-----------|----------|
| One file, one function, or a single needle | Read directly |
| Linear aggregate or list-everything, and completeness matters | Decompose |
| 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 |
Skip decomposition when the answer is one needle, when latency matters more than completeness, or when coordination would cost more than a direct read.
Recursion depth is 1. Sub-agents must not launch sub-agents. Write the batch count, run one parallel wave, merge, then another wave if batches remain.
## What you pay for
Direct: one call, input tokens times the price. Quality falls as the window fills (context rot).
Decomposed: sum of sub-call tokens plus the parent coordinating them. Latency is the slowest batch plus the merge, if batches run in parallel. Quality holds if each batch stays small and the merge is checked.
## Paper costs (Table 1, Figure 11)
BrowseComp-Plus, 6 to 11M tokens, GPT-5:
- RLM(depth=1): 91.3% at $0.99 average ($1.22 std)
- compaction: 70.5% at $0.57 average
- GPT-5 base: hits the context limit (0.0*)
- linear extrapolation of GPT-5-mini ingesting that input: $1.50 to $2.75
RLM is not cheaper than compaction on that row. It is cheaper than stuffing 6 to 11M tokens into the model, and the paper reports it outperforms compaction and retrieval by over 29%.
OOLONG (131k tokens): RLM(GPT-5, depth=1) 56.0 versus GPT-5 44.0 (+28.4%). RLM(Qwen3-Coder, depth=1) 48.0 versus 36.0 (+33.3%).
OOLONG-Pairs (32k tokens): GPT-5 F1 0.1 versus RLM 58.0 at depth=1 (76.0 at depth=3).
Median RLM cost is comparable or lower than the base model (Figure 11, 50th percentile). The average can sit higher because of long outlier trajectories. The 95th percentile of runtime is dominated by sequential sub-LLM calls. The paper does not publish a 99th-percentile multiplier.
## Parallel batches
If batches are independent:
```text
serial: T = t1 + t2 + ... + tn
parallel: T = max(t1, t2, ..., tn) + merge
```
Toy timing, not a paper result: ten batches at 30 seconds each, 10-second merge. Serial 300 seconds, parallel about 40.
## Variance
RLM trajectories are long-tailed (paper, Observation 4 and Figure 11). Common causes: too many sub-calls, the same span processed twice, deep recursion, clumsy chunks.
Caps that help: a sub-call budget, disjoint partitions, a depth limit, a running token count.
## Cut cost before you recurse
Filter first. A 1000-file tree that greps down to 20 files is a cheaper problem. The 10x in that sketch is arithmetic on the example, not a measured speedup.
For aggregates, sample a slice. If the distribution is obvious, stop. If it is not, process the rest.
For search, stop when the answer is found, then verify. Do not finish the remaining batches out of habit.
If the same tree will be queried again, cache per-chunk notes and drop them when the source changes.
## Tool choice
| Job | Approach |
|-----|----------|
| One file by name | glob or find, then read |
| One function definition | grep, then read that range |
| One module | read it and follow imports |
| About 5 related files | read them |
| A pattern across the tree | grep, then decompose the hits |
| Aggregate across 50+ files | disjoint batches, parallel sub-agents |
| Multi-hop across scattered sources | this skill |
Read directly on the first four rows. The last three are why the skill exists.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |