{"record":{"id":"9447ebe5da9df56e","repo":"JuliusBrussee/caveman","slug":"skill-md-needs-closed-yaml-frontmatter","errorCode":null,"errorMessage":"SKILL.md needs closed YAML frontmatter","messagePattern":"SKILL\\.md needs closed YAML frontmatter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":1593,"sourceCode":"\t\tthrow new Error(`source does not exist: ${input}`);\n\t}\n\tconst stat = lstatSync(resolved);\n\tconst file = stat.isDirectory() ? join(resolved, SKILL_MD) : resolved;\n\tif (!stat.isDirectory() && basename(resolved) !== SKILL_MD) throw new Error(\"source file must be named SKILL.md\");\n\tif (!hasFile(file)) throw new Error(`SKILL.md missing under ${resolved}`);\n\treturn { root: stat.isDirectory() ? resolved : dirname(resolved), file };\n}\n\nfunction cavemannifyImportedSkill(bytes: Buffer): { body: string; removedDuplicates: number; removedSeparators: number } {\n\tif (bytes.length === 0 || bytes.length > 256 * 1024) throw new Error(\"SKILL.md must be 1..262144 bytes\");\n\tif (bytes.includes(0)) throw new Error(\"SKILL.md contains NUL bytes\");\n\tconst text = bytes.toString(\"utf8\");\n\tif (!Buffer.from(text, \"utf8\").equals(bytes)) throw new Error(\"SKILL.md must be valid UTF-8\");\n\tif (/-----BEGIN [A-Z ]*PRIVATE KEY-----|\\b(?:sk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]{16,}/i.test(text)) {\n\t\tthrow new Error(\"SKILL.md contains credential-shaped material\");\n\t}\n\tconst split = splitSkillMarkdown(bytes);\n\tif (!split) throw new Error(\"SKILL.md needs closed YAML frontmatter\");\n\tconst blocks = split.bodyText.trim().split(/\\r?\\n(?:[ \\t]*\\r?\\n)+/);\n\tconst seen = new Set<string>();\n\tconst kept: string[] = [];\n\tlet removedDuplicates = 0;\n\tlet removedSeparators = 0;\n\tfor (const block of blocks) {\n\t\tconst clean = block.trim();\n\t\tif (/^(?:---+|\\*\\*\\*+|___+)$/.test(clean)) {\n\t\t\tremovedSeparators++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst identity = clean.replace(/\\s+/g, \" \");\n\t\tif (seen.has(identity)) {\n\t\t\tremovedDuplicates++;\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(identity);\n\t\tkept.push(clean);","sourceCodeStart":1575,"sourceCodeEnd":1611,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L1575-L1611","documentation":"splitSkillMarkdown must parse SKILL.md into YAML frontmatter plus body; a null result means the frontmatter is absent or not properly closed with a --- delimiter. The importer requires well-formed frontmatter to extract skill metadata.","triggerScenarios":"Importing a SKILL.md that does not start with '---', is missing the closing '---' line, or has malformed frontmatter delimiters (e.g. extra spaces or '--- ' with trailing text).","commonSituations":"Hand-written skills without frontmatter; editors that stripped the leading dashes; frontmatter closed with '---\\r' line-ending issues or wrong fence style.","solutions":["Add a closed YAML frontmatter block at the top: start the file with '---' and close it with a '---' line.","Ensure the frontmatter contains required metadata (e.g. name/description) inside the delimiters.","Check line endings — save with consistent \\n and no stray characters on the delimiter lines."],"exampleFix":"// before (SKILL.md)\n# My Skill\nbody...\n\n// after\n---\nname: my-skill\ndescription: Does things\n---\n# My Skill\nbody...","handlingStrategy":"validation","validationCode":"const text = readFileSync('SKILL.md', 'utf8');\nif (!text.startsWith('---')) throw new Error('missing opening --- frontmatter delimiter');\nconst close = text.indexOf('\\n---', 3);\nif (close === -1) throw new Error('frontmatter is not closed with ---');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start every SKILL.md with a closed --- YAML frontmatter block","Copy a known-good skill template as the starting point","Lint frontmatter with a YAML parser in CI before import"],"tags":["validation","yaml","frontmatter"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}