Skip to content

fix: preserve YAML frontmatter in skill fill#42

Open
LorranHippolyte wants to merge 1 commit intovinilana:mainfrom
LorranHippolyte:fix/issue-28-skill-fill-destroys-frontmatter
Open

fix: preserve YAML frontmatter in skill fill#42
LorranHippolyte wants to merge 1 commit intovinilana:mainfrom
LorranHippolyte:fix/issue-28-skill-fill-destroys-frontmatter

Conversation

@LorranHippolyte
Copy link
Copy Markdown
Contributor

Problem

Running skill fill overwrites SKILL.md files with the raw LLM output, completely discarding the original YAML frontmatter (type, skillSlug, phases, etc.).
After filling, the MCP skill list returns 0 skills because skill discovery relies on the frontmatter to identify files.

Fixes #28

Root cause

skillFillService.ts was writing result.text directly to disk with no frontmatter handling:

// before
await fs.writeFile(skillPath, this.ensureTrailingNewline(result.text));

Fix

src/services/fill/skillFillService.ts

  1. Extract the original frontmatter from the existing SKILL.md before calling the LLM
  2. Strip any frontmatter from the LLM output (removeFrontMatter)
  3. Reconstruct the file with the original metadata and status: filled
// after
const cleanBody = removeFrontMatter(result.text);
const updatedFrontMatter = originalFrontMatter
  ? { ...originalFrontMatter, status: 'filled' }
  : { status: 'filled' };
await fs.writeFile(skillPath, this.ensureTrailingNewline(addFrontMatter(cleanBody, updatedFrontMatter)));

All utilities (parseFrontMatter, removeFrontMatter, addFrontMatter) were already present in src/utils/frontMatter.ts — no new dependencies added.

Testing

21 unit tests passing. Pre-existing build failures related to tree-sitter type declarations are unrelated to this change.

  skillFillService was writing the raw LLM output directly to SKILL.md,
  discarding the original YAML frontmatter (type, skillSlug, phases, etc.).
  This caused MCP skill list to return 0 skills since discovery relies
  on the frontmatter to identify skill files.

  Fix: extract frontmatter before calling the LLM, strip any frontmatter
  from the generated output, then reconstruct the file with the original
  metadata and status updated to 'filled'.

  Fixes vinilana#28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skill fill destroys YAML frontmatter, replacing with markdown (v0.7.0)

1 participant