Skip to content

Add skill registry and on-demand script/reference loading#4

Merged
chinmaymk merged 2 commits intomainfrom
claude/improve-skills-system-9Mkuh
Mar 8, 2026
Merged

Add skill registry and on-demand script/reference loading#4
chinmaymk merged 2 commits intomainfrom
claude/improve-skills-system-9Mkuh

Conversation

@chinmaymk
Copy link
Copy Markdown
Owner

Summary

This PR introduces a skill registry system for installing skills from npm, GitHub, and URLs, along with a shift from eager to on-demand loading of skill scripts and references. Skills now include a manifest of available resources that can be loaded when needed, reducing initial context overhead.

Key Changes

Skill Registry (src/skills/registry.ts)

  • New installSkill() function to download and install skills from npm, GitHub, or direct URLs
  • parseSkillSource() to parse skill source strings (supports npm:, github:, https://, and bare package names)
  • removeSkill() and listInstalledSkills() for managing installed skills
  • defaultSkillInstallDir() returns ~/.ra/skills as the default installation directory
  • Stores source metadata (.source.json) with each installed skill for tracking origin and version

On-Demand Script/Reference Loading

  • buildSkillMessages() now returns only the skill body with a manifest of available scripts and references, rather than executing all scripts eagerly
  • New buildSkillMessagesEager() preserves the legacy behavior of running scripts at activation time
  • New runSkillScriptByName() in runner.ts allows running individual scripts on demand
  • New readSkillReference() in loader.ts allows reading reference files on demand
  • New buildSkillExcerpt() creates short summaries of skills for listing

REPL Commands

  • /skill-run <skill> <script> - Execute a skill script and attach output to next message
  • /skill-ref <skill> <reference> - Load a reference file and attach to next message
  • /skill-info [name] - List all skills or show details for a specific skill

CLI Commands

  • ra skill install <source> - Install from npm, GitHub, or URL
  • ra skill remove <name> - Remove an installed skill
  • ra skill list - List installed skills with source information

Argument Parsing

  • Extended parseArgs() to recognize skill subcommands
  • New SkillCommand interface for skill management operations

Documentation

  • Updated docs/site/skills/index.md with registry installation instructions and on-demand loading patterns
  • Clarified that scripts and references are now loaded on-demand rather than eagerly

Implementation Details

  • Skills are discovered by looking for SKILL.md files in skill directories or skills/*/SKILL.md subdirectories
  • npm packages can have a single skill at the root or multiple skills in subdirectories
  • GitHub installations try both main and master branches
  • Temporary directories are cleaned up after extraction
  • Source metadata is stored as JSON for tracking installed skill origins and versions
  • The on-demand approach keeps initial context lean while maintaining access to all skill resources

https://claude.ai/code/session_016sNdNotWPJNobo9dPS9VUb

claude added 2 commits March 8, 2026 01:40
- Scripts and references are no longer eagerly executed/loaded at skill
  activation. Only the SKILL.md body is included in context, with a
  manifest listing available scripts and references.
- Add on-demand commands: /skill-run, /skill-ref, /skill-info in REPL
- Add skill registry: download skills from npm, GitHub, or URLs via
  `ra skill install <source>`, with `ra skill remove` and `ra skill list`
- Add buildSkillExcerpt() for compact skill summaries
- Add readSkillReference() for on-demand reference loading
- Add runSkillScriptByName() for on-demand script execution
- Preserve buildSkillMessagesEager() as legacy API for eager loading
- Update docs with registry and on-demand usage instructions

https://claude.ai/code/session_016sNdNotWPJNobo9dPS9VUb
- Rewrite registry.ts: extract withTempExtract and installSkillDirs helpers
  to eliminate duplicated download-extract-install logic across npm/github/url
- Replace shell-based copyDir with node:fs cpSync
- Fix defaultSkillInstallDir to use os.homedir() instead of env vars
- Fix scoped npm package URL encoding (don't encode @ in scope)
- Use GitHub API tarball URL (auto-resolves default branch)
- Fix removeSkill to use rmSync directly (no TOCTOU existence check)
- Merge duplicate glob scans in findSkillDirsIn into single pattern
- Add root-as-skill fallback to URL installer (was missing)
- Extract resolveSkillAsset helper shared by runner.ts and loader.ts
- Make registry.ts import lazy in index.ts (only loaded for skill subcommands)

https://claude.ai/code/session_016sNdNotWPJNobo9dPS9VUb
@chinmaymk chinmaymk force-pushed the claude/improve-skills-system-9Mkuh branch from f11eb96 to 49456e2 Compare March 8, 2026 01:47
@chinmaymk chinmaymk merged commit 24c9fc4 into main Mar 8, 2026
1 check passed
@chinmaymk chinmaymk deleted the claude/improve-skills-system-9Mkuh branch March 8, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants