Decompose dense codebase-wide, multi-document, and large-PDF work even when it fits the window. Depth-1 sub-agents, then verify. Based on Recursive Language Models (Zhang, Kraska, Khattab, arXiv:2512.24601).
Decompose dense codebase-wide, multi-document, and large-PDF work even when it fits the window. Depth-1 sub-agents, then verify. Based on Recursive Language Models (Zhang, Kraska, Khattab, arXiv:2512.24601).
Decompose long-context tasks while keeping the context small.
An Agent Skill for Claude Code, Codex, Cursor and compatible agents, based on the Recursive Language Models research
Large codebases, dozens of documents, long reports: as the context grows, models miss details, link distant parts by guesswork and lose accuracy. The Recursive Language Models paper calls it context rot.
What it does
When a task is codebase-wide, multi-document, a pile of PDFs, or a dense aggregate, even if it fits the window, the skill makes the agent treat the input as an environment to query instead of text to swallow:
Size the input before reading anything.
Filter the search space with searches, not reads.
Chunk what remains into batches of 5 to 10 files or natural units.
Recurse at depth 1 with one sub-agent per batch, each with a self-contained brief. Sub-agents do not spawn sub-agents.
Verify the merged answer on a small window against the sources.
Synthesise programmatically, with file and line references.
PDFs go through anydoc first (npx -y @firecrawl/anydoc FILE -o .firecrawl/out.md), then grep the markdown. Cloud firecrawl parse is for OCR, -Q, or -S. A one-page convert job is not this skill.
Add -g for a user-level install, -a claude-code (or another agent) to target one agent.
As a Claude Code plugin:
claude plugin marketplace add massimodeluisa/recursive-decomposition-skill
claude plugin install recursive-decomposition@recursive-decomposition-skill
Manual: copy skills/recursive-decomposition into ~/.claude/skills/ (or your agent's skills directory) and restart the agent.
Usage
/recursive-decomposition applies the protocol to the current task.
/recursive-decomposition src/ sizes that input first, then runs the protocol.
The skill also activates on its own for prompts like:
Analyze error handling patterns across this entire codebase
Find all TODO comments in the project and categorize by priority
What API endpoints are defined across all route files?
Summarize the key decisions from all meeting notes in docs/
Find security issues across all Python files
How it works
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
RLM runs were about 3x cheaper than summarisation baselines.
Eval
Fixture is a git submodule, not files copied into this repo: tccao/mortgage-doc-rag (MIT), 131 public-domain mortgage PDFs, about 63 MB. Thanks to that project for the corpus.