Add --as-skill flag to kit unpack for agent skill installation#1158
Add --as-skill flag to kit unpack for agent skill installation#1158gorkem wants to merge 10 commits intokitops-ml:mainfrom
Conversation
Prompt layers containing SKILL.md can now be installed directly as agent skills (Claude Code, Cursor, Windsurf, etc.) via --as-skill. Auto-discovers installed agents when no agents are specified. Installs globally by default; use -d for project-scoped installation. Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
Use the listing context directory when reading SKILL.md so parsing works reliably for nested paths and shifted working directories. This prevents false read failures and preserves skill metadata population during kitfile generation. Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
Ensure close and filesystem operations do not silently fail during prompt-to-skill install and related tests. Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds a new “skill installation” mode to kit unpack so prompt layers containing SKILL.md can be installed as agent skills (with auto-detection and per-agent installation paths), while also consolidating SKILL frontmatter parsing into a shared library.
Changes:
- Introduces
pkg/lib/skill(agent registry/detection, skill name derivation, tar skill-layer reading/frontmatter parsing, and installation logic). - Extends
kit unpackwith--as-skill[=agents...]to install qualifying prompt layers as agent skills (global by default, project-scoped when-dis explicitly set). - Updates kitfile generation to reuse shared SKILL frontmatter parsing and fixes relative-path reading by tracking
ContextDir.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/lib/skill/skillfile.go | Reads prompt-layer tars, detects SKILL.md, parses YAML frontmatter |
| pkg/lib/skill/skillfile_test.go | Unit tests for skill-layer reading and frontmatter parsing |
| pkg/lib/skill/sanitize.go | Skill-name sanitization and name derivation rules |
| pkg/lib/skill/sanitize_test.go | Tests for sanitization/derivation behavior |
| pkg/lib/skill/install.go | Installs extracted tar entries into per-agent skill directories; strips prompt path prefixes |
| pkg/lib/skill/install_test.go | Installation tests (overwrite/ignore/dedup/prefix stripping) |
| pkg/lib/skill/agents.go | Registry of supported agents + detection and path resolution |
| pkg/lib/skill/agents_test.go | Minimal registry/config test coverage |
| pkg/lib/kitfile/generate/filesystem.go | Adds ContextDir so generated listings can resolve paths correctly |
| pkg/lib/kitfile/generate/skill.go | Switches frontmatter parsing to shared skill package; uses ContextDir |
| pkg/lib/kitfile/generate/skill_test.go | Updates tests for new parsing signature and SKILL filename expectations |
| pkg/lib/filesystem/unpack/options.go | Adds SkillOptions to enable skill-mode behavior |
| pkg/lib/filesystem/unpack/core.go | Implements prompt-layer “install as skill” path and summary/error handling |
| pkg/cmd/unpack/cmd.go | Adds --as-skill CLI flag and parses agent auto-detect / explicit agent list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fail fast in GetGlobalSkillsDir and DetectInstalledAgents when user home directory cannot be determined - Fix stale comment referencing path.Rel in stripPromptPrefix - Align copyright year to 2026 in sanitize_test.go Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
5688676 to
76e2183
Compare
Return prefix-strip errors from InstallSkill so unpack fails fast on misaligned prompt paths. Validate skill names and tar entry paths before writes to prevent unsafe or partial installs. Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
Handle single-file prompts only when the layer contains exactly one matching file entry, preventing directory prompt layers from being misclassified and stripped incorrectly. Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
Make sanitizeName return empty for invalid/blank input and move "unnamed-skill" fallback into DeriveSkillName so fallback priority is preserved before defaulting. Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
a66b694 to
770971c
Compare
| normalize := func(p string) string { | ||
| return path.Clean(strings.ReplaceAll(p, "\\", "/")) | ||
| } | ||
|
|
||
| // Normalize to forward slashes so comparisons work regardless of | ||
| // whether the Kitfile was packed on Windows or Unix. | ||
| prefix := normalizePath(promptPath) | ||
| prefix := normalize(promptPath) | ||
| cleaned := normalize(entryName) |
There was a problem hiding this comment.
In this case, don't we want to return paths cleaned by filepath.Clean? This will return a forward-slash delimited path on Windows, which means we're relying on the side-effect of filepath.Join, which happens to call filepath.Clean to convert it back to a windows-style path.
There was a problem hiding this comment.
I think forward slashes work as input on all platforms in Go. filepath.Join handles mixed separators it replaces occurrences of slash by Separator
| return AgentInstallResult{Agent: agent, Path: skillDir} | ||
| } | ||
|
|
||
| // AGENT_MODIFIED: Human review required before merge |
There was a problem hiding this comment.
you must have seen it wrong :)
Make sanitizeName return empty for invalid/blank input and move "unnamed-skill" fallback into DeriveSkillName so fallback priority is preserved before defaulting. Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
770971c to
72fc15f
Compare
Summary
--as-skillflag tokit unpackthat installs SKILL.md prompt layers as agent skills for 45+ coding agents (Claude Code, Cursor, Windsurf, etc.)--as-skill=claude-code,cursor-dis specifiedpkg/lib/skillpackage, fixing a pre-existing bug wherekit initcouldn't read SKILL.md when run from a parent directoryNew package:
pkg/lib/skill/agents.gosanitize.goskillfile.goinstall.go