MCPcopy Index your code
hub / github.com/shareAI-lab/learn-claude-code / _parse_frontmatter

Function _parse_frontmatter

s07_skill_loading/code.py:53–64  ·  view source on GitHub ↗

Parse YAML frontmatter from SKILL.md. Returns (meta, body).

(text: str)

Source from the content-addressed store, hash-verified

51
52# s07: Skill catalog scan (used by build_system below)
53def _parse_frontmatter(text: str) -> tuple[dict, str]:
54 """Parse YAML frontmatter from SKILL.md. Returns (meta, body)."""
55 if not text.startswith("---"):
56 return {}, text
57 parts = text.split("---", 2)
58 if len(parts) < 3:
59 return {}, text
60 try:
61 meta = yaml.safe_load(parts[1]) or {}
62 except yaml.YAMLError:
63 meta = {}
64 return meta, parts[2].strip()
65
66# Build skill registry at startup (used for safe lookup in load_skill)
67SKILL_REGISTRY: dict[str, dict] = {}

Callers 1

_scan_skillsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected