Skip to content
reaatechREAATECH

@reaatech/agents-markdown-validator

npm v1.0.0

Validates AGENTS.md and SKILL.md files against the AGENTS.md specification, providing a set of functions (`validate`, `validateAgentsMd`, `validateSkillMd`) that accept parsed documents from `@reaatech/agents-markdown-parser` and return structured validation results

@reaatech/agents-markdown-validator

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Zod schema validation engine for AGENTS.md and SKILL.md files. Validates frontmatter structure, required sections, section ordering, skill references, MCP tools tables, and content quality against the AGENTS.md specification.

Installation

terminal
npm install @reaatech/agents-markdown-validator
# or
pnpm add @reaatech/agents-markdown-validator

Feature Overview

  • Frontmatter validation — Zod schemas enforce required YAML fields, types, and optional config
  • Required sections — Checks all mandated sections are present for both AGENTS.md (8 sections) and SKILL.md (5 sections)
  • Recommended sections — Warns on missing recommended sections for AGENTS.md
  • Section ordering — Validates that sections follow the recommended order
  • Skill references — Ensures referenced skills/*.md files exist and skill IDs are unique
  • MCP tools table — Validates table structure, required columns, and tool naming conventions
  • Content quality — Flags placeholder text (TODO, FIXME), empty sections, missing PII mentions, missing logging mentions
  • User-friendly errors — Formatted findings with context, suggestions, and grouped summaries

Quick Start

typescript
import { parseMarkdown } from "@reaatech/agents-markdown-parser";
import { validate, validateAgentsMd, validateSkillMd } from "@reaatech/agents-markdown-validator";
 
const doc = await parseMarkdown(content, "./AGENTS.md");
 
// Generic validate (auto-detects AGENTS.md vs SKILL.md)
const result = validate(doc, { strict: true });
 
if (!result.valid) {
  for (const error of result.errors) {
    console.error(`${error.rule}: ${error.message}`);
  }
}
 
// Type-specific validators
const agentResult = validateAgentsMd(doc, { basePath: "./", existingSkills: ["echo"] });
const skillResult = validateSkillMd(doc, { basePath: "./" });

API Reference

validate(document, options?)

Auto-dispatches to the correct validator based on document type.

typescript
function validate(
  document: AgentsMdDocument | SkillMdDocument,
  options?: ValidationOptions
): ValidationResult
 
interface ValidationOptions {
  strict?: boolean;         // Fail on warnings
  basePath?: string;        // Base path for skill resolution
  existingSkills?: string[]; // Known skill IDs for reference checking
}

validateMultiple(documents, options?)

Batch validate. Returns one ValidationResult per document.

AGENTS.md Validation (validateAgentsMd)

Validates 10 checks:

CheckSeverityDescription
Frontmatter existence + Zod parseerrorMust have valid YAML frontmatter
Confidence thresholderrorconfidence_threshold must be present
TitleerrorMust have a # heading
Required sectionserrorAll 7+ sections must exist
Recommended sectionswarning5 recommended sections should exist
Heading orderwarningHeadings must not skip levels
Skill referenceserrorReferenced skills must exist and be unique
PII handlingwarningSecurity section should mention PII
LoggingwarningObservability section should mention structured logging
Placeholders / emptywarningNo TODO/FIXME or empty sections

SKILL.md Validation (validateSkillMd)

Validates 8 checks:

CheckSeverityDescription
FrontmattererrorMust have valid YAML frontmatter
TitleerrorMust have a # heading
Required sectionserrorAll 5 sections must exist
MCP tools tableerrorMust have proper table with Tool, Input Schema, Output columns
MCP tool nameswarningTool names should follow naming conventions
Usage exampleswarningShould include both success and error cases
Security permissionswarningShould mention permission requirements
Placeholders / emptywarningNo placeholder text or empty sections

Helpers

typescript
function createFinding(
  rule: string, severity: Severity, message: string,
  location?: ErrorLocation, suggestion?: string,
  autoFixable?: boolean, fix?: unknown
): Finding
 
function createError(rule: string, message: string, location?: ErrorLocation): Finding
function createWarning(rule: string, message: string, location?: ErrorLocation): Finding
function createInfo(rule: string, message: string, location?: ErrorLocation): Finding
function createSuggestion(rule: string, message: string, location?: ErrorLocation): Finding
function createFixableFinding(rule: string, message: string, fix: unknown, location?: ErrorLocation): Finding

Error Formatting

FunctionDescription
formatFinding(finding)Human-readable finding with severity, rule, message, location, suggestion
formatValidationSummary(result)One-line summary: valid/invalid with counts
formatFindingsGrouped(findings)Grouped by severity with emoji headers
formatWithContext(finding, content, contextLines?)Finding + surrounding source lines
createErrorReport(results, options?)Full ASCII-boxed report with summary
getAutoFixableFindings(results)Filter to fixable findings with fix data

License

MIT