dspy-rlm-module

dspy-rlm-module is a skill for Claude Code from intertwine/dspy-agent-skills. It costs 86 tokens per session (1,415 once invoked), scanned A, original, MIT.

A DSPy module for reasoning over very large codebases, logs, or documents by repeatedly exploring smaller parts in a sandboxed Python environment. DSPy is a Python framework for building language-model programs, and RLM means Recursive Language Model.

In plain words
What is it for?
Use it to inspect huge logs, find and count error types, explore large codebases, summarize long documents, and answer questions through iterative data analysis.
Why use it?
It helps when the material is too large to examine in one normal AI context window or needs repeated searching and summarizing.

Skill for Claude Code

Written for Claude Code: when-to-use in frontmatter.

Part of the dspy-agent-skills plugin — 5 skills shipped together

Good fit Use it to inspect huge logs, find and count error types, explore large codebases, summarize long documents, and answer questions through iterative data analysis.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/intertwine/dspy-agent-skills/dspy-rlm-module
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add intertwine/dspy-agent-skills --skill dspy-rlm-module
Clone the repo
git clone --depth 1 https://github.com/intertwine/dspy-agent-skills

Made for: Claude Code.

Or install dspy-agent-skills, the plugin that ships this one along with the rest of its 5 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dspy-rlm-module

README.md
[![agentmods](https://agentmods.dev/badge/skills/intertwine/dspy-agent-skills/dspy-rlm-module/github.svg)](https://agentmods.dev/skills/intertwine/dspy-agent-skills/dspy-rlm-module)
Your own site
<a href="https://agentmods.dev/skills/intertwine/dspy-agent-skills/dspy-rlm-module"><img src="https://agentmods.dev/badge/skills/intertwine/dspy-agent-skills/dspy-rlm-module/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dspy-rlm-module

Your own site · 80×15
<a href="https://agentmods.dev/skills/intertwine/dspy-agent-skills/dspy-rlm-module"><img src="https://agentmods.dev/badge/skills/intertwine/dspy-agent-skills/dspy-rlm-module.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 86 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,415 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00086 $0.01415
Opus 5 $0.00043 $0.00707
Sonnet 5 $0.00017 $0.00283
Haiku 4.5 $0.00009 $0.00142

Measured 10d ago against content hash 00f9899eb968, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

dspy-rlm-module scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (example_rlm.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

The default interpreter is a Deno-sandboxed Pyodide WASM runtime — no filesystem, network, or subprocess access by default. If you pass custom `tools` that do I/O, your tools' security posture is yours. Never hand raw `s
skills/dspy-rlm-module/SKILL.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

dspy.RLM — Recursive Language Model

dspy.RLM runs the LLM in a sandboxed Python REPL (Pyodide/WASM via Deno) with access to the full context as variables. The LLM writes code to slice, grep, summarize, and recursively sub-query the data, iterating until it can answer. Use it when the context is too large to cram into a single prompt.

Prerequisites

  • Deno installed (for the default PythonInterpreter): brew install deno or see https://deno.land. The interpreter is a Pyodide-in-WASM sandbox spawned by Deno.
  • A sub-LM for inner calls — usually a cheaper model than the outer LM. Defaults to dspy.settings.lm.

Canonical usage

import dspy

dspy.configure(lm=dspy.LM("openai/gpt-4o"))
sub_lm = dspy.LM("openai/gpt-4o-mini")    # cheap inner model

rlm = dspy.RLM(
    "context, query -> answer",
    max_iterations=20,
    max_llm_calls=50,
    max_output_chars=10_000,
    sub_lm=sub_lm,
    tools=[],
    verbose=False,
)

result = rlm(
    context=open("huge_log.txt").read(),   # can be 500k+ tokens
    query="Summarize every unique error class and how many times each appeared.",
)
print(result.answer)

Full constructor

dspy.RLM(
    signature: type[Signature] | str,
    max_iterations: int = 20,       # REPL loop cap
    max_llm_calls: int = 50,        # sub-LM call cap (stops runaway recursion)
    max_output_chars: int = 10_000, # truncate REPL stdout per step
    verbose: bool = False,          # print the REPL trace
    tools: list[Callable] | None = None,
    sub_lm: dspy.LM | None = None,
    interpreter: CodeInterpreter | None = None,  # custom sandbox
)

When to reach for RLM vs. alternatives

Situation Use
Context <100k, answer fits one LM call dspy.Predict / dspy.ChainOfThought
Need external tools (web, db) dspy.ReAct(tools=[...])
Math/code that must run dspy.ProgramOfThought
Huge context, recursive chunking, or data-exploration loop dspy.RLM
Entire-codebase reasoning where the LM should grep/read files dspy.RLM with file-reading tools=[...]

Read the full file on GitHub · 110 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 110 lines · 86 tokens per session scan A 00f9899eb968

Subscribe to this mod's changes

dspy-rlm-module is a skill published in the GitHub repository intertwine/dspy-agent-skills (277 stars, last pushed 4d ago), licensed MIT. It adds 86 tokens to every session and 1,415 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

accelerate

Run PyTorch training across GPUs with minimal changes.

NousResearch/hermes-agent · 13 tokens

developing-genkit-python

Develop AI-powered applications using Genkit in Python. Use when the user asks about Genkit, AI agents, flows, or tools in Python, or when encountering Genkit errors, import issues, or API problems.

google/skills · 49 tokens

optimize-for-gpu

GPU-accelerates scientific Python on NVIDIA hardware and verifies that the result is correct and faster. Use for CUDA/GPU optimization; CPU-bound NumPy, SciPy, pandas, scikit-learn, NetworkX, scikit-image, vector-search, image-processing, graph, simulation, or file-I/O workloads; CuPy, cuDF, cuML, cuGraph, cuVS…

K-Dense-AI/scientific-agent-skills · 151 tokens

marimo-pair

Work inside the user's live marimo notebook from the code editor: run Python in the same kernel the user does, inspect live notebook state, and commit durable notebook changes through code mode. Use whenever you create, analyze, or improve the user's marimo notebook.

marimo-team/marimo · 57 tokens

minicpm5-deploy-transformers

Run MiniCPM5-1B or MiniCPM5-2B with Hugging Face Transformers for one-shot Python generation on GPU (bfloat16) or CPU (float32). Use when the user wants a quick Python script, no server, no extra deps, or asks for "Transformers", "AutoModelForCausalLM", "model.generate" with MiniCPM5.

OpenBMB/MiniCPM · 90 tokens

azure-mgmt-fabric-py

Azure Fabric Management SDK for Python. Use for managing Microsoft Fabric capacities and resources. Triggers: "azure-mgmt-fabric", "FabricMgmtClient", "Fabric capacity", "Microsoft Fabric", "Power BI capacity".

microsoft/skills · 51 tokens