Skip to content

Add --as-skill flag to kit unpack for agent skill installation#1158

Open
gorkem wants to merge 10 commits intokitops-ml:mainfrom
gorkem:worktree-unpack-as-skill
Open

Add --as-skill flag to kit unpack for agent skill installation#1158
gorkem wants to merge 10 commits intokitops-ml:mainfrom
gorkem:worktree-unpack-as-skill

Conversation

@gorkem
Copy link
Copy Markdown
Member

@gorkem gorkem commented Apr 6, 2026

Summary

  • Adds --as-skill flag to kit unpack that installs SKILL.md prompt layers as agent skills for 45+ coding agents (Claude Code, Cursor, Windsurf, etc.)
  • Auto-discovers installed agents when no agents are specified; supports explicit agent list via --as-skill=claude-code,cursor
  • Installs globally (user-scoped) by default; project-scoped when -d is specified
  • Strips prompt path prefixes so SKILL.md lands at the skill root regardless of nesting depth
  • Consolidates frontmatter parsing into shared pkg/lib/skill package, fixing a pre-existing bug where kit init couldn't read SKILL.md when run from a parent directory

New package: pkg/lib/skill/

File Purpose
agents.go Agent registry (45+ agents), detection, path resolution
sanitize.go Skill name derivation and sanitization
skillfile.go Tar layer reading, SKILL.md detection, frontmatter parsing
install.go Per-agent installation with path dedup, overwrite/ignore semantics

gorkem added 4 commits April 5, 2026 20:12
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 unpack with --as-skill[=agents...] to install qualifying prompt layers as agent skills (global by default, project-scoped when -d is 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.

Comment thread pkg/lib/skill/skillfile.go
Comment thread pkg/lib/skill/install.go Outdated
Comment thread pkg/lib/skill/agents.go
Comment thread pkg/lib/skill/skillfile.go
Comment thread pkg/lib/skill/sanitize_test.go Outdated
- 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>
@gorkem gorkem force-pushed the worktree-unpack-as-skill branch from 5688676 to 76e2183 Compare April 7, 2026 17:31
Comment thread pkg/cmd/unpack/cmd.go
Comment thread pkg/cmd/unpack/cmd.go
Comment thread pkg/cmd/unpack/cmd.go
Comment thread pkg/cmd/unpack/cmd.go Outdated
Comment thread pkg/lib/filesystem/unpack/core.go
Comment thread pkg/lib/skill/install.go Outdated
Comment thread pkg/lib/skill/install.go Outdated
Comment thread pkg/lib/skill/sanitize.go Outdated
Comment thread pkg/lib/skill/sanitize.go Outdated
Comment thread pkg/lib/skill/sanitize.go
gorkem added 4 commits April 9, 2026 17:45
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>
@gorkem gorkem force-pushed the worktree-unpack-as-skill branch 2 times, most recently from a66b694 to 770971c Compare April 15, 2026 14:49
@gorkem gorkem requested a review from amisevsk April 15, 2026 14:52
Comment thread pkg/lib/skill/install.go
Comment on lines +95 to +100
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think forward slashes work as input on all platforms in Go. filepath.Join handles mixed separators it replaces occurrences of slash by Separator

Comment thread pkg/lib/skill/install.go Outdated
return AgentInstallResult{Agent: agent, Path: skillDir}
}

// AGENT_MODIFIED: Human review required before merge
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@gorkem gorkem force-pushed the worktree-unpack-as-skill branch from 770971c to 72fc15f Compare April 16, 2026 14:16
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.

3 participants