zed-industries/zed · error · anyhow::Error

SKILL.md file exceeds maximum size of

Error message

SKILL.md file exceeds maximum size of {}KB

What it means

Before extracting YAML frontmatter, `extract_skill_frontmatter` enforces `MAX_SKILL_FILE_SIZE` (100 * 1024 bytes = 100 KB) on the SKILL.md content. Skills are injected into agent context on demand, so an unbounded SKILL.md would blow up token budgets; oversized files are rejected outright.

Solutions

  1. Trim the body under 100 KB — skills should be a concise pointer to scripts, not a full manual.
  2. Move bulky reference material into sibling files in the skill directory and reference them by path.
  3. Strip embedded assets/base64 blobs out of the markdown.
  4. Check the byte size (not line count): `wc -c SKILL.md` must be <= 102400.

Example fix

# skill directory layout — before: one 300KB SKILL.md
# after: concise SKILL.md + external reference
myskill/
  SKILL.md            # < 100KB: description + workflow + pointers
  reference/api.md    # detailed tables moved here
  scripts/run.sh      # logic moved here
Defensive patterns

Strategy: validation

Validate before calling

const MAX: usize = agent_skills::MAX_SKILL_FILE_SIZE; // 100 * 1024
if content.len() > MAX {
    // trim the body or split reference material into sibling files before extracting frontmatter
}

Try / catch

match agent_skills::parse_skill_file_content(&content) {
    Err(e) if e.to_string().contains("exceeds maximum size") => {
        // reject the skill with a size hint; ask the author to externalize bulk content
    }
    rest => rest,
}

Prevention

When it happens

Trigger: A SKILL.md whose total length (frontmatter + body) exceeds 100 KB — e.g. embedded base64 assets, pasted logs, inlined API references, or whole documents in the body.

Common situations: Authors paste comprehensive documentation into a skill body; CI-generated skills concatenate many files; a script builds SKILL.md from a large corpus without trimming.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/b2129e8f4de2ed6e. Report an issue: GitHub.

Appendix: source

Thrown at crates/agent_skills/agent_skills.rs:294

        .to_path_buf();

    Ok(Skill {
        name: metadata.name,
        description: metadata.description,
        source,
        directory_path,
        skill_file_path: skill_file_path.to_path_buf(),
        load_warnings,
        disable_model_invocation: metadata.disable_model_invocation,
        embedded_body: None,
    })
}

/// Extract the YAML frontmatter and body from a SKILL.md file without
/// validating the metadata fields.
pub fn extract_skill_frontmatter(content: &str) -> Result<(SkillMetadata, &str)> {
    if content.len() > MAX_SKILL_FILE_SIZE {
        anyhow::bail!(
            "SKILL.md file exceeds maximum size of {}KB",
            MAX_SKILL_FILE_SIZE / 1024
        );
    }

    extract_frontmatter(content)
}

/// Parse and validate the YAML frontmatter and body from a SKILL.md file.
pub fn parse_skill_file_content(content: &str) -> Result<(SkillMetadata, &str)> {
    let (metadata, body) = extract_skill_frontmatter(content)?;

    validate_name(&metadata.name).map_err(anyhow::Error::msg)?;
    validate_description(&metadata.description).map_err(anyhow::Error::msg)?;

    Ok((metadata, body))
}

View on GitHub (pinned to 9d272b0363)