Markdown Reading & Analysis Skills
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
Markdown Reading & Analysis Skills refer to a specialized toolset and methodology within the WHK project designed for the rapid inspection, structural analysis, and content previewing of Markdown documentation. These skills are primarily utilized by AI agents and developers to navigate the project's extensive docs/ directory, which contains over 100 knowledge-point documents. The system provides automated utilities to extract hierarchy, validate naming conventions, and manage large-scale document processing.
The core purpose of these skills is to facilitate efficient content integration and quality control, particularly during workflows like "Supplement Integration," where external notes are merged into the main knowledge base. By providing granular tools for reading headers and splitting large files, the system ensures that AI agents can process technical content without exceeding context window limitations while maintaining strict adherence to the project's structural requirements.
Sources: AGENTS.md:7-10, scripts/skills/read/SKILL.md:3-5, scripts/workflows/supplement-integration-v2.md:1-5
Core Toolset Architecture
The "read" skill is implemented as a collection of Node.js scripts located in scripts/skills/read/. Each tool serves a specific phase of document analysis, ranging from high-level directory scanning to granular file content manipulation.
Analysis Components
| Tool Name | Script Path | Primary Function |
|---|---|---|
| dir_h1 | scripts/skills/read/dir_h1.js | Scans the docs directory and extracts the first H1 header from every .md file. |
| file_headings | scripts/skills/read/file_headings.js | Extracts all Markdown headings (lines starting with # ) with their corresponding line numbers. |
| file_prelimit | scripts/skills/read/file_prelimit.js | Previews the first 1000 content characters of a file, skipping YAML frontmatter. |
| file_split | scripts/skills/read/file_split.js | Segments large Markdown files into 20,000-character chunks for easier processing. |
Sources: scripts/skills/read/SKILL.md:9-91, AGENTS.md:27-32
Data Flow for Document Inspection
The following diagram illustrates how the tools are sequentially used to analyze a document from a global perspective down to specific content.
Structural Analysis Logic
Header Extraction (dir_h1 & file_headings)
The system distinguishes between a file's first H1 (used for indexing) and its overall structure.
- dir_h1: Specifically looks for the first occurrence of
#to establish a human-readable index for thedocs/folder. - file_headings: Identifies any line where
#is immediately followed by a space. It outputs the line number in brackets, e.g.,[4] ## H2, allowing agents to jump directly to sections within an editor.
Sources: scripts/skills/read/SKILL.md:11-47
Content Previewing (file_prelimit)
The file_prelimit tool implements a "smart skip" logic for YAML frontmatter. If the first non-empty line of a file is ---, the counter only starts after the second --- is encountered. It counts 1000 characters of actual content (excluding whitespace and empty lines for the limit) but preserves original formatting in the output.
Sources: scripts/skills/read/SKILL.md:52-73
Large File Management (file_split)
To handle files exceeding AI context limits, the file_split utility segments files at 20,000-character intervals.
- Naming Convention:
original_filename.001.tmp,original_filename.002.tmp. - Threshold: Files smaller than 20,000 characters are not split.
Sources: scripts/skills/read/SKILL.md:78-91
Integration Workflows
Markdown Reading & Analysis skills are fundamental to the supplement-integration workflow. This workflow uses the tools to map content from dev/supplement/ to the appropriate target files in docs/.
Sequence for Supplement Integration
The following sequence diagram shows how the reading skills are leveraged during the planning and execution phases of content integration.
Implementation Examples
Extracting Headings
node scripts/skills/read/file_headings.js docs/science/mechanics/1.md
Output Example:
[2] # Mechanics Overview
[15] ## Kinematics
[42] ### Linear Motion
Sources: scripts/skills/read/SKILL.md:43-45
Segmenting Large Files
node scripts/skills/read/file_split.js dev/supplement/huge_notes.md
Output Example:
Split dev/supplement/huge_notes.md into 2 parts:
dev/supplement/huge_notes.md.001.tmp 19,950 bytes
dev/supplement/huge_notes.md.002.tmp 4,200 bytes
Sources: scripts/skills/read/SKILL.md:88-90
Conclusion
The Markdown Reading & Analysis Skills provide the foundational infrastructure for maintaining the WHK project's documentation standards. By automating the extraction of headers, managing file sizes, and providing intelligent previews that account for metadata, these tools enable a highly structured approach to technical writing and content management. They ensure that even as the repository scales, documents remain navigable and compatible with AI-assisted workflows.