AgentSkillsCN

yaml-frontmatter-content-separation

在处理Story或ADR文件以供AI提示时,指导如何将YAML前言与内容分离。在进行AI处理的文件内容提取时使用此功能。

SKILL.md
--- frontmatter
name: yaml-frontmatter-content-separation
description: Guide for separating YAML frontmatter from content when processing Story or ADR files for AI prompts. Use this when working with file content extraction for AI processing.

YAML Frontmatter Content Separation

When processing Story or ADR files for AI prompts, ALWAYS separate metadata from content.

DO:

  • Extract content by detecting and removing YAML frontmatter delimited by --- markers
  • Normalize line endings (\r\n to \n) before processing
  • Trim leading whitespace after frontmatter; preserve trailing whitespace
  • Return entire file as content if no valid frontmatter exists
  • Handle malformed YAML (missing closing ---) by treating entire file as content

DON'T:

  • Include YAML frontmatter (state, score) when sending content to AI prompts
  • Treat --- inside markdown code blocks as frontmatter delimiters
  • Modify metadata values during content extraction

Rationale: Models may misinterpret metadata values, produce inappropriate responses, or conflate scoring with content generation if frontmatter is included.