Skip to main content

render_skill_md

Function render_skill_md 

Source
pub(crate) fn render_skill_md(
    slug: &str,
    description: &str,
    body: &str,
) -> String
Expand description

Render an Agent Skills-format SKILL.md: YAML frontmatter with the two required fields (name, description — per the spec’s six-field frontmatter; AgentMux doesn’t populate the four optional ones today: license, compatibility, metadata, allowed-tools), followed by the skill’s content as the Markdown body. See https://agentskills.io/specification.

slug (not the skill’s raw display name) is REQUIRED here — the spec requires name be lowercase/hyphenated and match its parent directory; callers must pass the same value used to build the .claude/skills/<slug>/ path (reagent P1, PR #2322). description is validated: the spec requires a non-empty value (falls back to a placeholder) capped at 1024 UTF-16 code units — matching the TS mirror’s .slice(0, 1024) (JS string indexing is UTF-16-code-unit based), since the UI permits arbitrary-length free text with no spec-awareness and non-ASCII descriptions previously truncated to different byte vs. UTF-16 lengths between the two paths (reagent P2, PR #2322).

YAML double-quoted scalars use JSON-compatible escaping (YAML 1.2 §7.3.1), so serde_json::to_string on a plain string produces a valid, correctly-escaped YAML value — this avoids hand-rolling YAML escaping or adding a yaml crate dependency (this workspace has neither today) just for two scalar fields.