frontmatter-guard

Validate and auto-repair YAML frontmatter on brain pages via the gbrain CLI.

Updated Aug 17, 2026
One-click install
npx skills add https://github.com/AMC-JTC/gbrain-1 --skill frontmatter-guard-amc-jtc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontmatter-guard
Source: https://github.com/AMC-JTC/gbrain-1/tree/main/plugin/skills/frontmatter-guard
Command: npx skills add https://github.com/AMC-JTC/gbrain-1 --skill frontmatter-guard-amc-jtc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Brain pages accumulate malformed YAML frontmatter over time — missing closing markers, nested quotes, slug mismatches, null bytes — which silently break sync and search until they surface as failures. This Skill audits, validates, and auto-repairs frontmatter before corrupted pages enter the brain. ## Core Features & Use Cases - Eight-class validation: Detects MISSING_OPEN, MISSING_CLOSE, YAML_PARSE, SLUG_MISMATCH, NULL_BYTES, NESTED_QUOTES, NON_STRING_FIELD, and EMPTY_FRONTMATTER errors across all registered sources. - Safe auto-repair: The --fix flag writes .bak backups before mutating files, with --dry-run previews for batch operations. - CI and pre-commit integration: Validate single paths with exit codes for pipelines, or install a git pre-commit hook to block malformed pages at commit time. - Use Case: After months of agent-written pages, run an audit to find 17 issues across your brain, preview the fixes, then repair them with backups while leaving human-authored drafts untouched. ## Quick Start Ask the agent to run a frontmatter audit across the brain and report how many issues exist per error class before fixing anything.

Frequently Asked Questions about frontmatter-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate YAML frontmatter on brain pages?

Run gbrain frontmatter audit --json to scan all registered sources, or gbrain frontmatter validate <path> --json for a single file or directory. The audit reports per-source counts grouped by eight error codes with samples of affected pages.

How to auto-fix broken frontmatter in markdown files?

Run gbrain frontmatter validate <path> --fix to repair auto-fixable classes like MISSING_CLOSE, NESTED_QUOTES, NULL_BYTES, and SLUG_MISMATCH. Every modified file gets a .bak backup first, and --dry-run previews changes without writing.

Can frontmatter validation run in a pre-commit hook or CI pipeline?

Yes. gbrain frontmatter install-hook adds a git pre-commit hook that validates staged .md and .mdx files, bypassable with git commit --no-verify. For CI, validate exits with code 0 when clean and 1 when errors are found.

Why does frontmatter validation flag JSON-style arrays in tags?

Before v0.37.5.0 the validator counted unescaped double quotes, falsely flagging valid YAML like tags: ["yc", "w2025"]. Newer versions parse suspicious values with js-yaml before flagging, so JSON-style arrays no longer trigger NESTED_QUOTES, though single-quoted YAML remains canonical.

Which frontmatter errors cannot be auto-fixed?

MISSING_OPEN, EMPTY_FRONTMATTER, and NON_STRING_FIELD require human input and are never auto-fixed. MISSING_OPEN and EMPTY_FRONTMATTER usually indicate an unfinished human draft, while NON_STRING_FIELD values like unquoted numbers must be quoted manually.