Skip to content

Bug: Numeric skill name in YAML frontmatter causes all slash commands to fail with cmd.name.toLowerCase is not a function #3354

@uf-hy

Description

@uf-hy

Description

When a skill's SKILL.md frontmatter has a numeric-only name field (e.g., name: 12306), the YAML parser (js-yaml) interprets it as a number instead of a string. This causes ALL slash commands (not just the affected skill) to fail with:

cmd.name.toLowerCase is not a function. (In 'cmd.name.toLowerCase()', 'cmd.name.toLowerCase' is undefined)

Root Cause

  1. loadSkillFromPath() (line ~88906) uses data.name directly from YAML frontmatter without type conversion:

    const baseName = data.name || options.defaultName;
  2. When the YAML field is name: 12306, js-yaml parses it as integer 12306 (number type), not string "12306".

  3. This number flows through skillToCommandInfo()discoverAllCommands() → into the command list.

  4. When ANY slash command is invoked, findCommand2() (line ~94715) iterates all commands and crashes:

    allCommands.find((cmd) => cmd.name.toLowerCase() === commandName.toLowerCase())

    Numbers don't have .toLowerCase(), so it throws.

Impact

  • All slash commands break, not just the offending skill's command
  • The error message is confusing — doesn't indicate which skill caused the problem
  • No graceful degradation; the entire command lookup fails

Reproduction

  1. Create a skill with a numeric-only name in frontmatter:
    ---
    name: 12306
    description: Some skill
    ---
  2. Place it in ~/.claude/skills/12306/SKILL.md
  3. Restart OpenCode
  4. Try any slash command (e.g., /handoff)
  5. Observe: "Failed to send command" / "Request failed"

Suggested Fix

Add type coercion in loadSkillFromPath():

// Line ~88906
const baseName = String(data.name || options.defaultName);

Or add a defensive check in findCommand2():

allCommands.find((cmd) => typeof cmd.name === "string" && cmd.name.toLowerCase() === commandName.toLowerCase())

Ideally both, for defense in depth.

Environment

  • oh-my-opencode: 3.16.0
  • OpenCode: 1.4.1
  • Platform: Linux x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions