Skip to main content

Process large codebases using the RLM (Recursive Language Model) pattern

Project description

coderlm

Process large codebases with Coding Agents using the RLM (Recursive Language Model) pattern — with bundled context guards to keep the agent's output from flooding its own context window.

Instead of stuffing all files into an LLM's context window, give it a file listing and let it use tools to peek, decompose, and recursively call itself on subsets. This keeps each agent focused on a manageable scope while covering arbitrarily large codebases.

Install

# npm / bun
bunx coderlm@latest
npx coderlm@latest

# pypi
uvx coderlm
pipx run coderlm

Or install globally:

npm i -g coderlm    # npm
uv tool install coderlm  # pypi

Usage

coderlm <agent> <globs...> --prompt "<task>" [--max-depth N] [--allowedTools TOOLS]

Examples

# Codex
coderlm codex "src/**/*.ts" --prompt "Find all TODO comments"
coderlm codex "src/**" "lib/**" "test/**" --prompt "Find dead code"
coderlm codex "**/*.ts" --prompt "Summarize the codebase" --max-depth 2

# Gemini
coderlm "bunx --bun @google/gemini-cli" "**/*.py" --prompt "Review for security issues"
coderlm "bunx --bun @google/gemini-cli" "src/**" --prompt "Architecture overview"

# Claude (non-recursive only — Claude cannot spawn nested Claude sessions)
coderlm claude "src/**" --prompt "Fix type errors" --allowedTools "Bash,Edit"

How It Works

  1. Expand globs into a file listing using fd (or find as fallback)
  2. Build a system prompt containing the file list and RLM instructions (explore, decompose, aggregate)
  3. Inject context guards via BASH_ENV so every bash subshell the agent spawns has output truncation active
  4. Launch the agent with agent-specific flags for non-interactive execution

The agent receives a file listing — not file contents. It uses shell tools (rg, cat, head, jq, etc.) to inspect files as needed. For large file sets (>20 files), it spawns recursive sub-agents on subsets.

Context Guards (bundled)

bashrlm.sh is bundled and auto-activates for every agent run. It wraps high-output commands (cat, grep, rg, jq, find, ls, curl, etc.) with automatic truncation, preventing the agent from flooding its own context window with oversized output.

Truncation uses head+tail mode — the agent sees the start and end of any large output, with the middle omitted:

[TRUNCATED — showing 2000 of 15000 chars, first and last 1000]

Guards are redirect-aware: piping to a file (> /tmp/out.txt) bypasses truncation, so multi-step processing works naturally. The agent's system prompt includes instructions for this pattern.

Supported Agents

Agent Command Notes
OpenAI Codex codex Recommended — supports recursive sub-agents
Google Gemini bunx --bun @google/gemini-cli Supports recursive sub-agents
Claude Code claude Non-recursive only — cannot spawn nested Claude sessions
Any CLI my-agent Combined prompt passed as single argument

When to Use

  • Many files to analyze (>10)
  • Task benefits from divide-and-conquer
  • Total content exceeds a comfortable context window
  • You want the agent to explore strategically rather than read everything upfront

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coderlm-0.1.1.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coderlm-0.1.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file coderlm-0.1.1.tar.gz.

File metadata

  • Download URL: coderlm-0.1.1.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for coderlm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cb9783b5a7c638b705a292eb2db636f63bf7682fc976ccb7133d1d30cf119962
MD5 32eb2f5b5607316ed0b8ed951c040585
BLAKE2b-256 10e15ce00d7477b8ba041a05df68dab7dce76ae509f4c55c190d38b88712e342

See more details on using hashes here.

File details

Details for the file coderlm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: coderlm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for coderlm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41e9466530ee90156661c685652ec71c8315aa07d0889a55e9724a7b681e131d
MD5 1d0d1d20afffa33a9b72d004a8ae6e34
BLAKE2b-256 e57895e980e28669ca2fcfad68e97d996095588223f49ff77b43bd720619ca8d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page