Hmbown/CodeWhale · error

SKILL.md is missing the closing '---' frontmatter fence

Error message

SKILL.md is missing the closing '---' frontmatter fence

What it means

parse_frontmatter_name verified the leading '---' fence but the frontmatter was never closed by a second '---'; SKILL.md is rejected early as malformed rather than parsed with ambiguous frontmatter boundaries.

Solutions

  1. Add a closing '---' line after the frontmatter block
  2. Ensure both fences are exactly three ASCII hyphens on their own lines
  3. Validate the SKILL.md frontmatter before packaging

Example fix

// before
---
name: my-skill
description: does things
// after
---
name: my-skill
description: does things
---
Defensive patterns

Strategy: validation

Validate before calling

fn has_closed_frontmatter(md: &str) -> bool {
    let t = md.trim_start();
    t.starts_with("---") && t[3..].contains("---")
}

Try / catch

match parse_skill_md(content) {
    Ok(fm) => /* use frontmatter */,
    Err(e) if e.to_string().contains("closing '---'") => eprintln!("SKILL.md frontmatter missing closing fence"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Importing/installing a skill whose SKILL.md has an opening '---' but the closing '---' line is missing, misspelled, or nested inside content in a way that leaves none findable.

Common situations: Hand-edited SKILL.md where the closing fence was deleted; fence written as different characters (e.g. '–––' or '```'); file truncated by a bad copy/paste.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/a251bb525d6b08df. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/skills/install.rs:1601

        std::borrow::Cow::Owned(rest.to_string())
    } else if path == prefix {
        std::borrow::Cow::Borrowed("")
    } else {
        std::borrow::Cow::Borrowed(path)
    }
}

/// Extract `name:` and ensure `description:` exist in the SKILL.md frontmatter.
/// Also verifies the leading `---` fence so we reject malformed files early.
fn parse_frontmatter_name(bytes: &[u8]) -> Result<String> {
    let content = std::str::from_utf8(bytes).context("SKILL.md is not valid UTF-8")?;
    let trimmed = content.trim_start();
    if !trimmed.starts_with("---") {
        bail!("SKILL.md is missing the leading '---' frontmatter fence");
    }
    let after_open = &trimmed[3..];
    let close = after_open.find("---").ok_or_else(|| {
        anyhow::anyhow!("SKILL.md is missing the closing '---' frontmatter fence")
    })?;
    let frontmatter = &after_open[..close];

    let mut name: Option<String> = None;
    let mut has_description = false;
    for raw in frontmatter.lines() {
        let line = raw.trim();
        if line.is_empty() || line.starts_with('#') {
            continue;
        }
        if let Some((key, value)) = line.split_once(':') {
            let key = key.trim().to_ascii_lowercase();
            let value = value.trim().to_string();
            match key.as_str() {
                "name" if !value.is_empty() => name = Some(value),
                "description" if !value.is_empty() => has_description = true,
                _ => {}
            }

View on GitHub (pinned to 73e0f67d83)