rlm

from rawwerks/rlm-cli

CLI for Recursive Language Models

27 stars1 forksUpdated Jan 25, 2026
npx skills add https://github.com/rawwerks/rlm-cli --skill rlm

SKILL.md

RLM CLI

Recursive Language Models (RLM) CLI - enables LLMs to handle near-infinite context by recursively decomposing inputs and calling themselves over parts. Supports files, directories, URLs, and stdin.

Installation

pip install rlm-cli    # or: pipx install rlm-cli
uvx rlm-cli ask ...    # run without installing

Set an API key for your backend (openrouter is default):

export OPENROUTER_API_KEY=...  # default backend
export OPENAI_API_KEY=...      # for --backend openai
export ANTHROPIC_API_KEY=...   # for --backend anthropic

Commands

ask - Query with context

rlm ask <inputs> -q "question"

Inputs (combinable):

TypeExampleNotes
Directoryrlm ask . -q "..."Recursive, respects .gitignore
Filerlm ask main.py -q "..."Single file
URLrlm ask https://x.com -q "..."Auto-converts to markdown
stdingit diff | rlm ask - -q "..."- reads from pipe
Literalrlm ask "text" -q "..." --literalTreat as raw text
Multiplerlm ask a.py b.py -q "..."Combine any types

Options:

FlagDescription
-q "..."Question/prompt (required)
--backendProvider: openrouter (default), openai, anthropic
--model NAMEModel override (format: provider/model or just model)
--jsonMachine-readable output
--output-formatOutput format: text, json, or json-tree
--summaryShow execution summary with depth statistics
--extensions .py .tsFilter by extension
--include/--excludeGlob patterns
--max-iterations NLimit REPL iterations (default: 30)
--max-depth NRecursive RLM depth (default: 1 = no recursion)
--max-budget N.NNSpending limit in USD (requires OpenRouter)
--max-timeout NTime limit in seconds
--max-tokens NTotal token limit (input + output)
--max-errors NConsecutive error limit before stopping
--no-indexSkip auto-indexing
--exaEnable Exa web search (requires EXA_API_KEY)
--inject-file FILEExecute Python code between iterations

JSON output structure:

{"ok": true, "exit_code": 0, "result": {"response": "..."}, "stats": {...}}

JSON-tree output (--output-format=json-tree): Adds execution tree showing nested RLM calls:

{
  "result": {
    "response": "...",
    "tree": {
      "depth": 0,
      "model": "openai/gpt-4",
      "duration": 2.3,
      "cost": 0.05,
      "iterations": [...],
      "children": [...]
    }
  }
}

Summary output (--summary): Shows depth-wise statistics after completion:

  • JSON mode: adds summary field to stats
  • Text mode: prints summary to stderr
=== RLM Execution Summary ===
Total depth: 2 | Nodes: 3 | Cost: $0.0054 | Duration: 17.38s
Depth 0: 1 call(s) ($0.0047, 13.94s)
Depth 1: 2 call(s) ($0.0007, 3.44s)

complete - Query without context

rlm complete "prompt text"
rlm complete "Generate SQL" --json --backend openai

search - Search indexed files

rlm search "query" [options]
FlagDescription
--limit NMax results (default: 20)
--language pythonFilter by language
--paths-onlyOutput file paths only
--jsonJSON output

Auto-indexes on first use. Manual index: rlm index .

index - Build search index

rlm index .              # Index current dir
rlm index ./src --force  # Force full reindex

doctor - Check setup

rlm doctor       # Check config, API keys, deps
rlm doctor --json

Workflows

Git diff review:

git diff | rlm ask - -q "Review for bugs"
git diff --cached | rlm ask - -q "Ready to commit?"
git diff HEAD~3 | rlm ask - -q "Summarize changes"

Codebase analysis:

rlm ask . -q "Explain architecture"
rlm ask src/ -q "How does auth work?" --extensions .py

Search + analyze:

rlm search "database" --paths-only
rlm ask src/db.py -q "How is connection pooling done?"

Compare files:

rlm ask old.py new.py -q "What changed?"

Configuration

Precedence: CLI flags > env vars > config file > defaults

Config locations: ./rlm.yaml, ./.rlm.yaml, ~/.config/rlm/config.yaml

backend: openrouter
model: google/gemini-3-flash-preview
max_iterations: 30

Environment variables:

  • RLM_BACKEND - Default backend
  • RLM_MODEL - Default model
  • RLM_CONFIG - Config file path
  • RLM_JSON=1 - Always output JSON

Recursion and Budget Limits

Recursive RLM (--max-depth)

Enable recursive llm_query() calls where child RLMs process sub-tasks:

# 2 levels of recursion
rlm ask . -q "Research thoroughly" --max-depth 2

# With budget cap
rlm ask . -q "Analyze codebase" --max-depth 3 --max-budget 0.50

Budget Control (--max-budget)

Limit spending per completion. Raises `BudgetExceededErr

...

Read full content

Repository Stats

Stars27
Forks1