zircote-plugins/claude-team-orchestration/rlm-pattern

Claude Code and agent skill by zircote-plugins/claude-team-orchestration

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Process files exceeding context limits using the RLM (Recursive Language Model) pattern with agent teams. Use when you need to process large files, analyze documents exceeding context, apply RLM chunking, chunk and analyze large content, or handle long context documents.

Install

npx vskill@latest install zircote-plugins/claude-team-orchestration/rlm-pattern

SKILL.md

The same SKILL.md was published earlier as zircote-plugins/claude-team-orchestration/rlm-pattern.

RLM (Recursive Language Model) Pattern

Process files that exceed context limits by dividing them into partitions and coordinating a team of analyst agents to analyze each partition in parallel, then synthesizing their reports.

Based on: arXiv:2512.24601


The Pattern

  1. Team Lead detects content type, determines partitioning strategy, and divides the content into manageable chunks.
  1. Each Analyst agent (selected by content type) independently analyzes their assigned partition and reports back to team-lead with structured findings.
  1. Team Lead collects all analyst reports, then either synthesizes directly or spawns a dedicated Synthesizer agent to produce the consolidated report.

This is a fan-out/fan-in coordination pattern built on agent teams.


Critical: What RLM is NOT

RLM partitions the data, not the analysis. Every analyst receives the same query and examines all columns/fields in their chunk of rows. The analysis goals are the query — not separate tasks.

WRONG (thematic decomposition):

  • Task 1: "Analyze error patterns" (reads entire file)
  • Task 2: "Analyze root causes" (reads entire file again)
  • Task 3: "Analyze trends" (reads entire file again)
  • Task 4: Synthesize (blocked by 1-3)

RIGHT (data partitioning):

  • Task 1: "Chunk 1 of 10 — rows 1-5000" (query: find error patterns, root causes, and trends)
  • Task 2: "Chunk 2 of 10 — rows 5001-10000" (same query)
  • ...
  • Task 10: "Chunk 10 of 10 — rows 45001-50000" (same query)
  • Synthesis: aggregate all chunk findings

If you find yourself creating tasks named after analysis concerns rather than data partitions, STOP — you are not doing RLM.


When to Use

  • File exceeds ~1500 lines or ~1500 CSV rows
  • You need comprehensive analysis of the full content, not just a snippet
  • Log analysis, data exports, large codebase review, document analysis
  • Grep alone can't answer the question (need contextual analysis, not keyword matching)
  • Directory contains multiple files needing cross-file analysis (see Multi-File Directory Analysis)

Don't use when: File fits in context (~1500 lines or fewer), a targeted Grep suffices, or the task is editing (not analyzing).


Pre-Processing

Before content-type detection, handle compressed or archived inputs:

InputAction
.zipunzip <file> -d /tmp/rlm-extract/ — then detect content type of extracted file(s)
.gzgunzip -k <file> — then detect content type of decompressed file
.tar.gz / .tgztar xzf <file> -C /tmp/rlm-extract/ — then enumerate extracted files

If a zip/archive contains a single file, proceed with single-file RLM on the extracted file. If it contains multiple files, proceed with multi-file directory analysis on the extraction directory.


Content-Type Detection

Before chunking, the Team Lead detects the content type to select the right partitioning strategy and analyst agent. This runs inline — no separate agent needed.

Stage 1: Extension Mapping
ExtensionsContent TypeConfidence
.py, .ts, .js, .tsx, .jsx, .rb, .go, .rs, .java, .kt, .c, .cpp, .h, .hpp, .cs, .swift, .scala, .php, .lua, .zig, .ex, .exs, .hs, .ml, .sh, .bash, .zshsource_codeHigh
.csv, .tsvstructured_dataHigh
.jsonjsonHigh
.jsonl, .ndjsonjsonlHigh
.loglogHigh
.md, .rst, .txt, .adocproseMedium
.xml, .html, .htm, .svgmarkupMedium
.yaml, .yml, .toml, .ini, .confconfigMedium
Stage 2: Content Sniffing (when extension gives Medium or no confidence)

Read the first 50 lines and apply heuristics (first match wins):

HeuristicDetected TypeSignal
First line matches CSV header pattern (comma/tab-separated tokens)structured_dataid,name,email,created_at
Lines match TIMESTAMP LEVEL message pattern consistentlylog2026-02-11 01:30:00 ERROR ...
First non-whitespace is [ or { and content parses as JSONjson{"key": "value", ...}
Every line is independent valid JSONjsonl{"event": "click"}\n{"event": "view"}
Lines start with def , function , class , import , #include, package source_codedef process_data(df):
Markdown headings (# , ## ), paragraph textprose## Introduction\n\nThis document...
No pattern matchesunknownFalls back to prose behavior
Detection Flow
1. Map file extension → content_type (Stage 1)
2. If confidence < High OR extension is .txt/.log:
a. Read first 50 lines
b. Apply Stage 2 heuristics (first match wins)
3. If still unknown → default to "prose"
4. Log: "Detected content type: {type} (via {extension|sniffing})"

Partitioning Strategies

Quick Reference
Content TypePartition ByChunk SizeAnalyst Agent
Source codeFunction/class boundaries150-300 linesswarm:rlm-code-analyzer
CSV/TSVRow count~2000 rows (narrow) / ~500-1500 rows (wide)swarm:rlm-data-analyzer
JSONTop-level array elements200-500 elementsswarm:rlm-json-analyzer
JSONLLine count500-1000 linesswarm:rlm-json-analyzer
Log filesLine ranges + overlap200-5000 lines, 20-50 overlapswarm:rlm-chunk-analyzer
Prose/docsSection headings or line ranges250 lines, 25 overlapswarm:rlm-chunk-analyzer
Config/markup/unknownLine ranges + overlap200 lines, 20 overlapswarm:rlm-chunk-analyzer

Choose chunk sizes from the targets above and let partition count scale with data size. Fewer partitions under-utilizes parallelism and degrades analysis quality. Be aggressive with partitioning — more smaller chunks produce better findings than fewer large ones. There is no practical ceiling on partition count when using findings-in-task-descriptions mode and staged spawning.

Source Code
  • Chunk boundary: Function/class/module — scan for lines at indentation level 0 starting with keywords (def , class , function , func , fn , pub fn , impl , module , export , const , type , interface ). Group consecutive lines between boundaries into chunks.
  • Chunk size: 150-300 lines. If any chunk exceeds 300 lines, split at the next inner boundary. If no boundaries detected, fall back to 200-line chunks with 20-line overlap.
  • Overlap: 0 — boundaries are semantic, no overlap needed.
  • Context injection: Extract the file's import/require block (lines from start until first non-import line). Prepend this to every chunk file for dependency awareness.
  • Partition method: Write chunk files (chunk-01.py through chunk-N.py), each starting with the shared import block.
Structured Data (CSV/TSV)
  • Chunk boundary: Row count (even splits).
  • Chunk size: Target ~2000 rows per partition for narrow data (< 20 columns), ~500-1500 rows for wide data (20+ columns). Use ~500 for dense wide data (most columns populated); use ~1500 for sparse wide data (many empty columns, e.g., Jira exports). Partition count scales naturally with total row count — a 50K-row file produces ~25 partitions at 2000 rows each.
  • Overlap: 0 — rows are independent.
  • Header preservation: Every chunk file includes the original header row as line 1.
  • Partition method: Write chunk files (chunk-01.csv through chunk-N.csv), each starting with the header.

Mandatory partitioning procedure for every CSV/TSV file:

bash
# 1. Count rows (subtract 1 for header)
total_rows=$(($(wc -l < input.csv) - 1))
# 2. Determine chunk size based on column count
col_count=$(head -1 input.csv | awk -F',' '{print NF}')
if [ "$col_count" -ge 20 ]; then
chunk_size=1500 # wide data (use ~500 for dense, ~1500 for sparse like Jira exports)
else
chunk_size=2000 # narrow data
fi
# 3. Calculate partition count
chunk_count=$(( (total_rows + chunk_size - 1) / chunk_size ))
# 4. Extract header and write chunk files
header=$(head -1 input.csv)
mkdir -p /tmp/rlm-chunks
for i in $(seq 1 "$chunk_count"); do
start=$(( (i - 1) * chunk_size + 2 )) # +2 to skip header
end=$(( start + chunk_size - 1 ))
chunk_file=$(printf "/tmp/rlm-chunks/chunk-%02d.csv" "$i")
printf '%s\n' "$header" > "$chunk_file"
sed -n "${start},${end}p" input.csv >> "$chunk_file"
done
# 5. Create one task per chunk file — NOT one task per source file

One CSV file = many tasks. A 10,000-row CSV produces ~7 chunks at 1500 rows/chunk or ~5 chunks at 2000 rows/chunk — never 1 task. If you are creating one task per source file, you are NOT partitioning — stop and run this procedure.

JSON (single document)
  • Chunk boundary: Top-level array elements. If root is array, split by element count. If root is object, split by top-level keys.
  • Chunk size: 200-500 elements per chunk. Adjust per element size.
  • Overlap: 0 — objects are self-contained.
  • Partition method: Write chunk files. Each chunk is a valid JSON array: [element1, element2, ...].
  • Schema injection: Include a schema summary (field names + types from first 5 elements) in the analyst prompt.
JSONL / NDJSON
  • Chunk boundary: Line count. Each line is one JSON object.
  • Chunk size: 500-1000 lines. Adjust per line size.
  • Overlap: 0 — lines are independent.
  • Partition method: Write chunk files. Each chunk is valid JSONL.
  • Schema injection: Include field list from first object in the analyst prompt.
Log Files
  • Chunk boundary: Line ranges (sequential).
  • Chunk size: 200-5000 lines (adjust to target 5-10 partitions).
  • Overlap: 20-50 lines. Prevents splitting multi-line stack traces.
  • Chunk index: Each analyst receives "chunk M of N" for temporal ordering.
  • Partition method: Read offset/limit — no file writes needed, analysts read in-place.
Prose / Markdown / Docs
  • Chunk boundary: Section headings (#, ##) when possible.
  • Chunk size: 250 lines, 25 overlap (fallback when no heading structure).
  • Chunk index: "chunk M of N" for reading order.
  • Partition method: Read offset/limit — no file writes needed.
Config / Markup / Unknown
  • Chunk boundary: Line ranges (current default behavior).
  • Chunk size: 200 lines, 20 overlap.
  • Partition method: Read offset/limit.

Agent Routing

The Team Lead selects the analyst agent based on detected content type and the user's analysis goal.

Routing by Content Type
Content TypeAnalyst AgentWhy
source_codeswarm:rlm-code-analyzerUnderstands function/class boundaries, reports with scope context, supports analysis focus
structured_dataswarm:rlm-data-analyzerColumn-aware, reports distributions and statistics, aggregatable across chunks
json / jsonlswarm:rlm-json-analyzerSchema-aware, reports field distributions and structural patterns
logswarm:rlm-chunk-analyzerGeneral-purpose, good at error/pattern detection in sequential text
proseswarm:rlm-chunk-analyzerGeneral-purpose, handles unstructured text
config / markup / unknownswarm:rlm-chunk-analyzerFallback general-purpose analyzer
Analysis Focus (source code only)

For source code, the Team Lead includes an analysis focus in each analyst's prompt to steer findings:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
15
Repository forks
2
7-day trend score
14

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 29 Sep 2026, a month ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/zircote-plugins/claude-team-orchestration/rlm-pattern/badge)](https://verified-skill.com/skills/zircote-plugins/claude-team-orchestration/rlm-pattern)

Something wrong with this skill or its page? Tell us.