Skip to content

Using Templates

diecut pulls templates from local paths or any Git host.

SourceExample
Local pathdiecut new ./my-template
GitHubdiecut new gh:user/repo
GitLabdiecut new gl:user/repo
Codebergdiecut new cb:user/repo
Any Git URLdiecut new https://git.example.com/repo.git

Git templates are cached at ~/.cache/diecut/templates/. Override with DIECUT_CACHE_DIR.

A single repo can hold multiple templates in subdirectories. Add the subdirectory path after the repo:

Terminal window
diecut new gh:raiderrobert/diecut-templates/python-pkg --output my-project
diecut new gh:raiderrobert/diecut-templates/rust-cli --output my-cli

diecut clones the repo once and navigates to the specified subdirectory.

Pass -d key=value to skip prompts for specific variables:

Terminal window
diecut new gh:user/template -d project_name=foo -d license=MIT -o my-project

Variables passed with -d skip the interactive prompt. You can mix — pass some via -d and diecut prompts for the rest.

For CI pipelines or scripting, use --defaults:

Terminal window
diecut new gh:user/template --defaults -o my-project

Every variable uses its default value. No prompts. Combine with -d to override specific ones:

Terminal window
diecut new gh:user/template --defaults -d project_name=ci-test -o output

Preview what would be generated without writing any files:

Terminal window
diecut new ./my-template --dry-run

Add --verbose to also see the rendered file contents:

Terminal window
diecut new ./my-template --dry-run --verbose

List cached templates:

Terminal window
diecut list

Templates live at ~/.cache/diecut/templates/. Set DIECUT_CACHE_DIR to change the location. Delete the directory to clear the cache.