frontmatter-guard
What it does
This skill checks the hidden header section on each brain page for mistakes. It can repair common errors automatically after you approve a preview.
When to use it
- ✓When a brain page fails to sync or shows garbled search results.
- ✓When you want to check all of your pages for header errors before a big import.
- ✓When a page has a missing closing line, nested quotes, or a title that does not match its file name.
Skill link
https://github.com/garrytan/gbrain/blob/master/plugin/skills/frontmatter-guard/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Check all my brain pages for broken header details, and show me a preview of any fixes before you apply them.”
5 new skills a week. 1 minute to read.
How it works
The agent scans each page against a set of standard checks. It explains each problem, then makes a backup and applies a fix only after you approve the preview.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Frontmatter Guard Skill
Convention: see
skills/conventions/quality.mdfor citation rules; this skill is structural validation, not citation auditing.
Contract
This skill guarantees:
- Every brain page is scanned against the eight canonical frontmatter validation classes
- Mechanical errors (nested quotes, missing closing
---, null bytes, slug mismatch) are auto-repairable on demand with.bakbackups - Validation logic is shared with
gbrain doctor'sfrontmatter_integritysubcheck — single source of truth - Reports per source (gbrain is multi-source since v0.18.0); never silently audits the wrong root
- Files sync holds are explained from their hold record (code, reason, key, line, fix) and fixed only through a previewed, hash-bound repair the user approved
Why This Exists
Brain pages pile up over months. Agents write them with malformed frontmatter:
- Missing closing
---(entity detector bugs) - Unstructured YAML in meeting pages (ingestion bugs)
- Slug mismatches (path renames not propagated)
- Null bytes (binary corruption from copy-paste accidents)
- Nested double quotes in titles (
title: "Alice "Ace" Example")
Without a guard, these accumulate silently until gbrain sync chokes or search returns garbage. The guard makes the failure visible at audit time and trivially fixable.
Write brain files safely (do this first)
Write pages through
put_page/capture(MCP orgbrain put). gbrain serializes frontmatter itself, so the file on disk is always valid YAML.A script or agent that writes Markdown files directly must build frontmatter with a YAML serializer (
yaml.dump, js-yamldump), never by string interpolation.title: ${title}breaks as soon as a title contains:,#, quotes or a newline.Check generated content before writing it, without touching disk:
printf '%s' "$content" | gbrain frontmatter validate --stdin --path notes/2026-10-04-digest.mdExit 1 means fix it first. The default is the strict producer rule: YAML gbrain could still import by quoting a value fails too, because other tools reject it.
--importableanswers the narrower question "would sync hold it?".Never write a key gbrain reads for access or identity (
visibility,derived_from,slug,type,id,source_id) from untrusted text.
Held files: read them, then fix them
A file sync cannot import without guessing is held: the rest of the source still syncs, a new file has no page yet, and an existing page keeps its last good revision and refuses put_page until the file is repaired (do not retry the write). Where holds show up: sync output (Held <path>: <code> … Next: <command>), gbrain sources status <id> (--json: git_holds.items[]), doctor git_held_files, get_page file_held, and search hits marked stale.
Each hold record carries code, reason, key, line, message (location only, never the value), fix (exact argv) and docs. Act on reason:
| Hold | What to do |
|---|---|
invalid_frontmatter / yaml_parse |
Preview gbrain repair frontmatter --source <id>; usually needs_review with the exact line to fix by hand. |
invalid_frontmatter / needs_interpretation |
Preview with --include-ambiguous, show the user each per-file diff, apply only what they approve. |
invalid_frontmatter / ambiguous_identity_key or ambiguous_protected_key; visibility_noncanonical |
Never guess. Show the user the line; they decide the one value (visibility decides who can read the page; page privacy reads only visibility: private, lowercase on its own line). |
frontmatter_slug_conflict |
Remove the slug: line or move the file; the repair proposes removing it under --include-ambiguous. |
file_too_large |
The file is over the fixed page limit (24 MiB for Markdown, 5 MB for code); every page under it is searchable, so never split one that fits. Ask the user to add it to sync.exclude, or to split it into files under the limit. A smaller page an MCP transport refused goes by file instead (docs/guides/memory-boundaries.md#large-page-limits). |
content_rejected |
The user chose content_sanity.junk_disposition=reject; ask before changing it. |
The fix flow (walkthrough with real output: docs/guides/repair.md#held-files):
gbrain sources status <id> # what is held and why
gbrain repair frontmatter --source <id> # pass 1: safe quotin
FAQ
Will it change my pages without asking?
No. Repairs are shown as a preview first, and a backup is kept.
What kinds of errors does it catch?
Missing closing lines, nested quotes, mismatched names, empty headers, and corrupted characters.
Why does sync skip some files?
The skill explains each hold from its record and fixes it only through an approved repair.
Details
Original description by the author
Validate and auto-repair YAML frontmatter on brain pages. Catches malformed pages before they enter the brain (missing closing ---, nested quotes, slug mismatches, null bytes, empty frontmatter, YAML parse failures), explains files sync holds instead of importing, and drives the previewed `gbrain repair frontmatter` fix. Wraps the `gbrain frontmatter` CLI for agent-driven workflows.
repo: garrytan/gbrain
Popularity
- GitHub stars
- 31k
- Ranking position
- #9302
- License
- MIT
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
gbrain
31kLets your agent search a shared company knowledge brain for facts about people, projects and decisions, and save durable notes to it.
brain-ingest-gate
31kChecks new content against an existing knowledge brain before it is added, to avoid duplicates and resolve named entities first.
brain-link-discipline
31kMakes sure your agent includes a working link to each brain page it reports, in the same message, so you can open it right away.
brain-ops
31kGives your agent the core routine for a knowledge brain: check existing context first, save explicit notes with their source, and link related pages.
Similar skills
technical-documentation
394kHelps your agent write and review clear technical docs and agent instruction files, so people and AI tools can follow them easily.
architecture-decision-records
280kHas your agent record important project structure decisions. It helps to understand the reasoning behind choices and maintain a clear history of changes.
code-tour
280kLets your agent create step-by-step code walkthroughs with exact file and line references. Useful for intros, explanations, and reviews.