AgentSkillsCN

rlm-reasoning

应用受埃隆·马斯克启发的系统设计思维,运用于科研、工程与业务流程:严谨质疑需求、删减冗余步骤、简化并优化剩余环节、加速迭代,再通过自动化手段提升效率。在设计或优化需要精益高效执行的系统、流程或产品时,可加以运用。

SKILL.md
--- frontmatter
name: rlm-reasoning
description: Apply RLM (Recursive Language Model) reasoning pattern for large context processing. Use when analyzing large files, codebases, or documents. Triggers on "RLM pattern", "large file analysis", "selective reading", "PROBE EXTRACT CONFIRM", or when dealing with files over 1000 lines.
allowed-tools:
  - Read
  - Grep
  - Glob
  - Task
  - Bash

RLM (Recursive Language Model) Reasoning Pattern

Based on Zhang et al., MIT CSAIL (arXiv:2512.24601)

Core Principle: Context Outside, Not Inside

Never load entire large files into context. Instead, keep data "outside" and access selectively.

4-Step Reasoning Pattern

1. PROBE (Explore)

Search for relevant areas using keywords before reading:

code
Grep for keywords to find relevant lines
Glob to find related files by pattern

Example:

code
Grep(pattern="authentication", path="src/")
Glob(pattern="**/auth*.py")

2. EXTRACT (Load Selectively)

Only read the specific sections you need:

code
Read with offset/limit for specific line ranges
Load only chunks that contain matches

Example:

code
Read(file_path="src/auth/login.py", offset=50, limit=100)

3. CONFIRM (Verify)

Before answering, verify information against the source:

code
Re-check that found information matches the question
Validate references actually exist
Cross-reference multiple sources if needed

4. ANSWER (Respond)

Provide verified response based on confirmed evidence.

When to Apply This Pattern

SituationAction
File > 1000 linesPROBE first with Grep, never Read entire
Complex analysisDelegate to Task tool sub-agent
Code generationVerify imports/references exist with Grep
Multiple filesUse Glob to find, then selective Read

Anti-Patterns (Avoid)

code
# BAD: Loading entire file
Read("large_file.py")  # Don't do this!

# GOOD: Search first, then selective read
Grep("function_name", "src/")
Read("src/file.py", offset=150, limit=50)

Sub-Agent Delegation

For complex multi-step analysis, use Task tool:

code
Task(
    subagent_type="Explore",
    prompt="Find all authentication-related code and summarize the flow"
)

Verification Checklist

Before providing an answer:

  • Did I search before reading?
  • Did I read only necessary sections?
  • Did I verify references exist?
  • Is my answer based on confirmed evidence?

Additional Resources

Quick Commands

Run the RLM agent directly:

bash
python ~/.claude/skills/rlm-reasoning/scripts/rlm_query.py "your question" /path/to/file