Using Templates
Template sources
Section titled “Template sources”diecut pulls templates from local paths or any Git host.
| Source | Example |
|---|---|
| Local path | diecut new ./my-template |
| GitHub | diecut new gh:user/repo |
| GitLab | diecut new gl:user/repo |
| Bitbucket | diecut new bb:user/repo |
| Sourcehut | diecut new sr:user/repo |
| Any Git URL | diecut new https://git.example.com/repo.git |
Git templates are cached at ~/.cache/diecut/templates/. Override with DIECUT_CACHE_DIR.
Overriding variables
Section titled “Overriding variables”Pass -d key=value to skip prompts for specific variables:
diecut new gh:user/template -d project_name=foo -d license=MIT -o my-projectVariables passed with -d skip the interactive prompt. You can mix — pass some via -d and diecut prompts for the rest.
Non-interactive mode
Section titled “Non-interactive mode”For CI pipelines or scripting, use --defaults:
diecut new gh:user/template --defaults -o my-projectEvery variable uses its default value. No prompts. Combine with -d to override specific ones:
diecut new gh:user/template --defaults -d project_name=ci-test -o outputUpdating a project
Section titled “Updating a project”You generated a project three months ago. The template author added a new CI config and updated the README. Instead of starting over:
diecut update ./my-projectHere is what happens:
- Reads
.diecut-answers.tomlfrom your project. This file stores the template source and your original variable choices. - Renders the template at the original version (old snapshot).
- Renders at the latest version (new snapshot).
- Three-way merges against your actual files.
- Reports files updated, added, removed, and any conflicts.
Pin to a specific version:
diecut update ./my-project --ref v2.0.0Conflicts are saved as .rej files. You resolve them manually, like patch conflicts.
Cookiecutter compatibility
Section titled “Cookiecutter compatibility”diecut auto-detects cookiecutter templates:
diecut new gh:audreyfeldroy/cookiecutter-pypackage -o my-packageIt 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.
Managing the cache
Section titled “Managing the cache”List cached templates:
diecut listTemplates live at ~/.cache/diecut/templates/. Set DIECUT_CACHE_DIR to change the location. Delete the directory to clear the cache.