/agentsop-multiscale-chunking
Enhancement-overlay (C5) for RAG over long documents — the chunk-paradox resolution. Activate when a single fixed chunk size cannot satisfy both retrieval precision (small chunks) and generation context (large chunks): small chunks lose surrounding context, large chunks dilute
$ npx -y skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/agentsop-multiscale-chunking
Context preview
The summary Claude sees to decide when to auto-load this skill.
Enhancement-overlay (C5) for RAG over long documents — the chunk-paradox resolution. Activate when a single fixed chunk size cannot satisfy both retrieval precision (small chunks) and generation context (large chunks): small chunks lose surrounding context, large chunks dilute
SKILL.md
agentsop-multiscale-chunking.SKILL.mdname: agentsop-multiscale-chunking
version: 0.1.0
description: >-
Enhancement-overlay (C5) for RAG over long documents — the chunk-paradox resolution.
Activate when a single fixed chunk size cannot satisfy both retrieval precision (small
chunks) and generation context (large chunks): small chunks lose surrounding context,
large chunks dilute embedding relevance into "topic averages". Encodes the core flip —
decouple the embed-unit from the return-unit: embed small for retrieval precision, return
large for synthesis context — and the SOP to pick a base chunk size, choose a horizontal
(sentence-window) vs vertical (auto-merging / parent-child) expansion strategy, and
measure the lift. Cross-links [[llamaindex]] for the full RAG SOP; this overlay supplies
the missing "chunk-paradox-resolution" recipe that the framework docs
(HierarchicalNodeParser, SentenceWindow) only describe in fragments. Medium-frequency for
any RAG over long prose, manuals, filings, or codebases. Search keywords: chunk size,
chunking strategy, parent document retriever, sentence window, small-to-big retrieval,
hierarchical chunking, optimal chunk size.
Multi-scale Chunking · C5 Enhancement Overlay
> Overlay on top of [[llamaindex]]. The base skill teaches the 5-layer RAG > pipeline and lists `DecoupleChunkScope` as one optimization knob among many. > This overlay zooms in on that single knob and turns it into a standalone > recipe: **how to resolve the chunk paradox when one chunk size is provably > not enough.** Third-person analytical view for an agent writing / reviewing > RAG ingestion code — not an end-user tutorial.
---
1. 何时激活 (Activation Rules)
Activate this overlay when **all three** RAG preconditions hold and the chunk paradox has actually surfaced:
1. The corpus is **long documents** — prose manuals, financial filings, legal contracts, research papers, codebases — where a single answer-bearing fact sits inside a larger context that the LLM needs to interpret it. 2. A **chunk-size sweep has stalled**: small chunks (128–256) win retrieval precision but the LLM answers from fragments; large chunks (1024–2048) give rich context but recall on specific queries drops because the embedding becomes a "topic average". The official failure-mode checklist documents both poles as *separate* failures — #2 (wrong chunk from too-small) and #6 (context overflow / dilution from too-large) (cited in [[llamaindex]] R3). 3. Faithfulness or relevancy is **plateauing below target** and bumping `chunk_size` only moves the failure from one pole to the other.
Concrete triggers:
- "Answers are technically retrieved but the model lacks context to explain them."
- "I keep retuning chunk_size and it never wins on both faithfulness and recall."
- A reviewer sees `SentenceSplitter(chunk_size=4096)` shipped as the fix for
"incomplete answers" (this is anti-pattern A1 in [[llamaindex]]).
Do **not** activate when:
- The corpus is short/static (<100k tokens) — prompt-stuff with caching; multi-scale chunking is over-engineering (§6).
- The chunk-size sweep *did* converge on a single winner (e.g. 1024 for prose) — pin it and stop.
- Retrieval quality is fine and the bottleneck is orchestration or synthesis.
---
2. 核心心智模型 (Core Mental Model)
> **Decouple the embed-unit from the return-unit. Embed small for retrieval > precision; return large for generation context.**
The naive assumption is that the unit you index *is* the unit you feed the LLM. That single identity is the source of the paradox: it forces one chunk size to serve two opposing jobs.
NAIVE (one unit, two jobs) MULTI-SCALE (two units, one job each)
───────────────────────── ─────────────────────────────────────
[ chunk ] embed unit → small (precision job)
/ \ │
embed it feed it match
(wants (wants │
small) large) return unit → large (context job)
↓ ↓ ▲
CONFLICT — pick one, expand from
lose the other match → parent / windowThree load-bearing sub-principles:
1. **A Node is a graph node, not a chunk.** In LlamaIndex a `Node` carries `relationships` (PREV/NEXT/PARENT/CHILD). Those links are exactly what let you store a small node for matching and *resolve* it to a larger node for return ([[llamaindex]] Principle 2). Multi-scale chunking is "build a chunk-graph", not "split into chunks".
2. **Two geometries of expansion.** Once embed ≠ return, you must choose *how* the small match expands into the large return:
- **Horizontal** — return N adjacent sentences around the matched sentence
(sentence-window). The expansion is *positional*.
- **Vertical** — return the parent chunk when enough sibling children match
(auto-merging / parent-child). The expansion is *hierarchical*.
3. **Match the geometry to the document, not to taste.** Flat narrative prose → horizontal. Documents with real structure (headings, sections, tables of contents) → vertical. This is the central dilemma case (§5.1).
The overlay's promise: this *strictly dominates* a compromise chunk size when the sweep frontier is non-flat — you no longer average two bad sizes.
---
3. SOP 工作流 (Decision Protocol)
A three-gate protocol. Do **not** skip Gate 0 — multi-scale chunking is only justified once a single chunk size has been proven insufficient.
Gate 0 — Pick the base chunk size first (and try to stop here)
Run the canonical sweep from [[llamaindex]] OP-02 *before* reaching for any multi-scale machinery:
from llama_index.core.evaluation import (
FaithfulnessEvaluator, RelevancyEvaluator,
)
# 1. ~20 eval QA pairs via DatasetGenerator.from_documents(docs)
# 2. sweep:
for cs in (128, 256, 512, 1024, 2048): # overlap = 0.1–0.2Read more
name: agentsop-multiscale-chunking version: 0.1.0 description: >- Enhancement-overlay (C5) for RAG over long documents — the chunk-paradox resolution. Activate when a single fixed chunk size cannot satisfy both retrieval precision (small chunks) and generation context (large chunks): small chunks lose surrounding context, large chunks dilute embedding relevance into "topic averages". Encodes the core flip — decouple the embed-unit from the return-unit: embed small for retrieval precision, return large for synthesis context — and the SOP to pick a base chunk size, choose a horizontal (sentence-window) vs vertical (auto-merging / parent-child) expansion strategy, and measure the lift. Cross-links [[llamaindex]] for the full RAG SOP; this overlay supplies the missing "chunk-paradox-resolution" recipe that the framework docs (HierarchicalNodeParser, SentenceWindow) only describe in fragments. Medium-frequency for any RAG over long prose, manuals, filings, or codebases. Search keywords: chunk size, chunking strategy, parent document retriever, sentence window, small-to-big retrieval, hierarchical chunking, optimal chunk size.
Multi-scale Chunking · C5 Enhancement Overlay
> Overlay on top of [[llamaindex]]. The base skill teaches the 5-layer RAG > pipeline and lists `DecoupleChunkScope` as one optimization knob among many. > This overlay zooms in on that single knob and turns it into a standalone > recipe: **how to resolve the chunk paradox when one chunk size is provably > not enough.** Third-person analytical view for an agent writing / reviewing > RAG ingestion code — not an end-user tutorial.
---
1. 何时激活 (Activation Rules)
Activate this overlay when **all three** RAG preconditions hold and the chunk paradox has actually surfaced:
1. The corpus is **long documents** — prose manuals, financial filings, legal contracts, research papers, codebases — where a single answer-bearing fact sits inside a larger context that the LLM needs to interpret it. 2. A **chunk-size sweep has stalled**: small chunks (128–256) win retrieval precision but the LLM answers from fragments; large chunks (1024–2048) give rich context but recall on specific queries drops because the embedding becomes a "topic average". The official failure-mode checklist documents both poles as *separate* failures — #2 (wrong chunk from too-small) and #6 (context overflow / dilution from too-large) (cited in [[llamaindex]] R3). 3. Faithfulness or relevancy is **plateauing below target** and bumping `chunk_size` only moves the failure from one pole to the other.
Concrete triggers:
- "Answers are technically retrieved but the model lacks context to explain them."
- "I keep retuning chunk_size and it never wins on both faithfulness and recall."
- A reviewer sees `SentenceSplitter(chunk_size=4096)` shipped as the fix for
"incomplete answers" (this is anti-pattern A1 in [[llamaindex]]).
Do **not** activate when:
- The corpus is short/static (<100k tokens) — prompt-stuff with caching; multi-scale chunking is over-engineering (§6).
- The chunk-size sweep *did* converge on a single winner (e.g. 1024 for prose) — pin it and stop.
- Retrieval quality is fine and the bottleneck is orchestration or synthesis.
---
2. 核心心智模型 (Core Mental Model)
> **Decouple the embed-unit from the return-unit. Embed small for retrieval > precision; return large for generation context.**
The naive assumption is that the unit you index *is* the unit you feed the LLM. That single identity is the source of the paradox: it forces one chunk size to serve two opposing jobs.
NAIVE (one unit, two jobs) MULTI-SCALE (two units, one job each)
───────────────────────── ─────────────────────────────────────
[ chunk ] embed unit → small (precision job)
/ \ │
embed it feed it match
(wants (wants │
small) large) return unit → large (context job)
↓ ↓ ▲
CONFLICT — pick one, expand from
lose the other match → parent / windowThree load-bearing sub-principles:
1. **A Node is a graph node, not a chunk.** In LlamaIndex a `Node` carries `relationships` (PREV/NEXT/PARENT/CHILD). Those links are exactly what let you store a small node for matching and *resolve* it to a larger node for return ([[llamaindex]] Principle 2). Multi-scale chunking is "build a chunk-graph", not "split into chunks".
2. **Two geometries of expansion.** Once embed ≠ return, you must choose *how* the small match expands into the large return:
- **Horizontal** — return N adjacent sentences around the matched sentence
(sentence-window). The expansion is *positional*.
- **Vertical** — return the parent chunk when enough sibling children match
(auto-merging / parent-child). The expansion is *hierarchical*.
3. **Match the geometry to the document, not to taste.** Flat narrative prose → horizontal. Documents with real structure (headings, sections, tables of contents) → vertical. This is the central dilemma case (§5.1).
The overlay's promise: this *strictly dominates* a compromise chunk size when the sweep frontier is non-flat — you no longer average two bad sizes.
---
3. SOP 工作流 (Decision Protocol)
A three-gate protocol. Do **not** skip Gate 0 — multi-scale chunking is only justified once a single chunk size has been proven insufficient.
Gate 0 — Pick the base chunk size first (and try to stop here)
Run the canonical sweep from [[llamaindex]] OP-02 *before* reaching for any multi-scale machinery:
from llama_index.core.evaluation import (
FaithfulnessEvaluator, RelevancyEvaluator,
)
# 1. ~20 eval QA pairs via DatasetGenerator.from_documents(docs)
# 2. sweep:
for cs in (128, 256, 512, 1024, 2048): # overlap = 0.1–0.2Other skills on skillalchemy.
- /LEAP
LEAP — 落地执行引擎。内含两条管线:A 分支蒸馏(从 raw data 提取 skill)、 B 分支融合(多 skill 编织为一个)。被 SkillAlchemy 编排器调用。 Use when 编排器判断需要蒸馏或融合时。
Open skill - /Lens
Lens — 给你的问题加一层认知镜片。输入任意任务描述,输出增强版 description, 发现「你不知道自己不知道」的隐性维度、前置条件和认知路线。 Use when 用户说「帮我想想」「分析一下」「生成 skill」「蒸馏」「融合」 或输入看起来太简单需要展开。
Open skill - /agentsop-agent-topology-selection
Cross-framework enhancement overlay for choosing a multi-agent topology BEFORE writing any agent. A binary-question rubric — is single-agent + tools enough? do agents need to know about each other? does the output need one voice? — maps the answer to single-agent / supervisor /
Open skill - /agentsop-aider
SOP for terminal-based, git-native AI pair programming with Aider (git work-tree + tree-sitter repo-map + edit-format + human-in-loop REPL). Use when editing code in an existing git repo via an LLM, when you need to converge a change to 2-5 files, pick an edit format that fits
Open skill - /agentsop-bio-fraud-forensics
Screens biomedical / life-science papers for signs of data fabrication, image manipulation, and statistical anomalies, using the detection techniques distilled from the field's canonical exposure platforms (PubPeer, Data Colada, Science Integrity Digest, For Better Science) and
Open skill - /agentsop-bounded-loop
Universal discipline for any LM-driven loop — agent retries, plan-act-observe, multi-agent handoffs, optimiser passes, test-fix cycles. Encodes the one rule every framework documents quietly and every team relearns expensively: the LM in the loop is NEVER a reliable terminator.
Open skill

