Repository navigation
feat: build skill images from remote Git repositories - #24
Conversation
Design for building OCI skill images directly from Git repository URLs, with SKILL.md-based discovery and SkillCard generation from frontmatter. Closes #10 and #13. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Eight tasks covering URL parsing, git clone with sparse checkout, SKILL.md discovery, SkillCard generation, Build() changes, resolver orchestrator, CLI integration, and end-to-end verification. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Implement Git clone functionality with sparse checkout optimization and ref override support for remote Git repositories. Features: - CheckGit validates git availability in PATH - Clone performs shallow clone with depth=1 for efficiency - Sparse checkout with --filter=blob:none for subPath clones - Automatic fallback to full shallow clone when sparse fails - RefOverride option to clone specific tags/branches/commits - Returns CloneResult with directory, commit SHA, and cleanup func Tests verify: - Git availability check - Shallow clone with subpath extraction - Error on nonexistent subpath - RefOverride clones correct tag/branch Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Implements Tasks 3 and 4: SKILL.md-based skill discovery with glob filtering and SkillCard generation from frontmatter. - Discover(): walks directory tree for SKILL.md files, supports glob patterns - GenerateSkillCard(): parses YAML frontmatter, generates SkillCard with fallbacks - Shared frontmatter parser (parseFrontmatterRaw) handles malformed YAML gracefully - Skips hidden directories, prevents nested skill discovery - Normalizes versions to semver (e.g., '2.0' → '2.0.0') - Falls back to first sentence for description, directory name for skill name Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Add SkillCard field to BuildOptions to support building from a pre-built SkillCard instead of always reading skill.yaml from disk. When SkillCard is provided, Build skips file read/parse/validate. This enables building skills from remote Git sources where the SkillCard is generated from SKILL.md frontmatter. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Enables 'skillctl build' to accept Git URLs in addition to local directories. New --ref flag allows specifying branch, tag, or commit SHA. New --filter flag enables glob pattern matching on skill names. The command automatically detects remote URLs via source.IsRemote() and routes them to runBuildRemote(), which: - Clones the repo (with optional ref) - Discovers skills (with optional filter) - Generates SkillCards for skills missing skillcard.yaml - Builds each skill into a local OCI image - Reports success/failure counts The existing runBuild() function remains unchanged for local paths. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughImplements remote Git source support for skill building. The feature adds URL parsing for Git repositories, cloning with ref/subpath handling, automatic skill directory discovery, SkillCard generation from SKILL.md frontmatter, and CLI integration to build multiple skills with provenance tracking. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI Build Command
participant Source as Source Resolver
participant Git as Git Operations
participant Discover as Skill Discovery
participant Generate as SkillCard Gen
participant OCI as OCI Builder
CLI->>Source: Resolve(remoteURL, ref, filter)
Source->>Git: ParseGitURL(URL)
Git-->>Source: GitSource{CloneURL, Ref, SubPath}
Source->>Git: CheckGit()
Git-->>Source: ok/error
Source->>Git: Clone(GitSource, CloneOptions)
Git->>Git: git clone + git checkout
Git-->>Source: CloneResult{Dir, CommitSHA}
Source->>Discover: Discover(clonedDir, filter)
Discover-->>Source: []DiscoveredSkill
loop For each discovered skill
Source->>Generate: GenerateSkillCard(skillDir)
Generate->>Generate: Parse SKILL.md frontmatter
Generate-->>Source: *SkillCard
Source->>Source: Inject Provenance(source, commit, path)
end
Source-->>CLI: ResolveResult{Skills, Cleanup}
loop For each resolved skill
CLI->>OCI: Build(skillDir, BuildOptions{SkillCard})
OCI->>OCI: Use provided SkillCard
OCI-->>CLI: Image digest
end
CLI->>Source: Cleanup()
Source->>Git: Remove temp directory
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 45 minutes and 3 seconds.Comment |
- Support commit SHA refs via clone + checkout (not --branch) - Fix GitLab nested group URL parsing (org/subgroup/repo) - Surface discoverNested errors instead of swallowing them - Validate namespace/name on generated SkillCards before build - Sanitize git error output to avoid leaking credentials Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 10
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/cli/build.go`:
- Around line 66-70: The code prints rawURL to stdout which can leak credentials
(e.g., https://token@host/repo.git); update the printing in the block that uses
rawURL and ref so you first parse rawURL (using net/url.Parse), remove or redact
the User field (set url.User = nil or replace with a placeholder like
"<redacted>"), build a sanitizedURL string and use that in the
fmt.Fprintf/Fprintln calls instead of rawURL (keep ref printing unchanged).
Locate the print statements that reference rawURL and replace them to use the
sanitizedURL variable.
- Line 64: Replace uses of context.Background() with the CLI command context so
cancellation/interrupts propagate; in functions runBuild() and runBuildRemote(),
change the created ctx variable to use cmd.Context() (the context from the cobra
command parameter) wherever ctx := context.Background() is currently used so
resolve, clone, and build operations respect Ctrl+C and parent cancellations.
In `@pkg/oci/build.go`:
- Around line 30-57: In Build, do not skip validation when opts.SkillCard is
supplied: after setting sc = opts.SkillCard (or after parsing via
skillcard.Parse when opts.SkillCard is nil), always call skillcard.Validate(sc),
handle its error (valErr) and the returned validationErrors the same way as the
parsed-path (returning fmt.Errorf on valErr and composing a joined message when
len(validationErrors) > 0). Update the branch that currently just assigns sc to
invoke the same validation logic (including returning ocispec.Descriptor{} on
failures) so both injected and parsed SkillCards are validated consistently.
In `@pkg/source/clone.go`:
- Around line 82-88: sparseClone can leave destDir populated when it returns an
error (e.g., after a failed sparse-checkout), so immediately calling
shallowClone into the same destDir will fail; change the fallback logic around
sparseClone and shallowClone to detect a failed sparseClone and remove/clean
destDir (e.g., os.RemoveAll on destDir) before invoking shallowClone, or
alternatively have sparseClone itself rollback the destination on error —
reference the sparseClone, shallowClone and destDir symbols when making the
change.
In `@pkg/source/discover.go`:
- Around line 33-45: The current discovery loop in discover/discoverNested only
iterates root + one nested level and misses deeper skills; replace the manual
two-level traversal in the functions (e.g., discoverNested / discover) with
filepath.WalkDir and prune entries: skip hidden directories
(strings.HasPrefix(name, ".")), and when a directory containing "SKILL.md" is
encountered, record that skill and skip walking its descendants (use
DirEntry.IsDir and WalkDirFunc to return fs.SkipDir) so nested skills under a
skill dir are not explored; ensure you still collect SKILL.md paths and
propagate errors the same way as the existing logic.
- Around line 20-21: The code is ignoring errors from filepath.Match and
treating invalid glob syntax as "no skills matching"; change each occurrence
(where you currently have "if matched, _ := filepath.Match(filter, name) { ...
}") to capture the error (if matched, err := filepath.Match(filter, name)), and
if err != nil return a clear user error (e.g. fmt.Errorf("invalid --filter
pattern %q: %w", filter, err)); otherwise proceed with the matched boolean check
and existing logic. Apply this change to all three occurrences that use
filepath.Match with variables filter, name (and similar uses) so malformed
patterns produce an immediate, descriptive error rather than being silently
ignored.
In `@pkg/source/generate.go`:
- Around line 115-120: The normalizeVersion function currently splits the entire
version string on dots, which truncates and mutates versions containing
pre-release or build metadata like "1.2.3-beta.1" or "1.2.3+build.5"; update
normalizeVersion to first separate any suffix starting with '-' or '+' (preserve
that suffix), operate only on the core version (split core on '.', pad with "0"
until 3 parts or take first 3 parts), then rejoin core and append the original
suffix unchanged; locate the normalizeVersion function to implement this change.
- Line 29: The generated metadata.description can end up empty when
stringFromMap(fm, "description", firstSentence(body)) resolves to an empty
string; update the logic in the code that builds metadata.description (the call
site using stringFromMap and firstSentence) to ensure a non-empty fallback is
used—for example, compute desc := stringFromMap(fm, "description",
firstSentence(body)); if desc == "" { desc = "<no description>" } and then set
Description: desc so SkillCard metadata.description is never empty (refer to
stringFromMap and firstSentence in the same generation path).
In `@pkg/source/giturl.go`:
- Around line 69-71: The fallback for GitLab nested-group root URLs incorrectly
sets groupRepoPath using parts[:2], dropping intermediate groups; update the
logic in pkg/source/giturl.go where groupRepoPath is assigned (variable
groupRepoPath) so that when parts length >= 2 you join all path segments except
the final repo segment (e.g., strings.Join(parts[:len(parts)-1], "/")) instead
of parts[:2], and ensure you guard against small slice lengths so you don’t
panic.
In `@pkg/source/source.go`:
- Around line 67-70: When hasSkillYAML(d.Dir) is true the code currently appends
ResolvedSkill with SkillCard: nil which skips the provenance injection applied
later; change this branch to load and parse the skill.yaml into a SkillCard
(deserialize into the same SkillCard type used elsewhere), run the same
provenance injection routine you use for remote builds (the provenance injection
block that currently runs for non-skill.yaml paths), and set
ResolvedSkill.SkillCard to the parsed+injected SkillCard before appending;
specifically update the hasSkillYAML branch that calls hasSkillYAML to call the
parser/decoder for skill.yaml into SkillCard, invoke the provenance injection
helper (the same function or logic used in the other branch), and then append
ResolvedSkill{Dir: d.Dir, Name: d.Name, SkillCard: parsedCard}.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 546e56f5-8b07-44a1-8aa0-0b9743f01604
📒 Files selected for processing (16)
docs/superpowers/plans/2026-04-29-remote-git-sources.mddocs/superpowers/specs/2026-04-29-remote-git-sources-design.mdinternal/cli/build.gopkg/oci/build.gopkg/oci/client.gopkg/oci/oci_test.gopkg/source/clone.gopkg/source/clone_test.gopkg/source/discover.gopkg/source/discover_test.gopkg/source/generate.gopkg/source/generate_test.gopkg/source/giturl.gopkg/source/giturl_test.gopkg/source/source.gopkg/source/source_test.go
| Name: stringFromMap(fm, "name", filepath.Base(skillDir)), | ||
| Namespace: orgFallback, | ||
| Version: normalizeVersion(stringFromMapNested(fm, "metadata", "version", "0.1.0")), | ||
| Description: stringFromMap(fm, "description", firstSentence(body)), |
There was a problem hiding this comment.
Ensure generated metadata.description is never empty.
At Line 29, if frontmatter has no description and the body is empty/whitespace, firstSentence(body) returns "", producing a SkillCard that violates required metadata and may fail later in validation/build paths.
Suggested fix
- Description: stringFromMap(fm, "description", firstSentence(body)),
+ Description: nonEmpty(
+ stringFromMap(fm, "description", ""),
+ firstSentence(body),
+ filepath.Base(skillDir),
+ ),+func nonEmpty(values ...string) string {
+ for _, v := range values {
+ if s := strings.TrimSpace(v); s != "" {
+ return s
+ }
+ }
+ return ""
+}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Description: stringFromMap(fm, "description", firstSentence(body)), | |
| Description: nonEmpty( | |
| stringFromMap(fm, "description", ""), | |
| firstSentence(body), | |
| filepath.Base(skillDir), | |
| ), |
| Description: stringFromMap(fm, "description", firstSentence(body)), | |
| func nonEmpty(values ...string) string { | |
| for _, v := range values { | |
| if s := strings.TrimSpace(v); s != "" { | |
| return s | |
| } | |
| } | |
| return "" | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/source/generate.go` at line 29, The generated metadata.description can
end up empty when stringFromMap(fm, "description", firstSentence(body)) resolves
to an empty string; update the logic in the code that builds
metadata.description (the call site using stringFromMap and firstSentence) to
ensure a non-empty fallback is used—for example, compute desc :=
stringFromMap(fm, "description", firstSentence(body)); if desc == "" { desc =
"<no description>" } and then set Description: desc so SkillCard
metadata.description is never empty (refer to stringFromMap and firstSentence in
the same generation path).
| if groupRepoPath == "" { | ||
| groupRepoPath = strings.Join(parts[:2], "/") | ||
| } |
There was a problem hiding this comment.
GitLab nested-group root URLs are parsed incorrectly.
At Line 70, fallback uses only parts[:2], so a URL like https://gitlab.com/group/sub/repo becomes clone URL .../group/sub.git (repo segment dropped).
Suggested fix
if groupRepoPath == "" {
- groupRepoPath = strings.Join(parts[:2], "/")
+ // root repo URL: include full group/repo path (supports nested groups)
+ groupRepoPath = strings.Join(parts, "/")
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if groupRepoPath == "" { | |
| groupRepoPath = strings.Join(parts[:2], "/") | |
| } | |
| if groupRepoPath == "" { | |
| // root repo URL: include full group/repo path (supports nested groups) | |
| groupRepoPath = strings.Join(parts, "/") | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/source/giturl.go` around lines 69 - 71, The fallback for GitLab
nested-group root URLs incorrectly sets groupRepoPath using parts[:2], dropping
intermediate groups; update the logic in pkg/source/giturl.go where
groupRepoPath is assigned (variable groupRepoPath) so that when parts length >=
2 you join all path segments except the final repo segment (e.g.,
strings.Join(parts[:len(parts)-1], "/")) instead of parts[:2], and ensure you
guard against small slice lengths so you don’t panic.
- Sanitize URLs in CLI output to avoid leaking credentials - Use cmd.Context() for cancellation/Ctrl+C propagation - Validate all SkillCards (pre-built and parsed) in Build() - Clean destDir before shallowClone fallback after sparse failure - Use WalkDir for recursive skill discovery at any depth - Validate --filter glob pattern early with clear error - Preserve pre-release/build metadata in normalizeVersion - Parse skill.yaml and inject provenance for repos that have it Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Summary
skillctl build https://github.com/org/repo)SKILL.mdpresence (noskill.yamlrequired in source repos)Closes #10. Closes #13.
Usage
Design
New
pkg/sourcepackage (source resolver layer) that sits between the CLI andpkg/oci:giturl.goclone.godiscover.gogenerate.gosource.gopkg/oci.BuildOptionsgains aSkillCardfield so generated SkillCardscan be passed in without writing temporary files.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
buildcommand now accepts remote Git repository URLs as input--refflag to specify Git branches or tags for remote sources--filterflag to select specific skills from multi-skill repositoriesDocumentation