rlm
Skill0 starsChanged 3 months agoMITView on GitHub
Work with input far larger than the context window — a huge file, a giant log or JSON dump, a whole repo, a database export, a long transcript, or any task where reading everything would blow the context. Use when a file is too large to read, when a Read got truncated, when the answer is somewhere in gigabytes of text, when asked to analyze or audit an entire codebase or log, or for long-horizon work spanning many files. Keeps the blob on disk as a variable and returns only bounded slices. Also on "recursive language model", "RLM", "context as a variable", "too big to read", "won't fit in context", "search this huge file".
12 other projects use a version of this.
Adopted by
Most recently taken up by
- osick/ctx.skillstheir own version, first seen Oct 13, 2026
- Trampoline-AI/predict-rlmtheir own version, first seen Oct 8, 2026
- brainqub3/claude_code_RLMtheir own version, first seen Oct 8, 2026
- saint0x/my-skillstheir own version, first seen Aug 29, 2026
- brainqub3/RLMtheir own version, first seen Jun 22, 2026
- Jinshi1945/claude_code_RLMtheir own version, first seen Feb 22, 2026
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- Trampoline-AI/predict-rlm★ 436same name
- brainqub3/claude_code_RLM★ 393same name
- brainqub3/RLM★ 393same name
- Tenobrus/claude-rlm★ 94same name
- richardwhiteii/rlm★ 49same name
- andremoreira73/Useful-Skills-from-lyfX★ 8same name
- endjin/RLM★ 6same name
- Jinshi1945/claude_code_RLM★ 1same name
- rgoldr88/claude-rlm★ 1same name
- saint0x/my-skills★ 1same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 33
Every command announces what it withheld — [capped: showing 40 of 4950 hits].
- Distinctive: line 41
Read returns a prefix with no marker in the content, so the answer gets built from the first slice and reported as if the file had been …
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
rlm — context as a variable
The blob stays on disk. You pull bounded slices out of it. It never enters your context whole, so its size stops being your problem.
This is prime-agent's RLM idea in the shape this harness allows: they give the
model one tool (a persistent IPython kernel) and make rlm() a Python call.
Here, the slicer is a script and the recursive half is Workflow — where
agent() already is rlm(), a subagent spawned as a function call.
The rule
Never Read a file over ~50k tokens. Map it, grep it, slice what grep found.
R=~/.claude/skills/rlm/rlm.py
python3 $R map FILE # what's in here, what would it cost
python3 $R grep FILE PATTERN # where the answer lives (locations, not content)
python3 $R slice FILE START END # read only that rangeOne pass, streaming, bounded output. Flags: --max (output lines),
--width (chars per line), --regex, --case.
map prints DO NOT read whole above ~100k tokens. Believe it.
Every command announces what it withheld — [capped: showing 40 of 4950 hits].
A cap you can't see reads as "that was everything", which is how a partial
answer gets reported as a complete one.
It is enforced, not advised
A PreToolUse hook denies a Read over 2000 lines when no offset/limit
was given, and names the command to run instead. That case is the whole point:
Read returns a prefix with no marker in the content, so the answer gets built
from the first slice and reported as if the file had been read.
The prompt matcher can't catch this — it scores the prompt and never sees a
tool call, so a 4 GB log discovered three calls into a task is invisible to it.
Explicit Read(offset/limit) is always allowed; that's paging on purpose.
Tune with RLM_MAX_LINES (default 2000) and RLM_MIN_BYTES (default 102400,
the size below which the line count isn't worth paying for).
The loop
map— orient. Size, token cost, structural lines spread across the file.grep— locate. You get line numbers, not the file.slice— read the one range that matters, and nothing either side of it.- Still too big? That's the recursive half: fan the ranges out to subagents
via
Workflow, oneagent()per range, and keep only what they return. The blob never lands in any single context — not yours, not theirs.
A million-token file becomes three bounded reads and a handful of subagent results. That is the whole trick.
Why Python
Measured on this machine, 2026-08-11, 793 MB blob, same substring search, interleaved runs:
| time | peak RSS | |
| python3, streaming | 1.95–2.41 s | 12.7 MB |
| ripgrep 14.1.1 (Rust) | 3.45–5.24 s | 500–650 MB |
Ripgrep lost on a 3.6 GB box already in swap — its buffering wants half a gig, and the machine, not the instruction count, is the binding constraint. Real corpus: a 43 MB / 11.2M-token transcript maps in 0.21 s at 16 MB.
metal routes it the same way independently — this is a dispatch layer, never
a compute layer, and a one-shot script run by hand is question 2. It flips
to Rust the moment it becomes resident: a daemon holding context across
turns is question 1, and that is a different project, not a rewrite of this.
Boundaries
For files that fit comfortably, Read is better — it's one call and you get
the whole thing. This earns its place only when the input is genuinely larger
than the context, and reaching for it on a 200-line file is ceremony.
python3 rlm.py --selftest verifies the caps hold.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

