{
  "markdown": "<div align=\"center\">\n\n# ReLaMo\n\n**Recursive Language Model skill for AI coding agents — programmatic codebase exploration via persistent Python REPL**\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Version](https://img.shields.io/badge/version-1.2.0-green.svg)]()\n[![Agent Skills](https://img.shields.io/badge/Agent_Skills-Standard-blueviolet.svg)](https://agentskills.io)\n[![Claude Code](https://img.shields.io/badge/Claude_Code-Plugin-orange.svg)](https://github.com/anthropics/claude-code)\n[![Gemini CLI](https://img.shields.io/badge/Gemini_CLI-Extension-4285F4.svg)](https://github.com/google-gemini/gemini-cli)\n[![Codex CLI](https://img.shields.io/badge/Codex_CLI-Compatible-10a37f.svg)](https://github.com/openai/codex)\n[![Python](https://img.shields.io/badge/Python-3.11+-3776AB.svg)](https://python.org)\n[![uv](https://img.shields.io/badge/uv-powered-blueviolet.svg)](https://docs.astral.sh/uv/)\n\nEver hit a wall exploring large codebases with AI?<br>\nThat's what happens when your tools can only read one file at a time.\n\n[Installation](#installation) • [Usage](#when-to-use-what) • [The Problem](#the-problem) • [How It Works](#how-it-works) • [Examples](#real-world-scenarios)\n\n</div>\n\nrelamo implements the **Recursive Language Model (RLM)** pattern as an [Agent Skills](https://agentskills.io) standard skill, supported across all major AI coding agents. Instead of stuffing files into prompts, it concatenates your codebase into a Python variable and lets the agent write code to search, extract, and analyze it iteratively — with full state persistence across REPL iterations.\n\n## Installation\n\nrelamo uses the [Agent Skills open standard](https://agentskills.io) (`SKILL.md` format), supported across all major AI coding agents.\n\n<table>\n<tr>\n  <th width=\"200\">Platform</th>\n  <th>How to install</th>\n</tr>\n<tr>\n  <td><strong>Claude Code</strong></td>\n  <td><code>claude plugin marketplace add ph3on1x/relamo</code><br><code>claude plugin install relamo</code></td>\n</tr>\n<tr>\n  <td><strong>Gemini CLI</strong></td>\n  <td><code>gemini extensions install &lt;github-url&gt;</code></td>\n</tr>\n<tr>\n  <td><strong>Codex CLI</strong></td>\n  <td>Clone the repo, then run <code>./scripts/setup-platforms.sh</code></td>\n</tr>\n<tr>\n  <td><strong>Cursor</strong></td>\n  <td>Auto-discovers skills — no setup needed if Claude Code plugin is installed. Otherwise, run <code>./scripts/setup-platforms.sh</code></td>\n</tr>\n</table>\n\n> [!NOTE]\n> Requires Python 3.11+ (managed automatically by uv) and [uv](https://docs.astral.sh/uv/) (auto-installs the `dill` dependency). `llm_query()` and `recursive_llm()` auto-detect the first available CLI in PATH (`claude`, `gemini`, `codex`). Override with `RELAMO_LLM_CMD` env var.\n\n## When to Use What\n\n<table>\n<tr>\n  <th width=\"280\">You're thinking...</th>\n  <th width=\"280\">Use</th>\n  <th>What happens</th>\n</tr>\n<tr>\n  <td>\"How does auth work in this 200-file project?\"</td>\n  <td><code>/relamo \"how does auth work?\"</code></td>\n  <td>Gathers codebase, explores iteratively via REPL, returns structured answer with evidence</td>\n</tr>\n<tr>\n  <td>\"Find all API endpoints and their handlers\"</td>\n  <td><code>/relamo \"find all API endpoints\"</code></td>\n  <td>Regex searches, extracts files, maps routes to handlers across the entire codebase</td>\n</tr>\n<tr>\n  <td>\"Compare error handling patterns across modules\"</td>\n  <td><code>/relamo \"compare error handling\"</code></td>\n  <td>Batch-processes files, uses <code>llm_query()</code> for sub-analysis, synthesizes findings</td>\n</tr>\n<tr>\n  <td>\"I need to analyze just one subdirectory\"</td>\n  <td><code>/relamo \"analyze auth\" --context src/auth</code></td>\n  <td>Scopes the REPL context to just that directory</td>\n</tr>\n</table>\n\n### Arguments\n\n<table>\n<tr>\n  <th width=\"200\">Argument</th>\n  <th width=\"120\">Default</th>\n  <th>Description</th>\n</tr>\n<tr>\n  <td><code>&lt;query&gt;</code></td>\n  <td>required</td>\n  <td>The question or task to answer</td>\n</tr>\n<tr>\n  <td><code>--context &lt;path&gt;</code></td>\n  <td>current directory</td>\n  <td>Path to codebase directory or single file</td>\n</tr>\n<tr>\n  <td><code>--depth &lt;1-3&gt;</code></td>\n  <td>1</td>\n  <td>Max recursion depth for <code>recursive_llm()</code></td>\n</tr>\n<tr>\n  <td><code>--iterations &lt;max&gt;</code></td>\n  <td>15</td>\n  <td>Max REPL loop iterations</td>\n</tr>\n</table>\n\n## The Problem\n\nAI coding agents are great at reading individual files. But when you need to understand how an entire codebase fits together:\n\n- **Context window limits** — large codebases don't fit in a single prompt\n- **No state between tool calls** — each file read starts from scratch\n- **No batch processing** — you can't programmatically map an operation across 50 files\n\n## How It Works\n\n```mermaid\nflowchart TD\n    A[\"/relamo 'find all auth flows'\"] --> B[\"Init: gather codebase\\ninto context variable\"]\n    B --> C[\"Assess: what do I know?\\nWhat do I need to find out?\"]\n    C --> D[\"Write Python code\\ntargeting the context variable\"]\n    D --> E[\"Execute in sandboxed REPL\\n(variables persist!)\"]\n    E --> F{\"Need more\\ninfo?\"}\n    F -- Yes --> C\n    F -- No --> G[\"FINAL(answer)\"]\n\n    style A fill:#1a1a2e,stroke:#e94560,color:#fff\n    style G fill:#1a1a2e,stroke:#0f3460,color:#fff\n    style F fill:#16213e,stroke:#e94560,color:#fff\n```\n\nThe entire codebase lives outside the prompt as a Python string. The agent writes code to interact with it — `search()`, `extract_file()`, `llm_query()` — accumulating findings in variables across iterations. This is the [RLM pattern](https://arxiv.org/abs/2307.00522) brought to AI coding agents as a skill.\n\nThe REPL engine (`scripts/repl.py`) is a [uv](https://docs.astral.sh/uv/) single-file script with [PEP 723](https://peps.python.org/pep-0723/) inline metadata. No manual dependency installation needed — `uv run` handles everything.\n\n1. **Init** — gathers your codebase via `git ls-files` (or directory walk), skips binaries and large files, concatenates everything with `=== path ===` delimiters\n2. **Execute** — runs Python code in a namespace where `context` and helpers are pre-loaded; state persists via [dill](https://github.com/uqfoundation/dill) serialization\n3. **Loop** — the agent assesses, writes code, executes, reads output, and decides whether to continue or call `FINAL()`\n\n### Available Functions\n\n<table>\n<tr>\n  <th width=\"280\">Function</th>\n  <th>Purpose</th>\n</tr>\n<tr><td><code>context</code></td><td>Full concatenated codebase as string</td></tr>\n<tr><td><code>list_files()</code></td><td>All file paths in context</td></tr>\n<tr><td><code>extract_file(path)</code></td><td>Extract single file content by path</td></tr>\n<tr><td><code>search(pattern, context_chars=200)</code></td><td>Regex search with surrounding context</td></tr>\n<tr><td><code>llm_query(prompt)</code></td><td>LLM completion via auto-detected CLI (<code>claude</code>, <code>gemini</code>, or <code>codex</code>)</td></tr>\n<tr><td><code>llm_query_batched(prompts)</code></td><td>Sequential LLM calls on a list of prompts</td></tr>\n<tr><td><code>recursive_llm(query, sub_context)</code></td><td>Spawn child RLM instance via auto-detected CLI</td></tr>\n<tr><td><code>FINAL(answer)</code></td><td>Emit final answer and terminate</td></tr>\n<tr><td><code>FINAL_VAR(var_name)</code></td><td>Emit a variable as the answer</td></tr>\n<tr><td><code>config</code></td><td>Mutable safety config dict</td></tr>\n</table>\n\n## Example Session\n\n### Exploring authentication\n\n```\n> /relamo \"how does authentication work in this project?\"\n\n[relamo] Gathering codebase from: /Users/you/project\n[relamo] Context size: 245,891 characters (241,003 bytes)\n[relamo] Files included: 87\n\n--- Iteration 1: Orient ---\nfiles = list_files()\nauth_files = [f for f in files if 'auth' in f.lower()]\nprint(auth_files)\n# ['src/auth/middleware.ts', 'src/auth/providers.ts', 'src/auth/session.ts', ...]\n\n--- Iteration 2: Extract key files ---\nmiddleware = extract_file('src/auth/middleware.ts')\nprint(middleware[:2000])\n\n--- Iteration 3: Analyze with LLM ---\nanalysis = llm_query(f\"Explain the auth flow in this middleware:\\n{middleware}\")\nprint(analysis)\n\n--- Iteration 4: Search for usage ---\nresults = search(r'requireAuth|isAuthenticated|withAuth')\nprint(f\"Found {len(results)} usages across codebase\")\n\n--- Iteration 5: Synthesize ---\nFINAL(f\"Authentication uses JWT tokens via {analysis}...\")\n\n## RLM Result\n### Answer\nAuthentication uses JWT tokens with a middleware chain...\n### Evidence\nsrc/auth/middleware.ts:15 — token validation\nsrc/auth/providers.ts:42 — OAuth provider config\n...\n```\n\n## Real-World Scenarios\n\n### Onboarding to a large codebase\n\n```\n> /relamo \"give me a high-level architecture overview of this project\"\n\nThe REPL lists all files, groups them by directory, identifies key entry points,\nextracts package.json/config files, and uses llm_query() to summarize each layer.\nReturns a structured overview with the tech stack, data flow, and key patterns.\n```\n\n### Batch analysis across files\n\n```\n> /relamo \"find all TODO and FIXME comments, categorize by priority and module\"\n\nThe REPL searches for TODO/FIXME patterns across every file, extracts surrounding\ncontext, uses llm_query() to classify each by priority, and returns a sorted report\ngrouped by module — something that would take dozens of manual Grep calls.\n```\n\n### Deep dive with recursive LLM\n\n```\n> /relamo \"how does data flow from API request to database write?\" --depth 2\n\nThe REPL identifies the API layer, then spawns recursive_llm() sub-instances to\nindependently analyze the routing layer, validation layer, and database layer.\nEach child REPL gets a focused subset of the codebase. Results are merged into\na complete data flow analysis with evidence from each layer.\n```\n\n## Safety and Cost\n\n### Guardrails\n\n<table>\n<tr>\n  <th width=\"200\">Parameter</th>\n  <th width=\"120\">Default</th>\n  <th>Description</th>\n</tr>\n<tr><td><code>recursion_limit</code></td><td>1</td><td>Max depth for <code>recursive_llm()</code></td></tr>\n<tr><td><code>max_iterations</code></td><td>15</td><td>REPL loop cap</td></tr>\n<tr><td><code>timeout_seconds</code></td><td>120</td><td>Per LLM call timeout</td></tr>\n<tr><td><code>max_output_chars</code></td><td>10,000</td><td>Stdout truncation limit</td></tr>\n<tr><td><code>max_file_size</code></td><td>1 MB</td><td>Skip individual files larger than this</td></tr>\n<tr><td><code>max_context_bytes</code></td><td>50 MB</td><td>Total codebase size limit</td></tr>\n</table>\n\nAll values are adjustable at runtime via the `config` dict.\n\n### Sandboxing\n\nThe REPL runs in a restricted environment:\n- **Blocked builtins**: `eval`, `exec`, `compile` are removed\n- **Import whitelist**: only `re`, `json`, `math`, `collections`, `itertools`, `functools`, `textwrap`, `difflib`, `hashlib`, `datetime`, `csv`, `io`, `os.path`, `pathlib`, `string`, `unicodedata`\n\n## Acknowledgments\n\n- **MIT CSAIL** — The [Recursive Language Model](https://arxiv.org/abs/2307.00522) research paper this plugin implements\n- **Anthropic** — [Claude Code](https://github.com/anthropics/claude-code) and the [Agent Skills standard](https://agentskills.io)\n\n## License\n\n[MIT](LICENSE)\n",
  "bytes": 11172,
  "sha": "3e36d7e335d99542d66404c1fe04fa374223ea1578445d712214ee7b98c68c42",
  "repo_slug": "ph3on1x/relamo",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_ph3on1x_relamo_d3544724/readme"
}