A Practical Guide to Turning Technical Books into Agent Skills
AI coding assistants often struggle with deep, domain-specific knowledge from technical books or internal design documents. While pasting entire texts into the context window is token-heavy and RAG can suffer from poor chunking, Agent Skills offer a structured alternative. This article outlines a three-step process to transform technical books into Agent Skills, covering how to structure SKILL.md, validate chapter segmentation, estimate token costs, verify hallucination rates, and avoid common pitfalls for team-wide sharing.
Why Turn Books into Agent Skills?
AI coding assistants can now read code, modify files, and participate in design discussions. However, when faced with details from a specific technical book or internal design document, they often give irrelevant answers or hallucinate plausible but incorrect content.
Developers typically take one of two approaches. The first is pasting the entire book into the chat window, which consumes a massive number of tokens and easily exceeds the model’s context length. The second is using Retrieval-Augmented Generation (RAG) to chunk the text and perform vector search, though inappropriate chunk sizes often lead to mismatched retrieval results.
Agent Skills provide a third approach. Instead of treating knowledge as a continuous block of text, it splits into two layers: a high-level mental model and chapter-based details. The Agent first reads the overview to determine the category of the question, then loads only the relevant chapters. This closely mimics how a human expert reads a book—building a broad framework first and consulting specific chapters when needed.
The Three-Step Process
The first step is specifying the source file and performing preprocessing. Inputs can be PDF manuals, Markdown design documents, or mixed-format resource packages. Preprocessing must complete text extraction, encoding unification, and basic cleaning to remove headers, footers, and redundant tables of contents.
The second step is structured extraction. This involves identifying three types of content from the text: the chapter framework (the knowledge map of the book), decision rules (which solution to choose under what conditions), and anti-patterns (typical practices to avoid). Once extracted, the content is split into independent knowledge units based on chapter boundaries. While LLMs can assist in extraction, the output must be manually reviewed, as models may miss critical conditions or alter the original meaning.
The third step is compiling the skill directory. The directory is generated under the Agent’s skills folder. Here is an example for a database indexing book:
skills/└── database-index/├── SKILL.md├── glossary.md└── chapters/├── ch01-index-basics.md├── ch02-btree-vs-hash.md└── ch07-pagination.md
Each file in the directory has a specific role. SKILL.md serves as the overview, while glossary.md contains core terms sorted alphabetically for quick reference. Under chapters/, each file represents a single chapter for on-demand loading. File names should ideally include the chapter number and topic keywords for easy indexing.
How to Write an Effective SKILL.md
The purpose of SKILL.md is to help the Agent quickly decide which chapter to load. It should contain two parts.
The first part is the mental model, consisting of core principles and judgment rules within the domain. For example, the fundamental trade-offs of index selection, the applicable scenarios for B+ trees versus hash indexes, and common cases of index failure. This section should be written in a “condition + conclusion” format, such as “Prioritize B+ trees for frequent range queries,” rather than just listing definitions.
The second part is the chapter index, telling the Agent which file to read for specific issues. For instance, “If pagination queries slow down with large data volumes, read ch07-pagination.md.”
Regarding length, a common recommendation is to keep the mental model section within a few thousand tokens. This is a design goal rather than an industry standard. The actual length should be adjusted based on the model’s context window and task complexity. If the overview is too long, the Agent’s attention may be diluted, leading to indexing errors.
How to Validate Chapter Segmentation
Chapter segmentation is critical to effectiveness. A chapter file should be self-contained. A reader should be able to answer common questions about that chapter’s topic just by reading that single file.
Validation can be done using the following methods:
- Prepare 5 to 10 typical questions for each chapter. Let the Agent answer using only that chapter’s file, and check whether the answer is complete and supported by the original text.
- Check for dangling references. Search the chapter files for phrases like “see Chapter X” or “refer to the original text.” Such references indicate content dependency on other chapters. These should either be rewritten as self-contained explanations or have the dependent content included directly.
- Check if the length of a single chapter is reasonable. Chapters that are too short may lack context, while overly long chapters increase loading costs. Consider splitting them further by section if necessary.
Thresholds for validation standards must be defined by your team. For example, you might require that most test questions can be answered by a single chapter, but the exact ratio should be determined based on business risk and historical data.
How to Estimate Token Costs
The cost of on-demand loading depends on two factors: the length of the indexed chapter and the number of chapters loaded in a single conversation.
Token conversion for Chinese text varies by model and tokenizer, with one Chinese character typically taking about 1 to 2 tokens. For estimation, it is best to test directly using the target platform’s token counting tool. A chapter of 5,000 characters roughly translates to a few thousand tokens. Loading the entire book would consume significantly more tokens. To calculate the single-run cost, multiply the token count by the unit price of the corresponding platform. Note that billing rules differ across platforms, so consult the official documentation.
Don’t just look at a single load. The Agent reads the overview and the hit chapters for every response, meaning the cumulative consumption across multi-turn dialogues must be factored in.
How to Verify Hallucination Rates
On-demand loading can reduce hallucinations, but the results must be backed by data rather than intuition.
A recommended practice is to establish a fixed set of test questions and run them under two conditions: directly giving the Agent the entire book, and using the skill directory. Record the hit rate (whether the answer is based on the correct chapter) and the error rate (whether there are factual or parameter inaccuracies). Comparing these two datasets will determine if the skill directory actually brings improvements.
It is important to note that on-demand loading is more likely to reduce errors only when the index is hit correctly and the chapter content is complete. If the index is written incorrectly or chapter segmentation breaks the context, the results may actually worsen.
Common Pitfalls
The most common mistakes in practice fall into the following categories:
- Writing only definitions without decision rules. The Agent knows “what an index is” but not “which index to use and when.”
- Ignoring anti-patterns. Experiences like “using a function on a column causes index failure” help the Agent understand boundary conditions. Omitting these makes answers less targeted.
- Inter-dependencies between chapters. Loading a single chapter without prerequisite information results in incomplete answers.
- Treating extraction results as absolute truth. Model extractions can contain errors; critical rules must be verified against the original text.
What to Consider for Team Sharing
Skills can be packaged and copied to other environments, provided the target platform supports the same Skill specification. Directory conventions, loading methods, and version requirements may vary across platforms, so check platform documentation before migration.
When used by a team, the following processes are recommended:
- Version control: Include the skill directory in the code repository to ensure every modification has a commit record.
- Review mechanism: Have domain experts review decision rules and anti-patterns to prevent the spread of incorrect knowledge.
- Copyright review: Confirm the licensing scope of the original book or internal document before deciding whether it can be shared.
- Data sanitization: Sensitive information such as keys, customer data, and internal IP addresses in internal documents must be deleted before compilation.
By following these steps, books and documents can be transformed into maintainable and verifiable team knowledge assets. New members can directly utilize this expertise while coding.
