Load Agent Skills in `clai2`'s `coder` plugin, with a `/skill-name` command for each

Merged
DO
2mo ago
+877-70
  • Stacked on #9802 (base branch harness-skills-discovery); retarget to main once it merges. No tracking issue: scoped by @DouweM.

Why we make these changes

CLAI loaded no Agent Skills, so the skills in a project's .agents/skills or .claude/skills and in the user's home never reached the model. There was also no way to invoke one directly, as /skill-name args does in Claude Code. The built-in coder plugin now does both, following the agent_folders pattern.

New public surface

  • CoderSettings.skill_folders (default .agents/skills, .claude/skills, ~/.agents/skills, ~/.claude/skills; [] turns skills off), tagged coder-skill-folders
  • Plugin.prepare(): async, awaited by the loader once per load before the get_* methods. load_plugin raises TypeError for a plugin that overrides it; a test calls from_host, awaits prepare(), then collect.
  • PluginHost.submit_prompt(text): a /command handler starts a turn once it returns (it raises anywhere else). PluginHost(submit_prompt=...) supplies it for a host built without a shell, such as in a test.
  • Command(overridable=True): gives way to another command of the same name, with a printed notice. Command names may now contain hyphens.

User-visible behavior

$ clai2                       # in this repo
> /pre-push-review main       # sends the rendered skill as the next prompt
  • The model's catalog lists this repo's 10 skills once each. .agents/skills holds copies of .claude/skills skills, and they count once.
  • Malformed skills and name clashes print one line each when coder loads.
  • A skill named like a command (/model) leaves the command alone.
  • New skills reach the model on the next turn, and their /command after /reload.
  • With no skills, nothing is added: no catalog, no load_capability.

Verification

  • tests/clai2/test_coder_skills.py: folders, catalog, no-overhead, notices, /skill turn through chat(), reload, command clashes
  • tests/clai2/test_settings_compatibility.py: saved skill_folders in builds with and without the feature
  • End-to-end: headless clai2 -m test -p hi in ~/pydantic-ai, with TestModel patched to print its request. The catalog lists each of the 10 skills once. In an empty directory and home, it shows no catalog and no load_capability. In tmux: startup notices, /help, and /review src/app.py submitting the rendered skill.

What changes for existing users

The stock coder (and saved coder declarations without skill_folders) now loads skills from the four default folders; set "skill_folders": [] to opt out.

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).