Skip to content

Fix --from-template: preserve frontmatter and copy sibling assets (#82, #83)#84

Merged
devrimcavusoglu merged 2 commits into
mainfrom
feature/from-template-frontmatter-and-siblings
May 6, 2026
Merged

Fix --from-template: preserve frontmatter and copy sibling assets (#82, #83)#84
devrimcavusoglu merged 2 commits into
mainfrom
feature/from-template-frontmatter-and-siblings

Conversation

@devrimcavusoglu
Copy link
Copy Markdown
Owner

Summary

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-template accept all three sensible inputs and behave correctly for each.

Behavior

--from-template <path> now resolves three ways:

<path> is Behavior
Directory containing SKILL.md Parses frontmatter; recursively copies every sibling file/subdir alongside the new SKILL.md.
SKILL.md file (starts with ---) Parses frontmatter. (No siblings — point at the directory for those.)
Any other markdown file Contents become the new skill's body verbatim (legacy behavior preserved for backward compatibility).

In the manifest-aware modes, the CLI <name> always wins over the template's name. Other CLI flags (--description, --tags, --author*, --version) override template values only when explicitly set (via cobra.Flags().Changed()), so an unspecified --description no longer clobbers the template's description with the Use when TODO: placeholder.

Implementation

  • New internal/registry/copy.go::CopySiblings(srcDir, dstDir) — recursive copy that skips the top-level SKILL.md. Lives in registry/ per the layering note in AGENTS.md ("filesystem operations belong here, not in cli/").
  • internal/cli/skill_create.goloadTemplate resolves the path; buildSkillFromTemplate merges template + CLI flags. Falls back to the existing NewSkillWithBody path when no template is given.
  • Registry.Create signature unchanged — sibling copying is a follow-on step in the CLI command, with rollback (os.RemoveAll(path)) if the copy fails.

Test plan

  • Unit: TestCopySiblings_* — copy nested files, skip top-level SKILL.md, copy a nested SKILL.md, handle empty dir.
  • CLI regression for skill create --from-template does not preserve frontmatter fields (description, metadata) #82: TestSkillCreate_FromTemplate_SkillMdFile_PreservesFrontmatter — description, tags, version, author all preserved; only name overridden.
  • CLI regression for skill create does not copy sibling assets (references/, templates/, VENDORED.md) from template directory #83: TestSkillCreate_FromTemplate_Directory_CopiesSiblings — verifies references/architecture.md, templates/example.txt, VENDORED.md land in the new skill with byte-identical content.
  • CLI: TestSkillCreate_FromTemplate_CLIOverridesTemplate--description and --tags override; unspecified --author/--version inherit from template.
  • CLI: TestSkillCreate_FromTemplate_RawBodyFile — legacy raw-body path still works; produces exactly one frontmatter block.
  • CLI: TestSkillCreate_FromTemplate_DirectoryMissingManifest — clear error when the directory has no SKILL.md.
  • make fmt clean, make lint 0 issues, make test all green.
  • Manual end-to-end against the rebuilt binary using a source skill with references/, templates/, and VENDORED.md — all assets copied, frontmatter preserved, single clean frontmatter block in the output SKILL.md.

Closes #82
Closes #83

🤖 Generated with Claude Code

devrimcavusoglu and others added 2 commits May 6, 2026 19:47
#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 devrimcavusoglu merged commit 2b7dc79 into main May 6, 2026
4 checks passed
@devrimcavusoglu devrimcavusoglu deleted the feature/from-template-frontmatter-and-siblings branch May 6, 2026 21:04
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant