Skip to content

Hooks

Hooks are shell commands that run after project generation. Configure them in diecut.toml.

[hooks]
post_create = "git init"

The command runs in the generated project directory via sh -c.

[hooks]
post_create = "git init && git add -A && git commit -m 'Initial commit'"

Python project:

[hooks]
post_create = "pip install -e ."

Node.js project:

[hooks]
post_create = "npm install"

Rust project:

[hooks]
post_create = "cargo build"
[hooks]
post_create = "./setup.sh"

The script must be in the template’s template/ directory and will be copied to the output before the hook runs.

When generating from a remote template that contains hooks, diecut prints a warning:

warning: This template contains hooks that will execute code on your machine
source: https://github.com/user/repo.git
use --no-hooks to skip hook execution

Use --no-hooks to skip hook execution for untrusted templates.