LEAP
LEAP builds skills through two pipelines: Branch A distills a skill from raw data, while Branch B combines multiple skills into one. It is called by the main…
Re-ingest-correctness SOP for production RAG. Activate when a calling agent builds, reviews, or debugs an ingestion pipeline that runs more than once over a changing corpus — scheduled re-index, incremental updates, CI re-ingest, or a "retrieval has duplicates / shows deleted
$ npx -y skills add agentsope/SkillAlchemy --skill agentsop-idempotent-ingestion --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/agentsop-idempotent-ingestionContext preview
The summary Claude sees to decide when to auto-load this skill.
Re-ingest-correctness SOP for production RAG. Activate when a calling agent builds, reviews, or debugs an ingestion pipeline that runs more than once over a changing corpus — scheduled re-index, incremental updates, CI re-ingest, or a "retrieval has duplicates / shows deleted
name: agentsop-idempotent-ingestion version: 0.1.0 description: | Re-ingest-correctness SOP for production RAG. Activate when a calling agent builds, reviews, or debugs an ingestion pipeline that runs more than once over a changing corpus — scheduled re-index, incremental updates, CI re-ingest, or a "retrieval has duplicates / shows deleted docs" bug. Encodes the rule — **ingestion must be idempotent: a document's content hash decides insert/update/skip, so re-running over unchanged docs is a no-op** — plus the docstore + doc-hash upsert machinery (LlamaIndex `IngestionPipeline` + `DocstoreStrategy`), the delete-propagation problem, and cross-framework equivalents (LangChain `index()` + `RecordManager`, manual hash table). ENHANCE overlay over [[llamaindex]]: the IngestionPipeline exists in the base skill but the re-ingest-correctness contract is not surfaced. trigger_keywords: - "idempotent ingestion" - "re-ingest" - "re-index" - "docstore" - "doc hash" - "upsert" - "duplicate chunks" - "IngestionPipeline" - "RecordManager" - "incremental update" - "scheduled reindex" when_to_use: - "any ingestion pipeline that will run more than once (cron, CI, webhook, manual re-run)" - "a corpus where source documents are added, edited, or deleted over time" - "debugging duplicate / stale chunks polluting retrieval after a re-run" - "reviewing a PR that calls VectorStoreIndex.from_documents / pipeline.run without a docstore" - "designing the ingestion side of a production RAG before first deploy" when_not_to_use: - "a one-shot index built once and never refreshed (static corpus, throwaway notebook)" - "the corpus is small enough to fully rebuild from scratch in seconds and rebuild-on-every-run is genuinely acceptable (measure first)" - "pure retrieval / query-time work with no ingestion path"
> Third-person operating model for a coder agent that owns ingestion > correctness across repeated runs. The audience is the LLM agent writing or > reviewing the pipeline code — not the end user.
> **One sentence**: *The interesting run is the second one. A correct pipeline > hashes each document, looks the hash up in a docstore, and inserts / updates > / skips accordingly — so re-running over unchanged docs changes nothing.*
This skill is an **ENHANCE overlay** over [[llamaindex]]. The base skill names `IngestionPipeline` with `docstore` + `UPSERTS_AND_DELETE` as a hardening must-have (OP-08, anti-pattern A10) but stops at "use it". This overlay surfaces the *correctness contract* — what idempotency actually means, how the hash decides the action, and how it generalises beyond LlamaIndex.
---
Activate this skill whenever **any** of the following holds:
1. The codebase contains an ingestion call (`VectorStoreIndex.from_documents`, `pipeline.run(documents=...)`, `vectorstore.add_documents`, a custom embed
that can change between runs. 2. The user mentions any of: re-ingest, re-index, scheduled / nightly index refresh, incremental document updates, docstore, doc hash, upsert, `RecordManager`, "keep the index in sync with the source". 3. A bug report says "I see the same answer chunk twice", "retrieval returns duplicates", "deleted a file but it still shows up in answers", "the index keeps growing every night even though nothing changed". 4. PR review: new ingestion code that builds the index with no docstore / no hash-keyed dedup and the corpus is live (LlamaIndex base skill A10). 5. A production RAG is about to ship and the ingestion side has only ever been tested as a cold first run.
Do **not** activate when:
is no second run to make idempotent.
cheaper than maintaining a docstore (rare; verify, don't assume).
ingestion path in scope.
---
Three principles. Violating any one means a second run can duplicate or corrupt the index — regardless of how good the retrieval stack downstream is.
> **Re-running the pipeline over an unchanged document is a no-op.** Run it > once, run it a thousand times — same index. The mechanism: each document is > reduced to a stable **content hash** (and a stable **doc id**); that hash is > looked up in a **docstore** (a key→hash record store separate from the vector > store); the lookup result decides the action.
doc_id seen? hash changed?
│ │
┌────────────┴───────────┐ ┌──────┴──────┐
no yes no yes
│ │ │ │
INSERT (embed + upsert) │ SKIP UPDATE
└──────────────►(delete old chunks,
re-embed, upsert)The hash is the whole game. Without it, the pipeline cannot tell "I have seen this exact content" from "this is new" — so it re-embeds and re-adds everything, and the vector store accumulates duplicates. (LlamaIndex base skill failure #3 / A10; `developers.llamaindex.ai/.../loading/ingestion_pipeline/`.)
The vector store holds embeddings keyed by node id. The **docstore** holds, per document, `{doc_id → content_hash}` (and the node ids derived from it). They are two stores with two jobs:
| Store | Holds | Answers | |---|---|---| | Docstore | `doc_id → hash`, doc→node mapping | "have I seen this content before?" | | Vector store | `node_id → embedding + metadata` | "what is semantically ne
Turn people, methods, and experience into installable, reusable agent skills. SkillAlchemy is an open-world agent skill creation system that turns underspecified skill briefs and open-world sources into installable, reusable agent skills.
LEAP builds skills through two pipelines: Branch A distills a skill from raw data, while Branch B combines multiple skills into one. It is called by the main…
Lens — Add a cognitive lens to any problem. It accepts a task description and produces an enhanced description that surfaces hidden dimensions, prerequisites,…
Cross-framework enhancement overlay for choosing a multi-agent topology BEFORE writing any agent. A binary-question rubric — is single-agent + tools enough? do…
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…
Screens biomedical / life-science papers for signs of data fabrication, image manipulation, and statistical anomalies, using the detection techniques distilled…
Universal discipline for any LM-driven loop — agent retries, plan-act-observe, multi-agent handoffs, optimiser passes, test-fix cycles. Encodes the one rule…