Repository navigation
Skills Phase 1: per-directory SKILL.md format + frontmatter parser - #55
Conversation
PasClaw's skill scheme was a single .json file with no body — adequate for "one developer with three pet automations" but not wire-compatible with the broader ecosystem (picoclaw, nanobot, ClawHub, Anthropic agent-skills). All four of those projects use the same SKILL.md layout: a per-skill directory with YAML frontmatter + markdown body, optionally with scripts/, references/, and assets/ subdirectories. This commit adds parser support for the SKILL.md format and the per-directory layout while keeping the existing .json files loadable. New layout, scanned from $PASCLAW_HOME/workspace/skills/: workspace/skills/<name>/SKILL.md <- preferred workspace/skills/<name>.json <- still works for backwards compat SKILL.md is YAML frontmatter (between `---` markers) + markdown: --- name: weather_report description: Fetch weather for a city kind: shell shell: curl -s 'https://wttr.in/{{city}}?format=3' schema: {"type":"object","properties":{"city":{"type":"string"}}} --- # Weather report Procedural knowledge the model loads on demand via fs_read. Implementation: ParseSkillMD(FilePath, out Spec, out ErrMsg): Boolean - Locates frontmatter delimiters (`---` lines) with tolerance for leading blank lines / BOMs. - Parses simple key:value entries; strips surrounding single or double quotes from values to accept YAML-quoted strings. - Schema field accepts inline JSON on one line (the only realistic need — skill schemas are small "object with these properties" blobs); multi-line schemas can come later if a real skill needs them. - Body = everything after the closing `---`, with surrounding whitespace trimmed. - Returns False with ErrMsg set on malformed frontmatter so the logger can warn per-file instead of silently dropping skills. ScanSkillDirs / ScanJsonSkills replace the old single-flat scan. Per-directory entries are loaded first and shadow same-named JSON entries by name. Lets users drop a SKILL.md next to an existing JSON, verify it loads, then delete the JSON when ready. TSkillSpec gains three fields: Body - markdown body (for the SKILL.md path; empty for JSON skills) Dir - skill directory (parent of SKILL.md, or dirname of JSON file) Source - absolute path to SKILL.md or the JSON file. Surfaces in the system prompt so the model knows where to fs_read for the full body. Kind semantics: shell - callable; registers as `skill_<name>` tool, runs the rendered Shell command. Unchanged. prompt - callable; registers as `skill_<name>` tool, returns the rendered Prompt template. Unchanged. (omitted) - knowledge-only; NO tool registered. SKILL.md body is advertised in the system prompt's SKILLS section so the model knows to fs_read it. This is the dominant pattern picoclaw and nanobot ship. System prompt's SKILLS section (PasClaw.Agent.Prompt) updated to distinguish callable from knowledge-only skills: ## Skills Skills extend your capabilities. Callable skills register as `skill_<name>` tools you invoke directly; knowledge-only skills are markdown bodies — read each one's SKILL.md with `fs_read` when the matching task comes up. - `skill_weather_report` — Fetch weather for a city (callable) - **code-review** — Static review prompt. Read `/home/me/.pasclaw/ workspace/skills/code-review/SKILL.md` for the full instructions. `pasclaw skills list` updated to show kind + path (relative to ~/.pasclaw when possible) instead of the old two-column shell/prompt view that did not surface the source file. samples/skills/hello/SKILL.md ships as a copy-pasteable starter documenting every frontmatter field and the body conventions. README's skills paragraph rewritten to document the new layout with a backwards-compat note for the JSON form. Not in this PR (Phase 2 → 4 of the roadmap discussed in the prior turn): - `pasclaw skills install owner/repo[/path]` GitHub fetch + zip extract (Delphi's System.Zip is the cross-target story; FPC has Zipper.TUnZipper). - ClawHub search/install client. - scripts/ + references/ runtime support (scripts as callable helpers; references lazily loaded into context). Roadmap noted in the README so future contributors can pick it up. https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8f9b8f1e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Line := Trim(Lines[i]); | ||
| if Line = '' then Continue; | ||
| if Line = '---' then begin StartIdx := i; Break; end; |
There was a problem hiding this comment.
Strip UTF-8 BOM before checking frontmatter
When a SKILL.md is saved with a UTF-8 BOM, ReadFileText preserves that character at the start of the first line, and Trim does not remove it, so Line becomes BOM+--- and this equality check fails. In that case the loader reports “no YAML frontmatter” and skips an otherwise valid skill, despite this parser explicitly intending to tolerate BOM-prefixed files. Strip the BOM from the first non-empty line before comparing the delimiter.
Useful? React with 👍 / 👎.
ParseSkillMD's comment claimed BOM tolerance but Trim only handles
ASCII whitespace, so a SKILL.md saved by a Windows editor with the
UTF-8 BOM (EF BB BF) prepended would have its first line read as
"<BOM>---", fail the `Line = '---'` equality check, and the parser
reported `no YAML frontmatter` — silently dropping an otherwise
valid skill.
Strip the BOM explicitly on the first line. Cross-toolchain detail
is that ReadFileText returns different shapes on each:
FPC: AnsiString-UTF8 — the BOM lives as three bytes EF BB BF at
positions 1..3 of the string.
Delphi: UnicodeString — TEncoding.UTF8.GetString decodes those
three UTF-8 bytes into a single Char #$FEFF (zero-width
no-break space; the Unicode BOM codepoint). It does NOT
silently strip the BOM, contrary to what one might assume.
Handle both via {$IFDEF FPC}. Test plan: save samples/skills/hello/
SKILL.md with `iconv -f UTF-8 -t UTF-8-BOM > with-bom/SKILL.md`,
`pasclaw skills list` should pick it up under both compilers.
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
First of four follow-up PRs to bring PasClaw's skill system to wire-parity with picoclaw / nanobot / Anthropic agent-skills / ClawHub. This one ships the format itself; subsequent PRs add the registry/install plumbing.
Roadmap (for reference)
pasclaw skills install owner/repo[/path]via GitHub fetch + zip extract (Delphi'sSystem.Zip↔ FPC'sZipper.TUnZipper; not tar)scripts/(callable helpers) +references/(lazy-loaded context) runtime supportWhat this PR ships
New on-disk layout
SKILL.md format (matches picoclaw / nanobot / ClawHub byte-for-byte)
Parser (
ParseSkillMDinPasClaw.Skills.Loader)---delimiters with tolerance for leading blank lines / BOMskey: valueentries, strips YAML quote wrappersschema:accepts inline JSON on one line (single-line is enough for the schemas skills actually need)---, trimmedTSkillSpecextensionsBodyDirSourcefs_readfor the full bodyKind semantics
kind:shellskill_<name>tool, runs the rendered Shell command. Unchanged.promptskill_<name>tool, returns the rendered Prompt template. Unchanged.fs_readit. Dominant pattern in picoclaw / nanobot.Loader resolution order
ScanSkillDirs→ScanJsonSkills. Per-directory entries win on name collisions. Lets users drop a SKILL.md next to an existing JSON, verify it loads, then delete the JSON when ready.System prompt SKILLS section
Adaptive intro: shows the "callable" line only if at least one callable skill is present, the "knowledge-only" line only if at least one knowledge skill is present, both if both.
CLI
pasclaw skills listupdated — shows kind + source path (relative to~/.pasclawwhen possible). Previous two-column shell/prompt view didn't surface where the skill came from; new view does.Sample
samples/skills/hello/SKILL.md— copy-pasteable starter documenting every frontmatter field and the body conventions.Docs
README's Skills paragraph rewritten with the new layout + backwards-compat note + roadmap pointer for Phase 2–4.
Test plan
make) + Delphi.dprojbuild cleanlypasclaw skills listwith no skills installed — prints the "(no skills found)" message + the new mkdir hintcp -r samples/skills/hello ~/.pasclaw/workspace/skills/—pasclaw skills listshows it as knowledge-only with~/workspace/skills/hello/SKILL.mdas sourcepasclaw agent "what does the hello skill do?"— model finds the SKILL.md entry in the system prompt, callsfs_readon the path, summarizes from the bodykind: shellwith a one-liner —pasclaw skills listshows it asshell,pasclaw agent "run hello"invokes the registeredskill_hellotoolworkspace/skills/legacy.json(old format) — still loads, listed alongside the new dir entriesname: legacynext tolegacy.json— JSON gets shadowed (debug log warns); only the SKILL.md entry shows inskills listname:) — logged at WARN, skipped, other skills still loadhttps://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code