Let `Skills` layer project and personal libraries, name each skill's directory, and render a skill for a host command

Merged
DO
2mo ago
+736-120
  • No tracking issue: scoped by @DouweM as the harness half of first-class Agent Skills in CLAI (stacked PR to follow).

Why we make these changes

Coding agents read skills from conventional folders (.agents/skills, .claude/skills, project then home) that may not exist, and many repos symlink or copy one into the other. Skills raised on both: a missing folder, and the same skill reached twice (Skills(['.agents/skills', '.claude/skills']) fails in this repo). It also gave the model no path to a skill's scripts/ and references/, and offered no public way for a host to read and render a skill for a user command.

New public surface

  • Skills(missing_directories='error' | 'skip', duplicate_names='error' | 'keep_first'), defaults unchanged
  • Skills.load(workspace) -> SkillCatalog(skills, skipped), reading as a run would, without emitting warnings
  • SkillDefinition (now exported) with directory, in_run_workspace (whether it was read from the run's workspace, so the model's tools can reach its directory) and render(arguments=None) ($ARGUMENTS substituted, else ARGUMENTS: ... appended)
  • MissingDirectories / DuplicateNames type aliases

User-visible behavior

skills = Skills(
    ['.agents/skills', '.claude/skills', '/home/me/.agents/skills', '/home/me/.claude/skills'],
    missing_directories='skip',  # absent folders are left out
    duplicate_names='keep_first',  # earlier folder wins, the other warns
)

load_capability for a skill now returns a Skill directory: <path> line under the heading (only for libraries in the run's workspace). A skill reached twice through a symlink, or a byte-identical SKILL.md, counts once. With no skills, nothing is added: no catalog, no load_capability.

Verification

What changes for existing users

Loaded skill instructions gain the directory line, and these no longer raise "Duplicate skill name": two paths to the same SKILL.md (a symlink or an identical copy), or an invalid SKILL.md that shares a name with a valid later one (it is skipped with a warning instead). Everything else needs the new opt-in options.

Decisions to review

  • New behavior is opt-in per the version policy: missing_directories and duplicate_names default to 'error'. ~ is still not expanded, because the workspace may be a sandbox. Callers such as CLAI expand it.
  • Names are deduped after parsing, so an invalid earlier SKILL.md can't hide a valid later one.
  • This reverses the old "no model-visible path" note in the docs. The directory is left out for workspace= libraries, because the model's tools can't reach them.
  • Telemetry: none added; skipped skills stay UserWarnings at run start.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
  • PR title is fit for the release changelog.

Opened by Claude (Douwe's coding agent).