Skip to main content

rebake

A spiritual successor to cruft for managing cookiecutter projects.

rebake improves on cruft in two key areas:

  1. Partial apply on conflict — uses git apply --reject to apply all applicable hunks; only the unresolvable portions are saved as .rej files
  2. New variable detection — prompts for variables added to the template since the project was last updated

Requirements

  • Python 3.12+
  • uv
  • Git

Quick Start

uvx rebake check
uvx rebake update

No installation required. Uses uv.

Installation

To install permanently:

uv tool install rebake

Or add it to a project:

uv add rebake

Usage

rebake create

Bootstrap a new project from one or more cookiecutter templates and write its rebake.yaml. The first template creates the project directory; each later template is rendered into the repository root or its specified sub-path — equivalent to a create followed by one rebake add per template.

rebake create <TEMPLATE> [TEMPLATE[=TARGET] ...] [OPTIONS]

The first template's top-level Cookiecutter directory determines the generated repository name (commonly from cookiecutter.project_name). Later templates have their Cookiecutter wrapper stripped before their contents are copied into the new repository. A bare later template targets the repository root; append =TARGET to place it in a sub-directory.

Only later template arguments accept an =TARGET suffix. The first template always creates the repository root; an =TARGET suffix on the first argument is not supported.

Options

Option Description
--output-dir, -o Directory to create the project in (default: .).
--checkout Branch, tag or commit for the first template.

For later template specs, the template comes first and the split is on the last =. A URL containing = therefore needs an explicit =TARGET; use =. to place such a later template at the root. The first template is never split, so = in its URL is unambiguous.

Example — a Go scaffold at the root, a shared common template also at the root, and a DB-migration scaffold under migrate/:

rebake create https://github.com/org/cookiecutter-go \
  https://github.com/org/cookiecutter-common \
  https://github.com/org/cookiecutter-migration=migrate

When more than one link targets the same directory (typically the root), the templates are copied in argument order, so a later copy replaces an earlier file during create. Future rebake update operations do not guarantee this precedence: overlapping changes can produce .rej files. Avoid having multiple templates own the same path.

Additional links are registered with their template and target_directory only; to pin a checkout or set a name per link, edit rebake.yaml after creating (see Multiple templates).

rebake check

Check whether the project is up-to-date with its template(s). When a repository tracks multiple templates, every one is checked and the command reports each; it exits non-zero if any is outdated.

rebake check [PROJECT_DIR] [OPTIONS]

Options

Option Description
--name, -n Check only the multi-template link(s) with this name (repeatable, e.g. -n api -n batch). Defaults to all links.

Exit codes:

  • 0 — up-to-date
  • 1 — outdated
  • 2 — error (e.g. neither rebake.yaml nor .cruft.json found)

User-facing change: the stdout is now reported per template link (<template> (<target_directory>) is up-to-date.) instead of the previous single Project is up-to-date. / Project is outdated.. Exit codes are unchanged, so CI gates keep working, but scripts that grep this stdout need updating.

rebake update

Apply the latest template changes to the project.

rebake update [PROJECT_DIR] [OPTIONS]

rebake will:

  1. Abort if there are uncommitted changes (commit or stash first)
  2. Run pre-update hooks (if defined) — abort if any hook fails
  3. Detect new variables added to the template and prompt for their values
  4. Generate a diff between the old and new rendered templates
  5. Apply the diff with git apply --reject — applicable hunks are written immediately; unresolvable hunks are saved as .rej files for manual resolution
  6. Update rebake.yaml with the new commit hash and any newly added variables
  7. Run post-update hooks (if defined)

Options

Option Description
--allow-untracked-files Allow update even if untracked files exist (no other changes)
--quiet Disable interactive prompts; exit 1 if new variables are found without a supplied value
--checkout, -c Branch, tag or commit to follow. On a multi-template repo, use <name>@<ref> (e.g. go@main) to target the link named go; a bare <ref> is rejected as ambiguous
--name, -n Update only the multi-template link(s) with this name (repeatable, e.g. -n api -n batch). Defaults to all links. Orthogonal to --checkout, so they compose: --name api --checkout api@main

Hooks

Define shell commands to run before or after the update in rebake.yaml:

hooks:
  pre-update:
    - make lint          # runs before the patch is applied; abort on failure
  post-update:
    - go generate ./...  # runs after rebake.yaml is saved; abort on failure
    - make fmt

Hooks run in the project directory with the following environment variables available:

Variable Value
REBAKE_TEMPLATE Template repository URL
REBAKE_OLD_COMMIT Commit hash before the update
REBAKE_NEW_COMMIT Commit hash after the update
REBAKE_PROJECT_DIR Absolute path to the repository root
REBAKE_TARGET_DIR Absolute path to this template's target directory (REBAKE_PROJECT_DIR/<target_directory>)

For multi-template repositories, hooks run once per template link with the working directory set to that link's target directory.

Non-interactive usage (e.g. from an LLM agent)

--quiet is designed for automated workflows where interactive prompts are not possible.

# Attempt update non-interactively; exit 1 if new variables need values
rebake update --quiet

When --quiet is used and new variables are found, rebake prints each variable name and its default value to stderr, then exits with code 1.

rebake add

Register and render an additional cookiecutter template into an existing repository. This is how a repository comes to track multiple templates.

rebake add <TEMPLATE> [--project-dir REPO] [--target-directory SUBDIR] [--checkout REF]
  • <TEMPLATE> — a cookiecutter template URL or local path (anything cookiecutter accepts, e.g. https://github.com/org/repo or ./path/to/template).
  • --target-directory, -t — sub-path within the repository to render into (default: ., the repository root). This is the entry's target_directory in rebake.yaml.
    • Note: cookiecutter's top-level project-name folder is stripped, so the template's files land directly under this path.
  • --project-dir, -p — repository root whose rebake.yaml the new entry is appended to (created if absent).
  • --checkout, -c — branch, tag or commit to pin.

Example — a repository tracking a shared "common" template at its root and a Go service scaffold under api/:

rebake add https://github.com/org/cookiecutter-common     # -> repo root
rebake add https://github.com/org/cookiecutter-go -t api  # -> api/

Multiple templates

A single repository can track more than one cookiecutter template — for example a shared CI/config template at the root plus one language scaffold per sub-directory. Each template link (an entry in the templates: list) records its own commit and a target_directory (the sub-path its patches apply to). rebake check and rebake update operate on every link by default; update applies each template's diff into its own target_directory. Pass --name/-n (repeatable) to scope either command to specific links by their name — handy for opening a focused, single-subproject PR when several links have drifted at once. This mirrors reparametrize --name.

Every link is self-contained: context, checkout, skip and hooks are all per-entry, so each template keeps its own variables and hooks.

Bootstrap several links at once with rebake create, add one to an existing repository with rebake add, or hand-edit the templates: list in rebake.yaml.

Migrating from cruft

rebake reads .cruft.json as-is. No migration needed — just replace cruft with rebake in your commands.

# before
cruft check
cruft update

# after
rebake check
rebake update

rebake.yaml format

rebake writes the templates: list form (one entry per template link, even when there is only one):

templates:
  - template: https://github.com/owner/cookiecutter-common
    commit: aaa111...
    name: common            # optional: label to target this link from the CLI
    checkout: main          # optional: branch/tag/commit to track
    context:
      cookiecutter:
        project_name: my-repo
        author: Jane Doe
    skip:                   # optional: file patterns to skip
      - go.sum
      - "*.lock"
    hooks:                  # optional: shell commands to run on update
      pre-update:
        - make lint
      post-update:
        - make fmt
    # target_directory defaults to "." (repository root)
  - template: https://github.com/owner/cookiecutter-go
    commit: bbb222...
    name: go
    target_directory: api   # this link's patches apply under api/
    context:
      cookiecutter:
        project_name: my-repo

target_directory is the sub-path within your repository that the link's patches apply to (defaults to .). It is intentionally not named directory: cruft's .cruft.json uses directory for the opposite thing (a sub-directory inside the template repo), so rebake ignores that key on read and reserves the name.

name is an optional label for a link. On a multi-template repo it lets you target one link from the CLI, e.g. rebake update --checkout go@main follows main only for the link named go.

Legacy formats (read-only)

For backward compatibility, rebake also reads the older single-template top-level form and a cruft .cruft.json with the same keys. The next rebake update rewrites the file into the templates: list form above.

template: https://github.com/owner/template
commit: abc123...
checkout: main
context:
  cookiecutter:
    project_name: my-project

Development

git clone https://github.com/kitagry/rebake
cd rebake
uv sync
uv run pytest

Metadata

Release files for rebake 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rebake 0.3.0
File Size Uploaded Provenance Actions
rebake-0.3.0.tar.gz 60.2 kB With provenance Details for rebake-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rebake 0.3.0
File Interpreter ABI Platform Actions
rebake-0.3.0-py3-none-any.whl Python 3 none any Details for rebake-0.3.0-py3-none-any.whl

Total release size: 83.4 kB

Release files / rebake-0.3.0.tar.gz

Download URL rebake-0.3.0.tar.gz
Size 60.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f9acbfe6d66c376996a043a6f1bdc6dbada5898404c969dbb93a117c73a98a61
BLAKE2b-256 checksum
How to use checksums
81c2cb976b2266f0a719e4181f55afd9631a48c29e58684e24dd69e49732d180
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / rebake-0.3.0-py3-none-any.whl

Download URL rebake-0.3.0-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b4806a77d70fb56cd420a5e60de557c498bfe0ccf923f29877267dd4cebe987
BLAKE2b-256 checksum
How to use checksums
939f4721707eccdfeb9709b2f74d8d549d47abaf48956620cd1be7030815a815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for rebake 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rebake-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page