Skip to main content
A Bakebook is a class in bakefile.py that holds your tasks:
  • Subclass it to share tasks across projects through normal inheritance.
  • It extends Pydantic’s BaseSettings, so configuration is typed class attributes with validation, env-var and .env loading, defaults, and type coercion.
  • Tasks use the @command() decorator, same syntax as Typer.
  • ctx.run() executes CLI commands through Python’s subprocess.

Defining tasks with @command

There are two patterns, depending on whether you define the task before or after instantiating the bakebook:
  • Pattern 1: Before instantiating - Use @command() on class methods, then access context through self.ctx.
  • Pattern 2: After instantiating - Use @bakebook.command() on standalone functions, then access context through bakebook.ctx.
@command() accepts all Typer options: name, help, deprecated, and so on.
See Commands for typed arguments and decorator options, and Context for the full ctx.run reference.

Configuration with Pydantic settings

Because Bakebook extends BaseSettings, every class attribute is typed, validated configuration. Values load from environment variables, .env files, or defaults:
Tasks read settings as plain attributes (self.api_key), so configuration and the tasks that use it live in the same class. Inherited bakebooks inherit configuration too, and subclasses can override individual fields. See Settings for validation, secrets, and getting values out.

Reuse through inheritance

The point of Bakebook being a class: task libraries are just classes you inherit from.
Override a task by redefining its method. Add tasks by defining new ones. Compose task sets through multiple inheritance. No include files, no templating, no copy-paste.

Instantiating

Create a bakebook by inheriting from Bakebook or instantiating it directly:
You can also generate a starter with bakefile init or bakefile add-inline.