Cookiecutter is a command-line tool that creates new projects from templates (called cookiecutters).
It automatically sets up files, folders, and code based on your answers to some prompts.
Very useful for starting projects like Python packages.

Key Features:
- Cross-platform (Windows, Mac, Linux)
- No Python knowledge needed to use
- Works with Python 3.7 to 3.12
- Supports templates in any language (not just Python)
- You can use local templates or GitHub templates
- Supports hooks for pre/post generation customization
Automation with Cookiecutter and GitHub Actions
Motivation
- Traditional project setup is tedious; needed a faster, automated, centralized solution.
- Goal: eliminate local dependencies, streamline CI/CD, and standardize templates.
Cookiecutter for Project Templating
- Enables fast, customizable project generation.
- Supports placeholder variables for project-specific customization.
Cruft for Template Maintenance:
- Tracks project-template linkage after generation.
- Allows updating existing projects as templates evolve.
- Manages
.cruft.json
for tracking metadata.
GitHub Actions for Automation
- Automates project setup inside GitHub repositories.
- Ensures consistency and scalability across teams.
Workflow Implementation
- Repository includes:
- Templates use a directory named
{{ cookiecutter.static_name }}
to fit Cookiecutter structure. - A
static_name
(“static”) workaround is used to move generated files correctly.

Setting Up Template Variables
- Create a
cookiecutter_inputs.json
with project-specific variables. - Example includes project name, author, email, Python version.
The GitHub Action Setup
- Action takes template name and variable path as inputs.
- A small Python script reads and applies inputs.
- Full action details: GitHub – cookiecutter-action.
Automating with a Workflow
- Add
generate_template.yml
inside.github/workflows
. - Triggers on
push
. - Generates project structure, commits, and pushes it automatically.
- Requires:
template_directory
template_var_path
workflow_token
Advantages
- Full GitHub integration, no extra tools needed.
- Saves time and reduces setup errors.
- Enforces project structure consistency.
Considerations
- Requires familiarity with GitHub Actions and Cookiecutter.
- May feel heavy for very small projects.
- Tied to GitHub (not easily portable to other platforms).
GitHub – cookiecutter/cookiecutter: A cross-platform command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, C projects.
A cross-platform command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, C projects. – cookiecutter/cookiecutter