Fix --from-template: preserve frontmatter and copy sibling assets (#82, #83)#84
Merged
devrimcavusoglu merged 2 commits intoMay 6, 2026
Merged
Conversation
#83) `skill create --from-template <path>` previously read the path as a single file and dumped its contents into the skill body, which produced two stacked frontmatter blocks (template's beneath skern's defaults) and silently dropped sibling assets. Resolve both by detecting what the path points to: * directory containing SKILL.md — parse the manifest for frontmatter and recursively copy all siblings (references/, templates/, VENDORED.md, ...) into the new skill via the new registry.CopySiblings helper. * SKILL.md file — parse the manifest for frontmatter (no siblings to copy). * any other markdown file — keep legacy raw-body behavior. The CLI <name> argument always wins over the template's name. Other CLI flags override template values only when explicitly set (cobra Changed()), so an unspecified --description preserves the template's description rather than stamping the placeholder. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
A skill is a folder, so --from-template now accepts only a directory containing a SKILL.md. Bare-file modes (a SKILL.md file path or a body-only markdown file) are rejected with a clear error that points at the parent directory: --from-template must point to a skill directory containing a SKILL.md file, but "<path>" is a file; pass the parent directory instead A directory missing SKILL.md gets its own dedicated message instead of the generic parse error. The directory-mode behavior (preserve frontmatter + copy siblings) is unchanged. Updates the manual scenario 09 templates from flat .md files into proper skill directories with SKILL.md to match the new contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
devrimcavusoglu
added a commit
that referenced
this pull request
May 7, 2026
Move the [Unreleased] block to v0.3.0 dated 2026-05-07, with a focused "Breaking changes" section calling out the --from-template directory requirement (#84). Cross-link the four PRs that landed since v0.2.1 (#81, #84, #86, #87) and add a Changed entry covering the docs-site refresh that ships in this branch. Bump the corresponding version refs in AGENTS.md (current release + milestone snapshot now covers M0–M7), INSTALL.md (SKERN_VERSION pin example), docs/guide/installation.md (matching pin example), and docs/guide/index.md (current-release callout). Docs build verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
devrimcavusoglu
added a commit
that referenced
this pull request
May 7, 2026
* Refresh docs site for v0.2.1 (eight platforms, init instructions, skill versioning) Bring the VitePress site up to date with the v0.2.0 / v0.2.1 surface that has landed since the last docs refresh: - Eight platform adapters wherever 3 were listed (index, guide, concepts diagram, reference flag enums, platforms index/comparison) and a dedicated page for each new adapter (cursor, gemini-cli, github-copilot, windsurf, continue). - `skern init --instructions` / `--tool-forming-loop` / `--target` / `--print-instructions` documented in the quick-start, agent-setup, and command reference. Agent-setup now leads with `init --instructions` instead of the manual `echo … >> AGENTS.md` recipe. - Reference reorganized: registry vs. platform command groups, full pages for `skill import`, `skill version`, `skill diff`, capacity reporting on install/uninstall, `--enforce-budget`, `--with-platforms`, batch install/uninstall. - Validation page split into errors / warnings / hints with the trigger-prefix and recommended-section hints. - Skill format page corrected to the nested `metadata.author` / `metadata.version` / `metadata.modified-by` schema and includes the import workflow. - Installation page covers macOS, Linux, and Windows (PowerShell) one-liners plus version pinning, custom install dir, source build, manual install, uninstall. - Contributing/development reflects the declarative platform spec, updated Make targets, and the `cli/instructions/` package. - Sidebar adds the new platform pages and a Writing Skills entry under Guide. Build verified with `npm run docs:build` (clean). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Cut v0.3.0: stamp CHANGELOG, bump version refs Move the [Unreleased] block to v0.3.0 dated 2026-05-07, with a focused "Breaking changes" section calling out the --from-template directory requirement (#84). Cross-link the four PRs that landed since v0.2.1 (#81, #84, #86, #87) and add a Changed entry covering the docs-site refresh that ships in this branch. Bump the corresponding version refs in AGENTS.md (current release + milestone snapshot now covers M0–M7), INSTALL.md (SKERN_VERSION pin example), docs/guide/installation.md (matching pin example), and docs/guide/index.md (current-release callout). Docs build verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
skill create --from-template <SKILL.md>resetdescription,tags,metadata.author, andmetadata.versionto placeholder defaults because the file was read opaquely into the body, producing a malformed manifest with two stacked frontmatter blocks (only the default block was visible to the parser).--from-templateonly ever read a single file, so sibling assets (references/,templates/,VENDORED.md, …) were silently dropped.Both issues share a single root cause: the flag was implemented as "read one file as raw body" while users (e.g., AURA's init flow) reasonably treat a skill as a folder. This PR makes
--from-templateaccept all three sensible inputs and behave correctly for each.Behavior
--from-template <path>now resolves three ways:<path>isSKILL.mdSKILL.md.SKILL.mdfile (starts with---)In the manifest-aware modes, the CLI
<name>always wins over the template'sname. Other CLI flags (--description,--tags,--author*,--version) override template values only when explicitly set (viacobra.Flags().Changed()), so an unspecified--descriptionno longer clobbers the template's description with theUse when TODO:placeholder.Implementation
internal/registry/copy.go::CopySiblings(srcDir, dstDir)— recursive copy that skips the top-levelSKILL.md. Lives inregistry/per the layering note in AGENTS.md ("filesystem operations belong here, not incli/").internal/cli/skill_create.go—loadTemplateresolves the path;buildSkillFromTemplatemerges template + CLI flags. Falls back to the existingNewSkillWithBodypath when no template is given.Registry.Createsignature unchanged — sibling copying is a follow-on step in the CLI command, with rollback (os.RemoveAll(path)) if the copy fails.Test plan
TestCopySiblings_*— copy nested files, skip top-levelSKILL.md, copy a nestedSKILL.md, handle empty dir.TestSkillCreate_FromTemplate_SkillMdFile_PreservesFrontmatter— description, tags, version, author all preserved; onlynameoverridden.TestSkillCreate_FromTemplate_Directory_CopiesSiblings— verifiesreferences/architecture.md,templates/example.txt,VENDORED.mdland in the new skill with byte-identical content.TestSkillCreate_FromTemplate_CLIOverridesTemplate—--descriptionand--tagsoverride; unspecified--author/--versioninherit from template.TestSkillCreate_FromTemplate_RawBodyFile— legacy raw-body path still works; produces exactly one frontmatter block.TestSkillCreate_FromTemplate_DirectoryMissingManifest— clear error when the directory has noSKILL.md.make fmtclean,make lint0 issues,make testall green.references/,templates/, andVENDORED.md— all assets copied, frontmatter preserved, single clean frontmatter block in the outputSKILL.md.Closes #82
Closes #83
🤖 Generated with Claude Code