rlm
БесплатноЗапускает вложенные скриптыНе проверенRecursive Language Model (RLM) loop for processing a context that is too large to read into the conversation directly. Loads the context as a variable in a…
Об этом скилле
rlm — Recursive Language Model loop
A faithful instantiation of Recursive Language Models (Zhang, Kraska, Khattab; arXiv:2512.24601), Algorithm 1, on Claude Code's primitives. The paper's insight: an arbitrarily long prompt should not be fed into a model's context window at all. It should live in an environment the model interacts with programmatically, recursively calling a model over slices of it. That's what this skill does.
Mental model
You (the main Claude Code conversation) are the root model. You do not read the big context into this conversation. Instead:
- The context lives as a
contextvariable inside a persistent Python REPL (scripts/rlm_repl.py). You only ever see metadata about it (length, a short prefix) and the truncated stdout of code you run — never the whole thing. This is the one rule that lets the context be far larger than any window. - You answer by writing REPL code that probes the context, decomposes it, and
calls a cheap sub-LM over the pieces:
llm_query(prompt)/llm_query_map(prompts)— a single / a parallel batch of plain sub-LM calls (a nested headlessclaude -p, tools off). This is the leaf: it reads a bounded chunk in its own window and returns text.rlm_query(context, query)— a full recursive RLM over a sub-context, for sub-tasks that are themselves too big for one leaf call (depth > 1). Falls back tollm_queryat the depth limit.
- You build intermediate results into REPL variables/buffers, then return the
answer by setting it in the REPL:
FINAL(answer)orFINAL_VAR(varname).
The division of labour that makes this work: the LLM does the semantics (classify this question, extract this fact, summarise this section); your Python does the bookkeeping (loop over every chunk, count, aggregate, format). Do not ask the LLM to count or do arithmetic over the whole corpus, and do not try to do the semantics yourself in Python with keyword heuristics — that is exactly the failure mode the paper's ablations show. Split the work along that seam.
When to use this
Use it when the context won't fit comfortably in the conversation and the task
needs broad access to it: aggregation/counting over every item, labelling every
row, multi-hop questions across a corpus, whole-document summarisation, or
"the answer depends on almost every line". For a one-off needle lookup in a file
you can just grep, you don't need this.
Inputs ($ARGUMENTS)
context=<path>(required): path to the large context file.query=<question>(required): what to answer about it.- Optional:
sub_model=<alias>(defaulthaiku),max_workers=<int>(default 8),max_depth=<int>(default 1; >1 enables recursiverlm_query).
If the user didn't supply them, ask for the context file path and the query.
Set optional knobs via environment before running, e.g.:
export RLM_SUB_MODEL=haiku RLM_MAX_WORKERS=8 RLM_MAX_DEPTH=1.
The loop (Algorithm 1)
Run these via the Bash tool. State persists between calls in
.claude/rlm_state/state.pkl. By default, init also creates a standalone
audit replay package under .claude/rlm_runs/<run_id>/; every exec saves the
submitted Python as steps/step_XXXX.py.
1. Initialise — load the context, read only its metadata
python .claude/skills/rlm/scripts/rlm_repl.py init <context_path>
This prints the context's type, char/line/token estimate, and a short prefix.
Do not read the context file with the Read tool — that defeats the purpose.
It also prints the audit replay package path. Use --no-audit only when you do
not want standalone step scripts.
2. Probe — understand the format with small, cheap code
Look at the shape of the data before deciding a strategy. Print small slices and structure, not the bulk:
python .claude/skills/rlm/scripts/rlm_repl.py exec <<'PY'
print(peek(0, 1500)) # head
lines = [l for l in content.splitlines() if l.strip()]
print("lines:", len(lines))
print("sample:", lines[1] if len(lines) > 1 else "")
PY
Ask: Is it line-oriented? JSON objects? Markdown sections? Logs with timestamps? The format dictates the chunking.
3. Decompose + sub-query — write code that calls the LLM over chunks
This is the core. Chunk the context, build one prompt per chunk, and fan the
semantic work out to the sub-LM with llm_query_map (parallel). Keep the
chunks fat (a leaf can hold a large slice — batch to minimise call count) but small
enough that the sub-LM stays accurate. Accumulate results in a variable; let Python
do the aggregation.
python .claude/skills/rlm/scripts/rlm_repl.py exec <<'PY'
# Example shape for an aggregation task: derive records from the actual format,
# ask leaf LMs for semantic labels, then count/aggregate in Python.
records = [line.strip() for line in content.splitlines() if line.strip()]
# Fill these from the user's query and what you
Установить rlm в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
BashReadWriteEditGrepGlobВложенные файлы
FAQ
Что делает скилл rlm?
Recursive Language Model (RLM) loop for processing a context that is too large to read into the conversation directly. Loads the context as a variable in a persistent Python REPL and answers the query by writing code that probes, chunks, and programmatically sub-queries a cheap LLM (`llm_query`) over slices of it, then aggregates. Use this WHENEVER the user points you at a big context file/log/transcript/codebase/scraped corpus (anything from ~50K chars up to millions) and asks a question that needs most of the content -- counting, aggregating, classifying every item, multi-hop lookup, or summarising the whole thing -- ESPECIALLY when the answer "depends on almost every line" and a single retrieval/grep won't do. Trigger it even if the user doesn't say "RLM": phrases like "this file is huge", "go through the whole log", "how many X across all of these", "label every row", or "it won't fit in context" are all signals to use this skill. Prefer it over dumping the file into chat.
Как установить скилл rlm?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rlm запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic