Skip to content

Recursive Decomposition Skill

Claude Code skill for handling long-context tasks through recursive decomposition

Install

$npx skills add massimodeluisa/recursive-decomposition-skill
Claude Code
claude mcp add recursive-decomposition-skill -- npx skills add massimodeluisa/recursive-decomposition-skill
Cursor / Claude Desktop (mcp.json)
{
  "mcpServers": {
    "recursive-decomposition-skill": {
      "command": "npx",
      "args": [
        "skills",
        "add",
        "massimodeluisa/recursive-decomposition-skill"
      ]
    }
  }
}

Install command taken from the project's README or registry entry. Always review code before running it.

Recursive Decomposition Skill

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

Install · Usage · How it works · Eval · Structure · Acknowledgments


The problem

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:

  1. Size the input before reading anything.
  2. Filter the search space with searches, not reads.
  3. Chunk what remains into batches of 5 to 10 files or natural units.
  4. Recurse at depth 1 with one sub-agent per batch, each with a self-contained brief. Sub-agents do not spawn sub-agents.
  5. Verify the merged answer on a small window against the sources.
  6. 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.

Install

With the skills CLI:

npx skills add massimodeluisa/recursive-decomposition-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 Decompose, even under 30k tokens
10+ files or 50k+ tokens Decompose
Under 30k tokens and a localised answer Read directly

Results reported in the paper:

Task Direct model With RLM
Multi-hop QA (6 to 11M tokens) 70% 91%
Linear aggregation baseline +28 to 33%
Quadratic reasoning under 0.1% 58%
Context scaling 2^14 tokens 2^18 tokens

RLM runs were about 3x cheaper than summarisation baselines.

Eval

Similar plugs

Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local…

Why use many token when few token do trick. Viral skill + proxy for coding agents that cuts 65% of tokens by talking like a caveman.

The 1st Collaborative AI Design Agent Workspace. Local-first and open source. Create prototypes, websites, apps, dashboards, presentations, images, and videos with your team…