MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / parseMarkdownFrontmatter

Function parseMarkdownFrontmatter

src/modes/store.ts:36–48  ·  view source on GitHub ↗

* Extracts YAML frontmatter and Markdown body from a string. * Expects the format used by Claude Code SKILL.md, OpenCode agents, * and Cursor rules: `---` delimited YAML followed by Markdown content. * * @throws {Error} If the string does not contain valid `---` delimiters. * @returns The parse

(raw: string)

Source from the content-addressed store, hash-verified

34 * @returns The parsed frontmatter object and the body text.
35 */
36function parseMarkdownFrontmatter(raw: string): {
37 frontmatter: Record<string, unknown>
38 body: string
39} {
40 const parts = raw.split(/^---$/m)
41 if (parts.length < 3) {
42 throw new Error('Invalid markdown frontmatter: missing --- delimiters')
43 }
44 return {
45 frontmatter: parseYaml(parts[1]) as Record<string, unknown>,
46 body: parts.slice(2).join('---').trim(),
47 }
48}
49
50function loadCustomModes(): CCBMode[] {
51 if (customModes !== null) return customModes

Callers 1

loadCustomModesFunction · 0.85

Calls 1

parseYamlFunction · 0.85

Tested by

no test coverage detected