The embedded templates (katac init) are a starting point — most of the value of katac is using it with your own katas. This page walks through scaffolding one from scratch, watching the test fail, implementing it, and watching it pass.
A trivial Add kata in Python: a function add(a, b) plus a one-line assertion test. We start with a stub that returns 0, see the test fail, replace return 0 with return a + b, and watch the test pass.
The choice of Python is incidental.
katac runshells out tomake run— what's inside the kata folder is up to you.
katac new AddThis creates katas/Add/ with a placeholder Makefile (run: echo TODO). Nothing else.
Drop three files into katas/Add/:
# katas/Add/add.py
def add(a, b):
return 0 # TODO# katas/Add/test_add.py
from add import add
assert add(2, 3) == 5
print('PASS')# katas/Add/Makefile
run:
python3 test_add.pyThe Makefile is the only piece katac cares about. Its run target can be pytest, go test, cargo test, bun test, a shell script — whatever runs your kata.
katac Addkatac copies katas/Add/ into the next days/dayN/ folder (days/day1/Add/ on the first run). From now on you work in days/day1/Add/, not in katas/. The template stays clean for tomorrow.
katac run> Running Add [1/1]
----------------------
Traceback (most recent call last):
File ".../days/day1/Add/test_add.py", line 2, in <module>
assert add(2, 3) == 5
AssertionError
make: *** [Makefile:2: run] Error 1
That's the kata: the test tells you what's expected, the failure tells you you're not there yet.
Open days/day1/Add/add.py and replace the stub:
def add(a, b):
return a + bkatac run> Running Add [1/1]
----------------------
PASS
Day 1 done. Tomorrow, katac Add again creates days/day2/Add/ from the original template — you start over, fresh.
- usage.md — the full reference:
katac.tomlconfiguration, restricting the random pool, per-kata Makefile recipes. - contributing.md — add a new embedded language template so
katac initknows about it.
