zed-industries/zed · error · anyhow::Error
SKILL.md must start with YAML frontmatter (---)
Error message
SKILL.md must start with YAML frontmatter (---)
What it means
`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.
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 `---`.
Example fix
# SKILL.md — before # My Skill Does things. # SKILL.md — after --- name: my-skill description: Condensed one-line trigger description. --- # My Skill Does things.
Defensive patterns
Strategy: validation
Validate before calling
if !content.trim_start().starts_with("---") {
// prepend a frontmatter block with name/description before loading the skill
} Type guard
fn has_frontmatter_opener(content: &str) -> bool {
content.trim_start().starts_with("---")
} Try / catch
match agent_skills::parse_skill_file_content(&content) {
Err(e) if e.to_string().contains("must start with YAML frontmatter") => {
// rewrite the file with a proper header, then retry the load
}
rest => rest,
} Prevention
- 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 `---`.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- SKILL.md missing closing frontmatter delimiter (---)
- SKILL.md file exceeds maximum size of
- auto_compact threshold of 0 is not valid
- Cannot list directory because its path matches the user's…
- Cannot list directory because its path matches the user's…
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/fa868aec76605b3a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent_skills/agent_skills.rs:348
}
let mut warnings = Vec::new();
let description_len = description.chars().count();
if description_len > MAX_SKILL_DESCRIPTION_LEN {
warnings.push(SkillLoadWarning::DescriptionTooLong {
actual_len: description_len,
max_len: MAX_SKILL_DESCRIPTION_LEN,
});
}
Ok(warnings)
}
fn extract_frontmatter(content: &str) -> Result<(SkillMetadata, &str)> {
let content = content.trim_start();
if !content.starts_with("---") {
anyhow::bail!("SKILL.md must start with YAML frontmatter (---)");
}
// Find every candidate closing `---` line: a line consisting EXACTLY of
// `---` (followed by `\n`, `\r\n`, or EOF) at column 0, excluding the
// opening line itself. The opener occupies bytes 0..(first line ending),
// and our scan starts after each `\n`, so the opener is naturally skipped.
//
// For each candidate we record the byte position right after its line
// ending; that's both where the YAML stream slice ends and where the body
// begins.
let bytes = content.as_bytes();
let mut candidates: Vec<usize> = Vec::new();
for (i, &b) in bytes.iter().enumerate() {
if b != b'\n' {
continue;
}
let line_start = i + 1;
if line_start + 3 > bytes.len() {View on GitHub (pinned to 9d272b0363)