Harness Engineering: A Practical Guide to Building an LLM Knowledge Base
This article explains how Harness engineering turns one-off LLM conversations into reusable assets by treating a knowledge base as a compiled system. It covers three core constraints—immutable raw data, model-maintained derived content, and structure as an interface—along with a four-layer directory layout, ingestion and compilation workflows, a lightweight Q&A approach that avoids complex retrieval stacks at small scale, output and acceptance checks, and common failure modes with practical countermeasures.
1. The Starting Point: Why Token Spend Should Shift from “Code” to “Knowledge”
After using large models for a large volume of engineering tasks, a common pattern emerges: the truly scarce resource is not the number of model calls, but the quality of context and the continuity of state. If every conversation starts from zero, the model has to re-understand the background and repeatedly retrieve the same material, so tokens get consumed by low-value repetitive work. Harness engineering—which can be understood as the “operating scaffold” built around a model—focuses on exactly this problem: how to continuously turn inputs from the external world into reusable artifacts, so the model works on a stable structure instead of struggling inside messy, temporary context.
One repeatedly validated lesson is that continuously persisting state as artifacts, and shifting the human role from “step-by-step operation” to “setting goals and accepting results” (on-the-loop, rather than in-the-loop), significantly improves system stability. Building a knowledge base is the most direct application of this idea: knowledge itself is stored as plain text and images, which makes it naturally versionable, diffable, and repeatedly compilable by the model.
2. Core Design Principles: Three Constraints Determine Success
- Raw data is immutable: all external inputs first enter an append-only raw layer, ensuring traceability and rebuildability.
- All derived content is maintained by the model: summaries, entries, backlinks, and indexes are generated by the model; humans only review and correct direction, avoiding manual maintenance costs that grow linearly with scale.
- Structure is the interface: directory conventions and file naming are the contract between humans and the model; only when the structure is stable is model behavior stable.
Together, these three constraints form the foundation of a “compiled knowledge base”: the raw layer is the source code, the derived layer is the build output, and you can recompile from the raw layer at any time.
3. Implementation Architecture: Four Directory Layers and Clear Responsibilities
A working layout typically contains the following layers (illustrative):
kb/├── raw/ # Append-only raw inputs: articles, papers, repo snapshots, dataset notes, images├── wiki/ # Compiled output: concept entries, topic overviews, backlinks├── index/ # Indexes and manifests: source list, concept map, TODOs and gaps└── out/ # Derived deliverables: documents, slides, charts
- raw/: stores original text and localized images. Localizing images is critical—the model is more stable when referencing local resources, and it avoids broken external links.
- wiki/: organized by concept rather than by source, with one entry per concept; entries link to each other, forming a navigable knowledge network.
- index/: maintains a “source-to-concept” mapping table and a coverage checklist, which is the key to replacing complex retrieval solutions in small-scale scenarios.
- out/: stores all human-facing deliverables in one place for easy traceback and reuse.
4. Ingestion: Standardizing Heterogeneous Inputs
The goal of ingestion is not to “read everything,” but to turn material into something compilable. Key practices include:
- Normalize everything into a plain-text markup format, preserving heading levels, lists, and code blocks, because structural information directly affects the quality of later summaries.
- Generate a stable identifier and metadata for each source (source type, collection time, topic tags) and write them into the index manifest.
- Localize attachments such as images and tables, and keep relative reference paths in the body text.
- Ingest in batches, triggering a compilation immediately after each batch completes, to avoid context overflow from piling everything up at once.
An illustrative metadata convention:
id: paper-2026-0142type: papertopic: [harness, knowledge-base]collected: 2026-04-04raw_path: raw/paper-2026-0142.md
5. Compilation: From Source Text to a Concept Network
Compilation is the process of “turning raw material into structure.” It is best split into three steps, each producing inspectable intermediate artifacts:
- Single-source summary: generate a structured summary for each source (problem, method, conclusion, reusable points) and write back backlinks.
- Concept extraction: extract candidate concepts from the summaries, merge them with existing concepts in the index, and decide whether to “create a new entry” or “merge into an existing entry.”
- Entry integration: write entries around concepts, present views from multiple sources side by side, flag disagreements and boundary conditions, and fill in cross-links between entries.
The engineering value of this step is that the model faces “a set of summaries plus an index manifest” rather than an ocean of raw full text, keeping context usage under control, with each step independently re-runnable.
6. Q&A: No Complex Retrieval Stack Needed at Small Scale
When the knowledge base is at the scale of hundreds of documents and hundreds of thousands of words, a common mistake is to immediately introduce complex vector retrieval and multi-route recall pipelines. A more pragmatic approach is to let the model first read the index and concept entries to locate relevant concepts, then read the corresponding summaries and key source excerpts on demand, and finally organize the answer. This works for two reasons: first, the index and summaries are themselves a “compressed representation” maintained by the model; second, concept entries have already aggregated cross-document information.
A few conventions for improving answer quality:
- Require answers to include source identifiers, making manual verification easy.
- For conflicting conclusions, list them explicitly and explain the source differences.
- If the index shows insufficient coverage, allow the model to directly answer “there is a gap in the current knowledge base” instead of fabricating an answer.
7. Output and Acceptance: Putting Humans Back in the Review Seat
Deliverables should prioritize versionable formats: structured documents, slide-style presentations, and script-generated charts. The value of output lies not in form, but in being reviewable, diffable, and regression-testable. The acceptance step should be fixed to three checks: whether citations can be located, whether conclusions are consistent with sources, and whether new content has been written back to the index and backlinks.
8. Common Failure Modes and Countermeasures
- Raw layer contamination: once direct editing of raw files is allowed, rebuild capability is lost; the countermeasure is to enforce read-only access through permissions and process.
- Concept entry bloat: stuffing too many topics into one entry degrades it into a “catch-all”; the countermeasure is to set entry length and single-topic constraints, and split promptly.
- Index drift: new sources not written back to the index distort coverage judgments; the countermeasure is to make index updates a mandatory step of compilation.
- Over-engineering: introducing complex retrieval and multi-agent orchestration too early makes maintenance costs exceed the benefits; the countermeasure is to first get the minimal loop of “ingest—compile—Q&A—output” working, then enhance as needed.
9. Conclusion
The essence of Harness engineering is turning “one-off conversations” into “accumulating assets.” When raw data stays immutable, derived content is uniformly maintained by the model, and the directory structure acts as a stable interface, the knowledge base generates compounding returns over time: the more you ingest, the less effort compilation takes, the more accurate Q&A becomes, and the more reliable the output. For developers, this method also applies to codebase understanding, technology selection research, and incident retrospectives—any domain that requires long-term accumulation and repeated reference can follow the same logic of “artifact persistence plus humans on-the-loop.”
