Skillpedia
التوثيق31k · #9302

frontmatter-guard

ما الذي تفعله

تفحص هذه المهارة قسم الرأس المخفي في كل صفحة من قاعدة معارفك بحثًا عن أخطاء. تستطيع إصلاح الأخطاء الشائعة تلقائيًا بعد موافقتك على معاينة.

متى تستخدمها

  • ✓عندما تفشل صفحة في قاعدة معارفك في المزامنة أو تظهر نتائج بحث مشوهة.
  • ✓عندما تريد فحص كل صفحاتك بحثًا عن أخطاء الرأس قبل استيراد كبير.
  • ✓عندما تفتقد صفحة سطرًا للإغلاق، أو فيها علامات تنصيص متداخلة، أو عنوان لا يطابق اسم ملفها.

رابط المهارة

https://github.com/garrytan/gbrain/blob/master/plugin/skills/frontmatter-guard/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/garrytan/gbrain/blob/master/plugin/skills/frontmatter-guard/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“افحص كل صفحات قاعدة معارفي بحثًا عن بيانات رأس معطوبة، وأرني معاينة لأي إصلاحات قبل أن تطبقها.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يفحص وكيلك كل صفحة مقابل مجموعة فحوص معيارية، ويشرح كل مشكلة. ثم يُنشئ نسخة احتياطية، ويطبق الإصلاح فقط بعد موافقتك على المعاينة.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Frontmatter Guard Skill

Convention: see skills/conventions/quality.md for 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 .bak backups
  • Validation logic is shared with gbrain doctor's frontmatter_integrity subcheck — 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 or gbrain 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-yaml dump), 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.md
    

    Exit 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. --importable answers 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
الأسئلة الشائعة

هل ستغيّر صفحاتي دون أن تسألني؟

لا. تُعرض الإصلاحات كمعاينة أولًا، وتُحفظ نسخة احتياطية.

ما أنواع الأخطاء التي تكتشفها؟

أسطر الإغلاق الناقصة، والعلامات المتداخلة، والأسماء غير المتطابقة، والرؤوس الفارغة، والرموز التالفة.

لماذا تتخطى المزامنة بعض الملفات؟

تشرح المهارة سبب كل إيقاف من سجلها، وتصلحه فقط بإصلاح مُعتمد.

التفاصيل

الوصف الأصلي من المؤلف

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

الشعبية

نجوم GitHub
31k
الترتيب
#9302
الترخيص
MIT
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة