Knowledge Engineering: RAG-Oriented Atomic Chunking Skill for Long Documents

Introduction

When building a self-hosted RAG knowledge base, a common practice is to mechanically chunk text by fixed word counts or paragraphs before writing it directly into the vector database. In long documents, cross-paragraph references, truncated code blocks, or fragments lacking metadata for retrieval often lead to a situation where items are “searchable but answer incorrectly.” It also becomes difficult to determine whether the issue lies in the chunking strategy or the embedding model.

The following is an introduction to knowledge-engineering on SkillHub (currently installable version v1.0.13, author Smart Peninsula). It treats the Agent as a knowledge base ETL controller: splitting documents at semantic boundaries, isolating outputs by directory, and using scripts for validation and retrieval evaluation. It integrates “actionable, quantifiable, and optimizable” standards into the workflow, rather than just providing a generic chunking prompt.

What is this

knowledge-engineering is an Agent Skill following the universal SKILL.md format, positioned as a “RAG Knowledge Base Atomic Slicing Controller.” It splits long documents into L0-level atomic slices that are semantically complete, physically isolated, self-contained, and retrieval-ready. It also builds in multi-layer quality gates for Validation → Auditing → Retrieval Accessibility Evaluation.

The official source address is https://api.skillhub.cn/user_741dc82b/knowledge-engineering; this API page is currently not directly browsable (HTTP 405), and the corresponding @user_741dc82b/knowledge-engineering on the SkillHub site shows as offline. A skill with the same name, @indiv-ebandao/knowledge-engineering, is still available in the store. The version and package descriptions match (1.0.13). The installation and usage instructions below are based on this package.

Core Functions

The following capabilities are derived from the SKILL.md and accompanying script documentation within the v1.0.13 package.

Standard 5-Step Closed Loop

Step Action Main Means Output
① Analysis Structure scan, Token budget, circuit breaker rehearsal, directory decision <analysis> pre-processing chain of thought (§0) Slicing plan
② Plan Classification routing and splitting scheme slice_generator.py --json JSON slicing plan
③ Generate Write semantic content and YAML according to templates Agent generates per §3 .md slice with 14 mandatory fields
④ Validate Single slice integrity + cross-slice audit validate_slice.py --fix, batch_audit.py Regenerate fatal issues / Warn flags
⑤ Final Check Retrieval accessibility evaluate_retrieval.py --fix R@1, R@5, MRR and dead slice repair

Slicing Rules and Output Contract

  • Absolute Directory Isolation: Each source file corresponds to a {Source-ID}/ directory; scattering slices in the output root directory is prohibited.
  • Semantic Priority, Word Count Fallback, Backtracking Protection: Soft upper limits such as ~700 words for plain text and ~500 words for code; do not hard-cut in the middle of code blocks, tables, or step lists.
  • Zero References, No Destructive Rewriting: Slices must be self-contained; key parameters and error codes must match the original text.
  • YAML + Markdown Template: Each slice contains 14 mandatory fields including title, embedding_hint, qa_pairs, hybrid_keywords, cross_refs, etc., serving hybrid retrieval and quality inspection.
  • Secondary Directory Routing: Categorize content into api/, config/, guide/, concepts/, misc/, multimodal/, etc. (including dynamic degradation rules).

Long Tasks and Anti-Interruption

Large batches or ultra-long documents must follow Init → Step → Poll: First output a plan and confirm with the user, then generate in small batches (max 2 slices per batch for super-large documents), and validate immediately after each slice is written; support --resume for checkpoint continuation. batch_audit.py and evaluate_retrieval.py must be run before final delivery.

Environment Dependencies

Running scripts requires Python 3.8+; for retrieval evaluation, it is recommended to install sentence-transformers, numpy, pyyaml (if missing, the evaluation layer can degrade to PurePythonEmbedder). The Skill explicitly requires not calling external LLM APIs to generate slice body text or metadata; metadata is filled in by the current Agent’s reasoning.

Installation and Activation

Method 1: Let the Agent install via SkillHub documentation

Send the following in the conversation (content from the SkillHub skill page):

Please install @indiv-ebandao/knowledge-engineering according to https://skillhub.cn/install/skillhub.md.

If you still hold the old namespace, the notation in the source is @user_741dc82b/knowledge-engineering; this path is no longer available on the site, please use the indiv-ebandao namespace above.

Method 2: SkillHub CLI

First confirm the CLI (see SkillHub Installation Instructions):

command -v skillhub && skillhub --version

Install to the current Agent’s skills directory (must use --dir, otherwise the default ./skills/ might not be loaded by the IDE):

skillhub install knowledge-engineering --namespace indiv-ebandao --dir ~/.cursor/skills/

Common paths (excerpted from official installation docs):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project

Restart or refresh the Agent after installation to make knowledge-engineering available in the skills list. Windows / Linux / macOS are marked as fully supported in the package metadata.

Typical Usage

Minimal Command Example

The minimal usable entry point provided in the package is as follows, used to generate a slice directory structure from a single file:

python scripts/slice_generator.py input.md slices/

In the Agent workspace where this Skill is enabled, the scripts/ above refers to the script path within the skill package (located in the knowledge-engineering package under the corresponding skills directory after installation).

  1. Generate plan and optional stubs:
python scripts/slice_generator.py <source_file.md> <output_dir> --stubs --json
  1. After the Agent completes <analysis> per §0 and gets user confirmation, fill in the §3 template content slice by slice and write to disk.

  2. Validate each slice, batch audit, and final retrieval check:

python scripts/validate_slice.py <slice_file> --fix --json
python scripts/batch_audit.py <output_dir> --fix
python scripts/evaluate_retrieval.py <output_dir> --fix

Natural Language Triggering

The user side only needs to state the intent, e.g., “Slice xxx.md”. The Agent should first analyze and display the plan (on the order of 10 to 30 seconds), wait for confirmation, and then generate in batches; variants like “show plan first” or “start from docx” are also supported. See REFERENCE.md in the package for specific boundaries.

Symptom Troubleshooting

Symptom Recommended Command
Missing YAML fields or format issues python scripts/validate_slice.py <file> --fix --json
Discontinuous index, dead links python scripts/batch_audit.py <dir> --fix
Need R@1 / R@5 / MRR python scripts/evaluate_retrieval.py <dir> --fix
Task interrupted python scripts/slice_generator.py <src> <out> --resume

Applicable Scenarios and Notes

Who it is for: Teams or individuals who need to import long Markdown/text (also supports txt, yaml, json, PDF, etc., see §9) such as technical manuals, API docs, and ops guides into RAG, and want slicing quality to be auditable and retrieval effects to be quantifiable.

Not suitable for: Expecting the skill to automatically crawl dynamic web pages, directly slice database tables, or perform OCR-level multimodal understanding of images—these are explicitly not supported within the capability boundaries.

Usage Notes:

  • Batch writing files without completing the <analysis> in §0 and user confirmation is a serious violation defined by the documentation.
  • Using script templates to batch fill embedding_hint, qa_pairs, etc. is considered an anti-pattern and may decrease retrieval hit rates.
  • When involving network drive paths (like Windows mapped drives), prioritize using methods required by the Skill like python_executor for reading and writing to avoid silent failures.
  • For destructive commands outside the working directory, the Skill carries HARB constraints; commands must be previewed and await user confirmation.

Conclusion

knowledge-engineering turns RAG slicing from “chunking by feel” into a checkable pipeline: semantic and directory contracts ensure usability within slices, while validation and evaluate_retrieval.py make optimization verifiable. If the API address in the source is unopenable, you can install @indiv-ebandao/knowledge-engineering (v1.0.13) via SkillHub to obtain the same capabilities.

  • Official Source Address: https://api.skillhub.cn/user_741dc82b/knowledge-engineering
  • Currently Accessible Skill Page: https://www.skillhub.cn/skills/indiv-ebandao/knowledge-engineering
  • Installation Instructions: https://skillhub.cn/install/skillhub.md
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye