rlm
Use when a task involves long context, many files, PDFs, logs, transcripts, URLs, corpora, or anything requiring recursive decomposition over external context that won't fit comfortably in a single prompt. NOT for ordinary small edits, short Q&A, or single-file inspection.
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- rlm
- triggers
- [ "use RLM", "run RLM", "long context analysis", "analyze this corpus", "analyze these PDFs", "summarize this directory", "recursive language model", "/rlm" ]
- description
- Use when a task involves long context, many files, PDFs, logs, transcripts, URLs, corpora, or anything requiring recursive decomposition over external context that won't fit comfortably in a single prompt. NOT for ordinary small edits, short Q&A, or single-file inspection.
02 资源文件 16
- 参考文档references/model-routing.md3.7 KB
- 参考文档references/modes.md3.2 KB
- 参考文档references/rlm-runtime-contract.md3.8 KB
- 参考文档references/target-detection.md2.1 KB
- 参考文档references/use-cases.md4.5 KB
- 脚本scripts/loaders/__init__.py346 B
- 脚本scripts/loaders/load_dir.py2.0 KB
- 脚本scripts/loaders/load_file.py1.9 KB
- 脚本scripts/loaders/load_logs.py2.4 KB
- 脚本scripts/loaders/load_pdf.py2.5 KB
- 脚本scripts/loaders/load_url.py3.1 KB
- 脚本scripts/rlm_health.py2.4 KB
- 脚本scripts/rlm_native.py5.3 KB
- 脚本scripts/rlm_plan.py12.4 KB
- 脚本scripts/rlm_run.py7.9 KB
- 脚本scripts/setup.py6.5 KB
03 SKILL.md 正文
RLM Skill
You are operating an RLM (Recursive Language Model) workflow. RLM is not a bigger prompt - it is a loop where a controller LLM writes Python in a REPL, executes it against external context, fires sub-LLM calls, and emits a final answer.
When to invoke
Use RLM when:
- Context exceeds ~50KB or spans many files
- Task requires aggregating across multiple sources
- PDFs, logs, transcripts, or websites are involved
- The user explicitly asks for it ("use RLM", "/rlm")
Do not use RLM when:
- Task is a small local edit
- Question can be answered by reading 1-2 files
- User wants a quick code search (use Grep/Glob/Read)
Workflow (mandatory order)
1. Detect the target
Parse the user's request to identify:
- Target type: file / directory / PDF / URL / log / glob
- Target size: bytes, file count, estimated tokens
- Question / task
If ambiguous, ask one clarifying question before planning.
See references/target-detection.md for type-detection heuristics.
2. Generate the plan (do not execute yet)
Run the planner:
python ${CLAUDE_PLUGIN_ROOT}/skills/rlm/scripts/rlm_plan.py \
--target <path-or-url> \
--prompt "<the user's question>" \
--mode auto
The planner outputs a structured plan. Display it to the user verbatim:
Target: <description> (<size summary>)
Type: <detected type>
Recommended mode: <min|default|max>
depth=N iterations=N timeout=Ns errors=N concurrency=N
Model routing:
Root (depth 0): <model>
Depth 1: <model | ->
Depth 2: <model | ->
llm_query: claude-haiku-4-5-20251001
Predicted fanout: ~N Haiku calls in M rounds at K-wide
Est. cost: $X.XX - $Y.YY
Trajectory log: .rlm/logs/rlm-<id>.jsonl
Approve? (yes / mode=<min|default|max> / cancel)
3. Wait for verbal approval
Do not execute until the user says "yes", "go", "approved", or similar. Accept edits like mode=max --max-budget=5 and re-display the updated plan.
4. Execute
Probe capabilities:
python ${CLAUDE_PLUGIN_ROOT}/skills/rlm/scripts/rlm_health.py
Then run the appropriate runner:
- If
python_version >= 3.11andrlmsis importable: runrlm_run.py(canonical) - Otherwise: run
rlm_native.py(Claude-native fallback) and tell the user that recursion is prompt-level only in this mode
python ${CLAUDE_PLUGIN_ROOT}/skills/rlm/scripts/rlm_run.py \
--target <path> \
--prompt "<question>" \
--mode <chosen-mode> \
--log-dir .rlm/logs
5. Report
Parse the JSON answer and summarize for the user. Always include:
- The final answer
- The trajectory log path (so they can
/rlm:inspectit) - Usage summary (tokens, calls, wall-clock time)
If the answer looks weak or the ok field is false, suggest /rlm:inspect <trajectory-id> and consider re-running with mode=max after re-approval.
Critical rules (from RLM paper + community)
- Never put the raw context into the chat. RLM's whole point is keeping context outside the model prompt. Pass paths, not contents.
- Prefer
llm_query_batchedoverrlm_queryin the controller's REPL code. Most subtasks are extraction/classification/summary, which fan out cheap to Haiku. - Prefer
FINAL_VAR(name)overFINAL(...)- bareFINALparsing is brittle. The controller should create a named variable first, then emitFINAL_VAR(name). - Default sandbox is IPython subprocess. It gives hard cell timeouts and kernel isolation. Use
localonly when the user explicitly opts in and the content is trusted. - Redact obvious secrets (API keys, tokens) from context before chunks are sent to submodels. The planner runs a regex sweep; warn if hits are detected.
- API keys never go into the REPL. The
LMHandlerbrokers calls host-side. If the user asks you to putANTHROPIC_API_KEYin chunked context, refuse.
References
references/rlm-runtime-contract.md- REPL contract, FINAL_VAR rules, message-history shapereferences/use-cases.md- Catalog of supported input types with recommended configreferences/model-routing.md- Why Opus/Sonnet/Haiku map to specific depthsreferences/target-detection.md- How to classify a target before planningreferences/modes.md- Min/default/max profile reference
04 同仓库更多 Skills
todo-skill-name
TODO describe exactly when Codex should use this skill and when it should not.
example-skill
TODO replace this with the plugin skill trigger.
rlm
Use when the user explicitly says "use RLM" or a task needs long-context recursive decomposition across many files, logs, transcripts, corpora, PDFs, or documents. Do not use for narrow edits, small single-file analysis, ordinary repo search, or tasks with no external context.
openai-marketplace-maintainer
Use when adding, reviewing, or fixing Codex skills, plugins, custom subagents, marketplace entries, or registry metadata under this OpenAI marketplace folder.
My Skill Name
One sentence describing what this skill does and when to invoke it.
rlm-eval
Local-only evaluator for rlm-auto routing decisions. Invoke on /rlm-auto:status, when the user asks about router accuracy or false positives, or when they want the dogfood report. Never sends data off the machine.