Skip to content

Add skill import from URL/git (#43)#73

Merged
devrimcavusoglu merged 2 commits into
mainfrom
feature/skill-import
Apr 26, 2026
Merged

Add skill import from URL/git (#43)#73
devrimcavusoglu merged 2 commits into
mainfrom
feature/skill-import

Conversation

@devrimcavusoglu
Copy link
Copy Markdown
Owner

Summary

  • Add skern skill import <url> command that imports skills from GitHub repository directories and GitHub gists into the local registry
  • Support --name (override manifest name), --scope (user/project), --force (overwrite existing + bypass overlap block) flags
  • Download SKILL.md + all companion files from remote directory, with overlap detection consistent with skill create

Changes

New files:

  • internal/skill/importer.go — URL parsing (ParseImportURL), HTTP fetching (FetchSkill), ParseManifestFromBytes
  • internal/cli/skill_import.go — Cobra command wiring
  • internal/skill/importer_test.go — 12 tests (URL parsing + mock HTTP fetch)
  • internal/cli/skill_import_test.go — 11 CLI-level tests

Modified files:

  • internal/output/types_skill.go — Added SkillImportResult
  • internal/registry/registry.go — Added Import() method; migrated manifestFile to skill.ManifestFile
  • internal/skill/skill.go — Exported ManifestFile constant
  • internal/cli/context.go — Added HTTPClient and GitHubBaseURL for testability
  • internal/cli/skill.go — Registered newSkillImportCmd()

Test plan

  • go test ./... — all 23 new tests pass
  • make build — binary builds successfully
  • skern skill import --help — shows correct usage

Closes #43

🤖 Generated with Claude Code

devrimcavusoglu and others added 2 commits April 13, 2026 03:14
Add `skern skill import <url>` command to import skills from GitHub
repository directories and gists. Supports --name override, --scope,
--force, overlap detection, companion files, and JSON output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 30s default HTTP timeout for skill import (was using
  http.DefaultClient with no timeout — slow/malicious endpoints
  could hang the CLI indefinitely).
- Cap downloaded payloads at 10 MiB via io.LimitReader on the
  contents API JSON, gist API JSON, and each companion file.
- Reject companion filenames containing path separators, "..",
  or absolute paths in Registry.Import. The contents API normally
  returns base names, but the gist API echoes user-supplied
  filenames, so validate defensively at the registry boundary.
- Convert ParseImportURL switch to a tagged switch (staticcheck
  QF1002) and document that refs containing slashes cannot be
  unambiguously parsed from the tree-URL form.
- Drop the misleading "github repo with branch ref" test that
  asserted the parser's incorrect behavior on slashed refs.
- Fix errcheck: wrap unchecked Encode/Write returns in test
  servers and resp.Body.Close() defers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@devrimcavusoglu devrimcavusoglu merged commit 2bf61d8 into main Apr 26, 2026
4 checks passed
@devrimcavusoglu devrimcavusoglu deleted the feature/skill-import branch April 26, 2026 17:25
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.

Skill import from URL/git

1 participant