opencode icon indicating copy to clipboard operation
opencode copied to clipboard

skills: a Claude-compatible SKILL.md that fails to parse is dropped without any log

Open liwenjie200543 opened this issue 3 days ago • 3 comments

Summary

The compatibility loader reads SKILL.md files from Claude and agent skill roots (packages/core/src/config/plugin/compatibility.ts). When SkillFile.parse returns Skipped, the file is simply not added to the loaded map:

const parsed = SkillFile.parse(resolved, filepath, content)
if (parsed._tag === "Parsed") loaded.set(parsed.skill.id, parsed.skill)

There is no log call on the other branch, so a skill that exists but cannot be parsed disappears without a trace at every log level, including DEBUG. The model then works without instructions the user believes are loaded.

This is the same symptom as #66716, which covers the native skill loader (skill.ts, which logs the skip at logDebug). This loader is the only one of the three that reports nothing at all.

Environment

  • opencode version: 2.4.2, and dev at 2204311e
  • Client: TUI / shared service
  • Model and provider: Not relevant
  • OS: Linux 6.x x86_64
  • Terminal: xterm-kitty, truecolor
  • Shell: /bin/bash
  • Install/channel: latest (release)
  • Active plugins: none related

Reproduction

  1. Create a skill under a compatibility root, for example ~/.claude/skills/repro/SKILL.md, with frontmatter that parses as YAML but does not decode into the expected shape:

    ---
    name: repro
    description: [not, a, string]
    ---
    body
    
  2. Make sure that root is part of compatibility.claude so ConfigCompatibilityPlugin scans it.

  3. Start opencode and open the skills list (/skills).

  4. The skill is absent.

  5. Search the log for the path: there is no line naming the file, at the default level or with OPENCODE_LOG_LEVEL=DEBUG.

Expected Behavior

A warning that names the file and the reason it was skipped, in the same shape the other two loaders already use for a file that exists but cannot be used (agent.ts:153/agent.ts:175, command.ts:142/command.ts:150). Both skip reasons should be reported, since both mean the file was found and then dropped.

Actual Behavior

No log output at any level; the skill is silently missing from the catalog.

Additional Context

SkillFile.parse returns { _tag: "Skipped", reason: "markdown" } when the frontmatter block cannot be read at all, and { _tag: "Skipped", reason: "frontmatter", issue } when it decodes into the wrong shape. Both are currently discarded by the if above.

liwenjie200543 avatar Nov 28 '26 11:11 liwenjie200543

Thanks for the precise report. I reproduced this with the released 2.4.2 CLI, and it still happens on the latest dev (2204311e).

What I did:

  1. In an isolated home directory, I created three skills under ~/.claude/skills:
    • good, a valid control skill.
    • badshape, with description: [not, a, string] (your case).
    • badyaml, with an unterminated quoted description.
  2. I ran opencode serve --print-logs, once at the default level and once with --log-level debug, and listed skills through GET /api/skill.
  3. On both versions, good is listed, so the Claude folder is being read. badshape and badyaml are missing, and no log line mentions either file at either level, even though the debug run did write DEBUG lines.

This matches the code in packages/core/src/config/plugin/compatibility.ts: a parsed skill is kept, and a skipped one is dropped with no log. The script below reproduces it, against the installed opencode or a source checkout via OC_DEV.

Related:

  • #66716: the same symptom in the native skill loader (skill.ts)
  • #66732: open PR for #66716; its description says it changes only skill.ts, so it does not cover this loader
Reproduction script (repro.sh)
#!/usr/bin/env bash
# Repro for #66970: a Claude-compatible SKILL.md (~/.claude/skills) that fails to parse is dropped with no log at any level.
# Usage: ./repro.sh                     -> uses `opencode` from PATH
#        OC_DEV=/path/to/repo ./repro.sh -> runs the CLI from a source checkout
set -u
mkdir -p /tmp/opencode
P=$(mktemp -d /tmp/opencode/compatskill.XXXX)
export HOME="$P/home" XDG_CONFIG_HOME="$P/home/.config" XDG_DATA_HOME="$P/home/.local/share" XDG_STATE_HOME="$P/home/.local/state" XDG_CACHE_HOME="$P/home/.cache"
export OPENCODE_PASSWORD=repro
S="$HOME/.claude/skills"
mkdir -p "$S/good" "$S/badshape" "$S/badyaml" "$P/proj"
printf -- '---\nname: good\ndescription: control skill\n---\nbody\n' > "$S/good/SKILL.md"
printf -- '---\nname: badshape\ndescription: [not, a, string]\n---\nbody\n' > "$S/badshape/SKILL.md"
printf -- '---\nname: badyaml\ndescription: "unterminated\n---\nbody\n' > "$S/badyaml/SKILL.md"
cd "$P/proj" && git init -q
if [ -n "${OC_DEV:-}" ]; then
  oc() { bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js" "$OC_DEV/packages/cli/src/index.ts" "$@"; }
else
  oc() { opencode "$@"; }
fi
oc --version
run() { # $1 = label, rest = extra flags
  local label=$1; shift; local port=$((4700 + RANDOM % 200))
  oc serve --port $port --print-logs "$@" > "$P/$label.log" 2>&1 & local pid=$!
  for i in $(seq 1 60); do curl -s -u opencode:repro "http://127.0.0.1:$port/api/skill" | grep -q '"id":"good"' && break; sleep 1; done
  echo "=== [$label] /api/skill ids:"
  curl -s -u opencode:repro "http://127.0.0.1:$port/api/skill" | grep -oE '"id":"[^"]*"' | sort -u
  sleep 2; kill $pid; wait $pid 2>/dev/null
  echo "--- [$label] log lines mentioning badshape/badyaml or 'skill file skipped':"
  grep -nE 'badshape|badyaml|skill file skipped' "$P/$label.log" || echo "(none)"
}
run default
run debug --log-level debug
echo "--- persisted log files mentioning them:"; grep -rlE 'badshape|badyaml' "$XDG_DATA_HOME" "$XDG_STATE_HOME" 2>/dev/null || echo "(none)"
echo "work dir: $P"

Run it: bash repro.sh

opencodejr[bot] avatar Nov 28 '26 11:11 opencodejr[bot]

confirmed, reproduced on dev at 2204311e. i put a good skill plus two bad ones under a claude skills root (one with unparseable yaml, one whose frontmatter parses but decodes into the wrong shape, same as your repro) and started the compatibility plugin: only the good skill loads, and there is no warning for either bad file at the default level or at debug. the code in compatibility.ts just drops the Skipped result without logging anything, while skill.ts at least logs it at debug and agent.ts/command.ts warn. working on a fix that logs the skip as a warning with the file and reason, same shape as agent.ts/command.ts.

fanyzp avatar Nov 28 '26 11:11 fanyzp

Fix ready on compat-skill-skip-warn in my fork: https://github.com/anomalyco/opencode/compare/dev...liwenjie200543:opencode:compat-skill-skip-warn — gh pr create is currently returning does not have the correct permissions to execute CreatePullRequest for this account, so I am leaving the link here instead of a PR; opening it from that URL is a single click.

The change is the same shape as #66732, one loader over: in compatibility.ts, a Skipped parse now logs a warning with filepath, reason, and the formatted issue for frontmatter, then skips the file, where it previously fell through silently. Warning rather than debug, because a skill that fails to load is a configuration error, and the rescan is idempotent so it does not repeat.

Verified on dev@8870cabc06: a new case in test/config/skill.test.ts puts a valid skill and one with description: [not, a, string] under a .claude/skills root; it asserts only the valid one is listed, exactly one skill file skipped warning is emitted, and it names the bad file with reason frontmatter. The case fails on the base and passes with the change; bun test test/config/skill.test.ts 14 pass, typecheck clean over 2,046 files, oxlint clean.

liwenjie200543 avatar Nov 28 '26 11:11 liwenjie200543

Correction to the link above: the CreatePullRequest error was the repository's open-pull-request limit, not a permissions bug — this account already has three open PRs here, which is the cap, so a fourth cannot be created (drafts are exempt, but this is not worth a draft).

So the fix now lives as a second commit on #66732 (head b121acf9) instead, which keeps both loaders — skill.ts and compatibility.ts — in one change. test/config/skill.test.ts covers the Claude-compatible root as well: a valid skill plus one with description: [not, a, string], asserting only the valid one loads and exactly one warning names the bad file.

liwenjie200543 avatar Nov 28 '26 12:11 liwenjie200543