{"record":{"id":"43af76432550e519","repo":"Hmbown/CodeWhale","slug":"skill-md-is-missing-the-leading-frontmatter","errorCode":null,"errorMessage":"SKILL.md is missing the leading '---' frontmatter fence","messagePattern":"SKILL\\.md is missing the leading '---' frontmatter fence","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/install.rs","lineNumber":1597,"sourceCode":"        return std::borrow::Cow::Borrowed(path);\n    }\n    let with_slash = format!(\"{prefix}/\");\n    if let Some(rest) = path.strip_prefix(&with_slash) {\n        std::borrow::Cow::Owned(rest.to_string())\n    } else if path == prefix {\n        std::borrow::Cow::Borrowed(\"\")\n    } else {\n        std::borrow::Cow::Borrowed(path)\n    }\n}\n\n/// Extract `name:` and ensure `description:` exist in the SKILL.md frontmatter.\n/// Also verifies the leading `---` fence so we reject malformed files early.\nfn parse_frontmatter_name(bytes: &[u8]) -> Result<String> {\n    let content = std::str::from_utf8(bytes).context(\"SKILL.md is not valid UTF-8\")?;\n    let trimmed = content.trim_start();\n    if !trimmed.starts_with(\"---\") {\n        bail!(\"SKILL.md is missing the leading '---' frontmatter fence\");\n    }\n    let after_open = &trimmed[3..];\n    let close = after_open.find(\"---\").ok_or_else(|| {\n        anyhow::anyhow!(\"SKILL.md is missing the closing '---' frontmatter fence\")\n    })?;\n    let frontmatter = &after_open[..close];\n\n    let mut name: Option<String> = None;\n    let mut has_description = false;\n    for raw in frontmatter.lines() {\n        let line = raw.trim();\n        if line.is_empty() || line.starts_with('#') {\n            continue;\n        }\n        if let Some((key, value)) = line.split_once(':') {\n            let key = key.trim().to_ascii_lowercase();\n            let value = value.trim().to_string();\n            match key.as_str() {","sourceCodeStart":1579,"sourceCodeEnd":1615,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/skills/install.rs#L1579-L1615","documentation":"parse_frontmatter_name requires SKILL.md to begin with a leading '---' YAML frontmatter fence (after leading whitespace). Skills are validated early so malformed packages are rejected before extraction and install.","triggerScenarios":"Installing/importing a skill whose SKILL.md starts with prose, a BOM-influenced prefix, markdown headers, or otherwise lacks the opening '---' frontmatter delimiter.","commonSituations":"Hand-written skill files missing frontmatter; files generated by tools that omit the fence; SKILL.md downloaded from a repo where only the README was authoritative.","solutions":["Add a frontmatter block at the very top of SKILL.md starting with '---'","Include at least 'name:' and 'description:' fields inside the frontmatter","Verify the file is the SKILL.md for the skill, not a README or other doc"],"exampleFix":"// before (SKILL.md)\n# My Skill\nSome text...\n// after (SKILL.md)\n---\nname: my-skill\ndescription: Does something useful.\n---\n# My Skill","handlingStrategy":"validation","validationCode":"let head = std::fs::read_to_string(path.join(\"SKILL.md\"))?;\nif !head.trim_start().starts_with(\"---\") {\n    return Err(anyhow!(\"SKILL.md must start with '---' frontmatter fence\"));\n}","typeGuard":"fn has_frontmatter(md: &str) -> bool { md.trim_start().starts_with(\"---\") }","tryCatchPattern":"match install_skill(pkg) {\n    Err(e) if e.to_string().contains(\"frontmatter fence\") => eprintln!(\"SKILL.md lacks '---' frontmatter; add a name/description block at the top\"),\n    other => other?,\n}","preventionTips":["Always author SKILL.md with a leading '---' frontmatter block","Lint skill packages before distributing them","Ensure your skill template/generator emits the fence first, with no BOM or shebang before it"],"tags":["skills","frontmatter","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}