frontmatter-guard
Skill này làm gì
Skill này kiểm tra phần tiêu đề ẩn ở đầu mỗi trang brain xem có lỗi không. Nó có thể tự sửa các lỗi thường gặp sau khi bạn duyệt bản xem trước.
Khi nào nên dùng
- ✓Khi một trang brain không đồng bộ được hoặc hiển thị kết quả tìm kiếm bị lỗi.
- ✓Khi bạn muốn kiểm tra mọi trang xem có lỗi tiêu đề trước một đợt nhập lớn không.
- ✓Khi một trang thiếu dòng đóng, có dấu ngoặc kép lồng nhau, hoặc tiêu đề không khớp với tên file.
Liên kết skill
https://github.com/garrytan/gbrain/blob/master/plugin/skills/frontmatter-guard/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Kiểm tra mọi trang brain của tôi xem có lỗi trong phần tiêu đề không, và cho tôi xem bản xem trước các bản sửa trước khi áp dụng.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent quét từng trang theo một bộ kiểm tra chuẩn. Nó giải thích từng vấn đề, rồi tạo bản sao lưu và chỉ áp dụng bản sửa sau khi bạn duyệt bản xem trước.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Nó có sửa trang của tôi mà không hỏi không?
Không. Các bản sửa được xem trước trước, và luôn có bản sao lưu.
Nó bắt được những loại lỗi nào?
Thiếu dòng đóng, dấu ngoặc kép lồng nhau, tên không khớp, tiêu đề trống và ký tự bị hỏng.
Tại sao đồng bộ bỏ qua một số file?
Skill giải thích từng trường hợp bị giữ lại dựa trên bản ghi, và chỉ sửa khi có bản sửa đã được duyệt.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 31k
- Vị trí xếp hạng
- #9302
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
gbrain
31kCho phép agent của bạn tìm trong kho tri thức dùng chung của công ty các thông tin về con người, dự án và quyết định, và lưu ghi chú bền vững vào đó.
brain-ingest-gate
31kKiểm tra nội dung mới với kho tri thức hiện có trước khi thêm vào, để tránh trùng lặp và xác định các thực thể được nêu tên trước.
brain-link-discipline
31kĐảm bảo agent của bạn kèm một liên kết hoạt động đến mỗi trang kho tri thức mà nó báo cáo, trong cùng một tin nhắn, để bạn mở được ngay.
brain-ops
31kCung cấp cho agent của bạn thói quen cốt lõi cho kho tri thức: kiểm tra ngữ cảnh có sẵn trước, lưu ghi chú rõ ràng kèm nguồn và liên kết các trang liên quan.
Skill tương tự
technical-documentation
394kGiúp agent của bạn viết và rà soát tài liệu kỹ thuật cùng file hướng dẫn cho agent, rõ ràng để mọi người và công cụ AI đều dễ làm theo.
architecture-decision-records
280kGiúp agent của bạn ghi lại các quyết định quan trọng về cấu trúc dự án, giúp hiểu lý do đằng sau các lựa chọn và giữ lịch sử thay đổi rõ ràng.
code-tour
280kGiúp agent của bạn tạo các hướng dẫn đọc code từng bước, có tham chiếu chính xác đến file và dòng, hữu ích cho phần giới thiệu, giải thích và rà soát.