Cookiecutter

Cookiecutter is a project templating and scaffolding tool that generates new projects from Jinja2-based templates. It prompts for values, then renders file contents and paths to produce a ready-to-use project structure for Python and others.

Installation and Setup

Install it from PyPI:

Windows PowerShell
(venv) PS> py -m pip install cookiecutter
Shell
(venv) $ python -m pip install cookiecutter

A template defines prompts and defaults in cookiecutter.json or cookiecutter.yaml:

JSON cookiecutter.json
{
  "project_name": "example",
  "package_name": "example",
  "license": ["MIT", "Apache-2.0"]
}

Optional user configuration lives in ~/.cookiecutterrc and can set a default template directory and context.

Key Features

  • Provides Jinja2-powered scaffolding that renders file contents and paths, including directory names.
  • Works with templates from local directories, Git repositories, and ZIP archives.
  • Supports interactive prompts with defaults, plus unattended runs with --no-input.
  • Provides hooks (pre_prompt, pre_gen_project, post_gen_project) to validate inputs and customize output.
  • Allows for repeatable runs via replay files with --replay, --replay-file.

Usage

Generate a project from a remote template:

Shell
$ cookiecutter https://github.com/your-org/your-template

Render from a local template folder:

Shell
$ cookiecutter path/to/template

Write output into a specific directory and select a template subfolder:

Shell
$ cookiecutter -o ./projects https://github.com/your-org/your-template

Repeat a previous run using the saved replay file:

Shell
$ cookiecutter --replay https://github.com/your-org/your-template

Choose a subdirectory with --directory:

Shell
$ cookiecutter https://github.com/your-org/your-template --directory templates/library

By Leodanis Pozo Ramos • Updated Dec. 15, 2025