Reference repository for learning, using, and creating templates with Cookiecutter.
Cookiecutter is a CLI tool that generates projects from templates. It defines variables in cookiecutter.json, uses Jinja2 in file names and content, and runs pre/post generation hooks. It is the de facto standard for scaffolding in Python and multi-language projects.
- What is Cookiecutter
- Quick Install
- How to Use This Repository
- Repository Structure
- Included Template: Behave BDD
- Minimalist Examples
- Documentation
- Resources
- Contributing
Cookiecutter creates projects from templates interactively or non-interactively. A template is a directory with:
cookiecutter.json— defines the variables the user fills in.{{ cookiecutter.project_name }}/— the template directory (Jinja2 in name and content).hooks/(optional) —pre_gen_project.pyandpost_gen_project.pyscripts.
# Basic usage
cookiecutter https://github.com/user/cookiecutter-template
# Non-interactive
cookiecutter --no-input https://github.com/user/cookiecutter-template project_name=my-project
# From a local path
cookiecutter ./my-templatepip install cookiecutter
# or with pipx (recommended)
pipx install cookiecutterRequires: Python 3.7+.
# Clone this repo
git clone https://github.com/MathiasPaulenko/cookiecutter-example.git
cd cookiecutter-example
# Generate project from the Behave BDD template
cookiecutter .
# or non-interactive:
cookiecutter --no-input . project_name=my_behave_project# Basic example
cookiecutter examples/01-minimal/
# Hooks example
cookiecutter examples/02-hooks/
# Choices and conditionals example
cookiecutter examples/03-choices-conditionals/
# Dynamic values and advanced Jinja2 example
cookiecutter examples/04-dynamic-jinja2/cookiecutter-example/
├── README.md # This file
├── LICENSE # Repo license
├── CONTRIBUTING.md # Contribution guide
├── cookiecutter.json # Behave template variables
├── hooks/ # Pre/post generation hooks
├── {{ cookiecutter.project_name }}/ # Full Behave BDD template
│ ├── features/ # Gherkin features and steps
│ ├── behave.ini # Behave configuration
│ ├── requirements.txt # Conditional dependencies
│ └── README.md
├── docs/ # Cookiecutter documentation
│ ├── 01-cookiecutter-basics.md
│ ├── 02-template-structure.md
│ ├── 03-hooks-guide.md
│ ├── 04-advanced-jinja2.md
│ ├── 05-best-practices.md
│ └── 06-creating-your-own.md
├── examples/ # Minimalist demo templates
│ ├── 01-minimal/
│ ├── 02-hooks/
│ ├── 03-choices-conditionals/
│ └── 04-dynamic-jinja2/
└── resources/ # Resources and links
├── cheatsheet.md
├── awesome-templates.md
└── tools-integrations.md
This repository includes a real template: Behave BDD Project — a base BDD test automation project using Behave, with optional support for Selenium, Requests, and Allure.
Template features:
- Variables in
cookiecutter.json:project_name,project_description,author_name,python_version,license,use_selenium,use_requests,use_allure,browser,headless,init_git. - Structure with
features/(Gherkin),features/steps/(step definitions),features/environment.py(hooks). behave.iniwith default configuration.- Pre/post generation hooks: input validation, optional git init.
- Conditional dependencies based on choices (Selenium, Requests, Allure).
See the template README at {{ cookiecutter.project_name }}/README.md.
Each example in examples/ demonstrates a specific cookiecutter concept:
| Example | Concept demonstrated |
|---|---|
01-minimal/ |
Minimum viable template structure |
02-hooks/ |
pre_gen_project.py and post_gen_project.py |
03-choices-conditionals/ |
Choice lists, conditional files |
04-dynamic-jinja2/ |
Derived values, Jinja2 filters, slugify |
See examples/README.md for details.
Full guides in docs/:
- Cookiecutter Basics — install, CLI, first template.
- Template Structure — anatomy,
cookiecutter.json,{{ }}directory. - Hooks Guide — pre/post gen, use cases, examples.
- Advanced Jinja2 — filters, conditionals, loops, macros.
- Best Practices — naming, versioning, template testing.
- Creating Your Own Template — step by step from scratch.
- Cheatsheet — quick syntax and command reference.
- Awesome Templates — curated list of community templates.
- Tools & Integrations — cookiecutter extensions, CI/CD, IDE plugins.
Contributions are welcome. See CONTRIBUTING.md.
MIT — see LICENSE.