[Bug]: CRLF SKILL.md gets a name-only stub frontmatter prepended on every sync
What happened?
On Windows, skills whose SKILL.md uses CRLF line endings get a second, LF-only frontmatter block prepended whenever Plexus writes the store (plexus sync, or toggling a skill in the dashboard):
---\n
name: my-skill\n
description: my-skill\n <- description replaced by the skill name
---\n
---\r\n <- original frontmatter, still there
name: my-skill\r\n
description: Use when ...\r\n
---\r\n
Claude Code and Codex read the first block, so the skill's description becomes its name and the skill no longer triggers from its real description. On my machine 14 of 32 personal skills were affected: exactly the ones saved with CRLF. LF files, and files with LF frontmatter plus a CRLF body, are fine. The stub doesn't stack, but it survives every later sync, and removing it by hand only lasts until the next sync.
Cause
FRONTMATTER_RE in packages/core/src/store/skills.ts (line 13 on master) only accepts \n:
const FRONTMATTER_RE = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;
For a file that starts with ---\r\n:
parseSkillMarkdownreturns{ frontmatter: {}, body: <whole file> }, soreadSkills/readNativeSkillsFromAgentget nodescription.serializeSkillMarkdowntries to unwrap a nested frontmatter from the body, but with the same regex, so that fails too.descriptionfalls back toname, and a new LF frontmatter is written above the original.- On the next sync the outer LF block parses but the nested CRLF block still doesn't, so the existing nested-frontmatter repair never applies.
Both store write paths hit this: applySmartMergeToStore (rewrites every store skill on sync) and toggleSkillAgent (one skill). import/from-agents.ts and market/install.ts use the same parser.
Steps to reproduce
- Create a skill with CRLF line endings:
mkdir -p ~/.claude/skills/crlf-demo printf -- '---\r\nname: crlf-demo\r\ndescription: Use when testing CRLF frontmatter handling.\r\n---\r\n\r\n# CRLF demo\r\n' > ~/.claude/skills/crlf-demo/SKILL.md - Run
plexus sync. - Inspect the store copy:
od -c ~/.config/plexus/personal/skills/crlf-demo/SKILL.md | head -4
I ran this against a throwaway home (HOME/USERPROFILE pointed at an empty folder, PLEXUS_DETECT_CONFIG_ONLY=1). Output with 0.0.14 after three syncs (still a single stub):
0000000 - - - \n n a m e : c r l f - d
0000020 e m o \n d e s c r i p t i o n :
0000040 c r l f - d e m o \n - - - \n -
0000060 - - \r \n n a m e : c r l f - d
Expected behavior
CRLF frontmatter is parsed like LF frontmatter. The store keeps one frontmatter block with the original description, and a file that already has the stub is repaired by the existing nested-frontmatter unwrap.
Suggested fix
Accept an optional \r in the regex:
-const FRONTMATTER_RE = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;
+const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
I applied this locally to 0.0.14. With it, the repro above produces a single frontmatter with the real description. All 14 affected skills keep the same parsed YAML values and the same body (apart from the leading blank lines that serializeSkillMarkdown already trims), and the already-stubbed ones repair themselves. parseLooseFrontmatter splits on \n but trims each value, so a stray \r doesn't leak into values.
Two notes:
- The dashboard compiles core in through
transpilePackages. In 0.0.14 the regex also lives invendor/plexus-agent-config-web/.next/server/chunks/938.js, so the web build needs the fix as well. One of the stubs on my machine came from a dashboard toggle. serializeSkillMarkdownalways writes the frontmatter with\n, so after the fix a CRLF skill ends up with LF frontmatter and a CRLF body. Claude Code and Codex load such files correctly in my setup. Matching the body's line ending would be a nice extra, not required.
Regression test
Same style as packages/core/test/skills.test.ts, which already covers the LF nested-frontmatter case:
const CRLF_SKILL = ["---", "name: crlf-demo", "description: Use when testing CRLF frontmatter.", "---", "# CRLF demo", ""].join("\r\n");
const NAME_ONLY_STUB = "---\nname: crlf-demo\ndescription: crlf-demo\n---\n";
it.each([
["parses CRLF frontmatter instead of prepending a name-only stub", CRLF_SKILL],
["repairs a CRLF skill that already has the name-only stub", NAME_ONLY_STUB + CRLF_SKILL],
])("%s", async (_title, content) => {
const skillDir = path.join(PLEXUS_PATHS.personal, "skills", "crlf-demo");
await fs.mkdir(skillDir, { recursive: true });
await fs.writeFile(path.join(skillDir, "SKILL.md"), content, "utf8");
const [skill] = await readSkills("personal");
expect(skill.description).toBe("Use when testing CRLF frontmatter.");
await writeSkill(skill);
const raw = await fs.readFile(path.join(skillDir, "SKILL.md"), "utf8");
expect(frontmatter(raw).description).toBe("Use when testing CRLF frontmatter.");
expect(raw.match(/^---\r?$/gm)).toHaveLength(2);
});
I checked these assertions with a plain Node script against 0.0.14's readSkills/writeSkill: both cases fail without the regex change and pass with it. I haven't run them under vitest in the repo.
Environment
- OS: Windows 10 Pro 22H2 (build 19045)
- Node version: v20.20.0
- Plexus version: 0.0.14 (
npm i -g plexus-agent-config). The regex is unchanged in 0.0.18 and onmaster(2026-09-02). - Agent involved: Claude Code and Codex,
syncStrategy: symlink
Logs or screenshots
The od output above. On my real setup, both a full sync (backup reason partial sync: claude-code,codex) and a dashboard toggle (toggleSkillAgent <id> claude-code true) wrote the stub.
Thanks for the clear repro and suggested regex. Opened https://github.com/miniLV/Plexus/pull/12 with that change plus the two regression cases you sketched. npm run test:core is green (73 passed).
Merged in https://github.com/miniLV/Plexus/pull/12 and tagged v0.0.19 (npm + GitHub release workflows should pick it up from the tag). After publish: npm i -g [email protected], then plexus sync should keep real descriptions on CRLF skills.