Skip to content
reaatechREAATECH

@reaatech/agents-markdown-linter

npm v1.0.0

Enforces style, content, and best-practice standards for AGENTS.md and SKILL.md files through a set of exported functions for linting and auto-fixing. It requires a document object parsed by `@reaatech/agents-markdown-parser` to execute its rule registry.

@reaatech/agents-markdown-linter

npm version License: MIT CI

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

Style, content, and best-practice linting rules for AGENTS.md and SKILL.md files. Ships with 18 built-in rules across three categories, plus an extensible rule registry and auto-fix engine for format-level issues.

Installation

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

Feature Overview

  • 18 built-in rules — Style (6), Content (7), Best Practice (5) covering formatting, structure, and quality
  • Extensible rule registry — Register custom lint rules with registerRule
  • Auto-fix engine — Fix trailing whitespace, missing code block languages, inconsistent table formats, and missing headings
  • Severity levelserror, warning, info, suggestion
  • Per-rule isolation — A failing rule does not abort the lint run
  • Finding output — Standard Finding[] format consumable by reporters

Quick Start

typescript
import { parseMarkdown } from "@reaatech/agents-markdown-parser";
import { runLintRules, registerRule, runAutoFix } from "@reaatech/agents-markdown-linter";
 
const doc = await parseMarkdown(content, "./AGENTS.md");
const result = runLintRules(doc);
 
console.log(`Errors: ${result.errorCount}, Warnings: ${result.warningCount}`);
 
for (const finding of result.findings) {
  console.log(`${finding.severity}: ${finding.rule} — ${finding.message}`);
}
 
// Auto-fix formatting issues
const fixed = runAutoFix(content, ["trailing-whitespace", "no-code-language", "table-format"]);

API Reference

runLintRules(document)

Runs all registered rules against a document. Catches per-rule errors so one failing rule does not abort the run.

typescript
function runLintRules(
  document: AgentsMdDocument | SkillMdDocument
): LintResult

registerRule(category, ruleId, rule, definition)

Register a custom lint rule. Rules are side-effect modules — importing @reaatech/agents-markdown-linter automatically registers all built-in rules.

typescript
function registerRule(
  category: "style" | "content" | "bestPractice",
  ruleId: string,
  rule: LintRule,
  definition: RuleDefinition
): void

getRegisteredRules()

typescript
function getRegisteredRules(): RuleDefinition[]

runAutoFix(content, ruleIds)

Apply auto-fixes for the specified rules. Returns the fixed content string.

typescript
function runAutoFix(content: string, ruleIds: string[]): string

getAutoFixableRules()

Returns the list of rule IDs that support auto-fix.

typescript
function getAutoFixableRules(): string[]

Built-in Rules

Style Rules

Rule IDSeverityAuto-fixDescription
heading-orderwarningNoHeading levels must not be skipped (e.g., ## then ####)
no-code-languagewarningYesCode blocks should specify a language
trailing-whitespaceinfoYesLines must not have trailing whitespace
line-too-longinfoNoLines must not exceed 120 characters
table-formatwarningYesTable rows must have consistent column counts
list-formatwarningNoList markers must be consistent within a list

Content Rules

Rule IDSeverityAuto-fixDescription
heading-missingerrorYesRequired section headings must be present
empty-sectionwarningNoSections must contain content
placeholder-textwarningNoNo TODO/FIXME/TBD placeholders
duplicate-sectionerrorNoSection titles must be unique
broken-skill-referrorNoReferenced skill files must exist
duplicate-skill-iderrorNoSkill IDs must be unique
section-orderingwarningNoSections should follow recommended order
min-content-lengthwarningNoSections should have minimum content (20 chars)

Best Practice Rules

Rule IDSeverityAuto-fixDescription
missing-pii-mentionwarningNoSecurity section should mention PII handling
missing-observabilitywarningNoObservability section should mention structured logging
incomplete-exampleswarningNoUsage examples should include both success and error cases
missing-mcp-schemawarningNoMCP tools should have input schemas documented
missing-confidenceerrorNoAgent config must include confidence_threshold

Custom Rule Example

typescript
import { registerRule } from "@reaatech/agents-markdown-linter";
 
registerRule("style", "my-custom-rule",
  (doc) => {
    const findings = [];
    if (!doc.frontmatter.description) {
      findings.push({
        ruleId: "my-custom-rule",
        severity: "warning",
        message: "Description is recommended in frontmatter",
      });
    }
    return findings;
  },
  {
    id: "my-custom-rule",
    description: "Enforce description in frontmatter",
    severity: "warning",
    category: "style",
    autoFixable: false,
  }
);

License

MIT