rlm-prep
Prepare source content for RLM processing by discovering files, chunking each one, and writing a unified searchable manifest
What this skill does
# RLM Prep
Prepare source content for RLM processing in one shot: discovers files, chunks each one, builds a searchable index, and writes a unified `manifest.json`. Run this once on a codebase or document set; then use `rlm-search` or `fanout` against the output without re-preparing.
## Triggers
Alternate expressions and non-obvious activations:
- "index this codebase for search" → rlm-prep on directory
- "get this ready for RLM" → rlm-prep with defaults
- "prep the docs folder" → rlm-prep on `docs/`
- "build a chunk index" → rlm-prep with index output
## Trigger Patterns Reference
| Pattern | Example | Action |
|---------|---------|--------|
| Prep a directory | "prepare src/ for RLM" | `rlm-prep src/` |
| Prep a single file | "prep this file for recursive search" | `rlm-prep path/to/file.ts` |
| Strategy override | "prep with fixed-count chunking" | `--strategy fixed-count` |
| Size override | "prep in 100-line chunks" | `--size 100` |
| Custom output | "prep into tmp/rlm/" | `--output tmp/rlm/` |
| Force refresh | "re-prep even if already done" | `--force` |
| Check status | "is this codebase already prepped?" | Inspect output dir for manifest |
## Behavior
When triggered:
1. **Resolve source** — determine whether the input is a single file or a directory. For directories, discover all supported file types (`.ts`, `.js`, `.py`, `.go`, `.md`, `.txt`, `.yaml`, `.json`, `.sql`, and others). Respect `.gitignore` patterns.
2. **Check for existing prep** — look for a manifest in the output directory. If found and `--force` is not set, report that prep already exists and offer to use it or re-run.
3. **Chunk each file** — apply the selected strategy per file. Each file produces its own subdirectory under `chunks/`, named after the file path (slashes replaced with underscores).
4. **Build index** — construct a searchable index (`index.json`) with:
- Chunk IDs mapped to file, line range, and boundary label
- Content summaries (first non-blank line of each chunk)
- File-level metadata (language, size, last-modified)
5. **Write unified manifest** — a single `manifest.json` at the output root that references all chunks across all files. This is what `fanout` and `rlm-search` consume.
6. **Report result** — print file count, total chunk count, index size, and output path.
### Output Directory Structure
```
.aiwg/rlm-prep/<source-hash>/
├── manifest.json # Unified chunk manifest (all files)
├── index.json # Searchable index with summaries
├── meta.json # Source path, strategy, timestamp
└── chunks/
├── src__auth__middleware.ts/
│ ├── chunk-0001.txt
│ ├── chunk-0002.txt
│ └── chunk-0003.txt
├── src__auth__jwt.ts/
│ ├── chunk-0001.txt
│ └── chunk-0002.txt
└── src__core__parser.ts/
├── chunk-0001.txt
├── chunk-0002.txt
├── chunk-0003.txt
└── chunk-0004.txt
```
### Manifest Format (multi-file)
```json
{
"source": "src/auth/",
"source_hash": "sha256:a1b2c3d4...",
"strategy": "semantic-boundary",
"chunk_size": 200,
"overlap": 20,
"created_at": "2026-04-01T14:23:00Z",
"files": 12,
"total_chunks": 47,
"output_dir": ".aiwg/rlm-prep/a1b2c3d4/",
"chunks": [
{
"id": "src__auth__middleware.ts/chunk-0001",
"file_source": "src/auth/middleware.ts",
"chunk_file": ".aiwg/rlm-prep/a1b2c3d4/chunks/src__auth__middleware.ts/chunk-0001.txt",
"start_line": 1,
"end_line": 218,
"boundary_label": "validateToken()"
}
]
}
```
## Parameters
- `<file|dir>` — Source file or directory to prepare (required)
- `--output <dir>` — Output directory (default: `.aiwg/rlm-prep/<source-hash>/`)
- `--strategy semantic-boundary|fixed-count|adaptive` — Chunking strategy (default: `semantic-boundary`)
- `--size N` — Target chunk size in lines (default: `200`)
- `--overlap N` — Overlap lines between adjacent chunks (default: `20`)
- `--force` — Re-prep even if a manifest already exists
## Examples
### Example 1: Prep a source directory
**User**: "prepare src/ for RLM processing"
**Action**:
```bash
aiwg rlm-prep src/
```
**Response**: "Prepped `src/` for RLM. 12 files, 47 chunks. Strategy: semantic-boundary (200 lines, 20 overlap). Manifest: `.aiwg/rlm-prep/a1b2c3d4/manifest.json`"
---
### Example 2: Prep with smaller chunks for a dense codebase
**User**: "index the entire repo for RLM, use 100-line chunks"
**Action**:
```bash
aiwg rlm-prep . --size 100 --overlap 15
```
**Response**: "Prepped `.` for RLM. 84 files, 312 chunks. Strategy: semantic-boundary (100 lines, 15 overlap). Manifest: `.aiwg/rlm-prep/b3c4d5e6/manifest.json`"
---
### Example 3: Prep a documentation set
**User**: "get the docs folder ready for recursive search"
**Action**:
```bash
aiwg rlm-prep docs/ --strategy fixed-count --size 150
```
**Response**: "Prepped `docs/` for RLM. 23 files, 89 chunks. Strategy: fixed-count (150 lines, 20 overlap). Manifest: `.aiwg/rlm-prep/c4d5e6f7/manifest.json`"
---
### Example 4: Already prepped — user wants to force refresh
**User**: "re-prep the auth module, I've made changes"
**Action**:
```bash
aiwg rlm-prep src/auth/ --force
```
**Response**: "Re-prepped `src/auth/` (previous prep from 2026-03-28 replaced). 4 files, 14 chunks. Manifest: `.aiwg/rlm-prep/d5e6f7a8/manifest.json`"
---
### Example 5: Check if already prepped
**User**: "is src/ already prepped for RLM?"
**Action**: Check `.aiwg/rlm-prep/` for a manifest matching the source hash of `src/`.
**Response**: "Yes — `src/` was prepped on 2026-04-01 (47 chunks, strategy: semantic-boundary). Run with `--force` to re-prep."
## Clarification Prompts
If the user's intent is ambiguous:
- "Should I prep the entire directory or just a specific subdirectory?"
- "A previous prep exists from [date]. Should I use it or re-prep?"
- "Which strategy: split at natural boundaries (semantic-boundary), fixed line counts, or adaptive?"
## References
- @$AIWG_ROOT/agentic/code/addons/rlm/skills/chunk/SKILL.md — Single-file chunking (used internally by rlm-prep)
- @$AIWG_ROOT/agentic/code/addons/rlm/skills/fanout/SKILL.md — Query the prepared manifest
- @$AIWG_ROOT/agentic/code/addons/rlm/skills/rlm-search/SKILL.md — Full pipeline that calls rlm-prep automatically
- @$AIWG_ROOT/agentic/code/addons/rlm/schemas/rlm-chunk-manifest.yaml — Manifest schema
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/context-budget.md — Budget guidance for downstream fanout
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.