{"record":{"id":"fa868aec76605b3a","repo":"zed-industries/zed","slug":"skill-md-must-start-with-yaml-frontmatter","errorCode":null,"errorMessage":"SKILL.md must start with YAML frontmatter (---)","messagePattern":"SKILL\\.md must start with YAML frontmatter \\(---\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent_skills/agent_skills.rs","lineNumber":348,"sourceCode":"    }\n\n    let mut warnings = Vec::new();\n    let description_len = description.chars().count();\n    if description_len > MAX_SKILL_DESCRIPTION_LEN {\n        warnings.push(SkillLoadWarning::DescriptionTooLong {\n            actual_len: description_len,\n            max_len: MAX_SKILL_DESCRIPTION_LEN,\n        });\n    }\n\n    Ok(warnings)\n}\n\nfn extract_frontmatter(content: &str) -> Result<(SkillMetadata, &str)> {\n    let content = content.trim_start();\n\n    if !content.starts_with(\"---\") {\n        anyhow::bail!(\"SKILL.md must start with YAML frontmatter (---)\");\n    }\n\n    // Find every candidate closing `---` line: a line consisting EXACTLY of\n    // `---` (followed by `\\n`, `\\r\\n`, or EOF) at column 0, excluding the\n    // opening line itself. The opener occupies bytes 0..(first line ending),\n    // and our scan starts after each `\\n`, so the opener is naturally skipped.\n    //\n    // For each candidate we record the byte position right after its line\n    // ending; that's both where the YAML stream slice ends and where the body\n    // begins.\n    let bytes = content.as_bytes();\n    let mut candidates: Vec<usize> = Vec::new();\n    for (i, &b) in bytes.iter().enumerate() {\n        if b != b'\\n' {\n            continue;\n        }\n        let line_start = i + 1;\n        if line_start + 3 > bytes.len() {","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/agent_skills/agent_skills.rs#L330-L366","documentation":"`extract_frontmatter` trims leading whitespace then requires the content to begin with `---`. SKILL.md files must open with a YAML frontmatter block (delimiters plus metadata like `name` and `description`); a file starting directly with prose, a heading, or a BOM-adjacent garbage line fails here.","triggerScenarios":"A SKILL.md whose first non-whitespace characters are not `---`: starts with `# Title`, plain description text, or the metadata written as bare `key: value` lines with no delimiters.","commonSituations":"Authors write the skill body first and forget the header; converting an existing README into a skill; YAML written with `...` or a different fence style.","solutions":["Start the file with a `---` line, then metadata, then a closing `---` line, then the body.","Include at least `name` and `description` keys in the frontmatter.","Ensure no stray characters precede the first `---` (leading blank lines are tolerated because of `trim_start`, but text is not).","Validate locally: `head -1 SKILL.md` should print exactly `---`."],"exampleFix":"# SKILL.md — before\n# My Skill\nDoes things.\n\n# SKILL.md — after\n---\nname: my-skill\ndescription: Condensed one-line trigger description.\n---\n# My Skill\nDoes things.","handlingStrategy":"validation","validationCode":"if !content.trim_start().starts_with(\"---\") {\n    // prepend a frontmatter block with name/description before loading the skill\n}","typeGuard":"fn has_frontmatter_opener(content: &str) -> bool {\n    content.trim_start().starts_with(\"---\")\n}","tryCatchPattern":"match agent_skills::parse_skill_file_content(&content) {\n    Err(e) if e.to_string().contains(\"must start with YAML frontmatter\") => {\n        // rewrite the file with a proper header, then retry the load\n    }\n    rest => rest,\n}","preventionTips":["Start every SKILL.md with `---` on line one.","Scaffold skills from a template that already includes the delimiters.","Add a lint check: first non-empty line must be exactly `---`."],"tags":["rust","zed","agent-skills","yaml","frontmatter","skills","parse-error"],"backgroundTag":"yaml-frontmatter-invalid","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}