scaffold

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package scaffold renders the embedded templates into a directory on disk. Separating this from the cli package keeps the rendering logic testable without spawning a cobra command.

Index

Constants

This section is empty.

Variables

View Source
var ErrNameInvalid = errors.New("name must be kebab-case: lowercase letters, digits, and single hyphens")

ErrNameInvalid is returned when Name does not match kebabPattern.

View Source
var ErrTargetExists = errors.New("target directory already exists (use --force to overwrite)")

ErrTargetExists is returned when the scaffold target directory already exists and Force is false.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name  string
	Email string
}

Author captures the author fields every template references. Both fields may be empty strings; the scaffold never rejects the run for missing author data (marketplaces do, and hanko flags it, but that's not scaffold's job).

type Kind

type Kind string

Kind identifies what the caller wants scaffolded.

const (
	// KindPlugin scaffolds a full Claude Code plugin directory with a
	// sample skill, LICENSE, README, and plugin.json.
	KindPlugin Kind = "plugin"
	// KindSkill scaffolds a standalone SKILL.md in skills/<name>/.
	KindSkill Kind = "skill"
)

type Options

type Options struct {
	// Kind is plugin or skill.
	Kind Kind
	// Name is the kebab-case identifier (plugin name, skill name).
	Name string
	// TargetDir is where files land. Defaults to current working dir.
	// Scaffold creates a subdirectory named Name under TargetDir for
	// the plugin kind, and skills/Name/ for the skill kind.
	TargetDir string
	// Description populates the top-level description in plugin.json
	// and the frontmatter of skills.
	Description string
	// Author is written into plugin.json and the LICENSE year + holder.
	Author Author
	// Version is the initial version in plugin.json. Default "0.1.0".
	Version string
	// License is the SPDX identifier written into plugin.json. Default "MIT".
	License string
	// Year is the LICENSE copyright year. Defaults to the current year.
	Year int
	// SampleSkill is the sub-skill created inside a plugin. Default "hello".
	// Plugin kind only.
	SampleSkill string
	// Attribution, when true (default), includes a "scaffolded with
	// tsuba" footer in generated README files.
	Attribution bool
	// Force, when true, overwrites existing files. Default false; the
	// scaffold errors out if the target directory already exists.
	Force bool
}

Options customises a single scaffold run. All fields except Name have working defaults; see Defaults for the canonical values.

type Result

type Result struct {
	// Root is the absolute path of the directory the scaffold created.
	Root string
	// Files lists the paths of every file that was written, relative
	// to Root. Order is deterministic (lexical).
	Files []string
}

Result summarises what Scaffold wrote. Callers (tests, the CLI) use it to report back to the user without re-walking the filesystem.

func Scaffold

func Scaffold(opts Options) (*Result, error)

Scaffold renders templates for the requested kind and writes them to disk. It returns a Result describing what was written. Errors are wrapped with context so the CLI can surface them directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL