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
Bitbucketdiecut new bb:user/repo
Sourcehutdiecut new sr: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.

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

You generated a project three months ago. The template author added a new CI config and updated the README. Instead of starting over:

Terminal window
diecut update ./my-project

Here is what happens:

  1. Reads .diecut-answers.toml from your project. This file stores the template source and your original variable choices.
  2. Renders the template at the original version (old snapshot).
  3. Renders at the latest version (new snapshot).
  4. Three-way merges against your actual files.
  5. Reports files updated, added, removed, and any conflicts.

Pin to a specific version:

Terminal window
diecut update ./my-project --ref v2.0.0

Conflicts are saved as .rej files. You resolve them manually, like patch conflicts.

diecut auto-detects cookiecutter templates:

Terminal window
diecut new gh:audreyfeldroy/cookiecutter-pypackage -o my-package

It finds cookiecutter.json, translates the format on the fly, and prompts you as usual. No migration needed.

For a permanent conversion to native diecut format, see Migrating from Cookiecutter.

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.