[Bug] UTF-8 BOM prevents SKILL.md frontmatter from loading #1397
Replies: 3 comments
|
Confirmed your diagnosis against
The JSON config loaders have the same gap, and there it is worse because So a BOM'd Worth noting the repo already has the helper: If maintainers want this fixed as one change rather than only in the skill loader, the natural shape is stripping the BOM at each read boundary — |
|
Confirmed on Windows 11 with Prime Agent 0.7.2 and Node.js 24.x. The issue is particularly relevant on Windows because many Windows editors (Notepad, Visual Studio) historically saved UTF-8 files with a BOM by default. Users editing SKILL.md files in Notepad will silently produce BOM-prefixed files that Prime Agent silently ignores. Root cause confirmed in const normalized = normalizeNewlines(content);
if (!normalized.startsWith("---")) {
return { yamlString: null, body: normalized };
}
This affects not just SKILL.md but any file parsed through I can reproduce this on Windows with: import { parseFrontmatter } from "./src/utils/frontmatter.ts";
const withBom = "\uFEFF---\nname: test\ndescription: Test\n---\nBody";
console.log(parseFrontmatter(withBom).frontmatter); // {} — emptyA one-line fix in const normalized = normalizeNewlines(content).replace(/^\uFEFF/, "");Happy to test a patch on Windows if maintainers want this addressed. |
|
Upstream has fixed this, so there is a patch to port rather than a fix to design.
export function splitBom(content: string): { bom: string; text: string } {
return content.startsWith("\uFEFF") ? { bom: "\uFEFF", text: content.slice(1) } : { bom: "", text: content };
}
export function stripBom(content: string): string {
return splitBom(content).text;
}It then applies it at 16 read boundaries. The two that match this report are one line each:
They also covered themes, keybindings, manifests, model config, models store, package manager, trust manager, migrations, external editor, and CLI file input, and kept the BOM on edit operations so writes do not silently drop it. Total is +102/-32 across 20 files including a regression test. On prime-agent Worth noting the fork already ships |
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Coding agent and CLI
What happened?
On current
main, aSKILL.mdencoded as UTF-8 with an initial byte-order mark is skipped by the skill loader. The same content without the BOM loads normally.The shared frontmatter parser normalizes newlines but leaves the initial U+FEFF in place. Because it then checks whether the content starts with
---, the BOM-prefixed file is treated as having no frontmatter. The skill loader consequently reportsdescription is requiredand excludes the skill.Steps to reproduce
Using the current parser:
I also loaded two
demo/SKILL.mdfiles whose bytes differed only by the initial UTF-8 BOM:Expected behavior
An initial UTF-8 BOM should not change the parsed frontmatter or prevent the skill from loading.
Prime Agent version
mainat9f9501146e869466acaca66dac49cff857b7b4f9Environment
macOS 26.3.2 arm64, Node.js 24.14.1
Additional context
Prompt templates use the same parser. In a separate check, a BOM-prefixed template also lost its frontmatter metadata and retained the frontmatter block as template content.
I can add a focused regression and narrow fix if maintainers confirm that BOM-prefixed Markdown resources should be supported.
All reactions