Chad Fowler’s Regenerative Software treats code as disposable and the system’s knowledge as the asset. A module is safely replaceable when it can be deleted and rebuilt from knowledge that lives outside its implementation, and when the rebuilt module is judged by an oracle that outlives the code. spotregen reads that knowledge from a tracked regen/ tree and checks it against the source tree.
NoteWhat you get
A static check, spotregen check, that fails when the knowledge and the code disagree. It is deterministic and belongs in make guard.
Reports: status, deletion-test, context (the regeneration bundle), compact and new-unit.
Measures: measures (intent coverage and specification size) and mutate (mutation score: the evaluations run against planted mutants; slow, never part of make guard). See the tutorial.
Two drivers, spotregen claude and spotregen local, that regenerate a unit with an LLM. They are non-deterministic and never belong in make guard (see the drivers).
Zero runtime dependencies. The tool uses the standard library only and never imports the modules it describes; it reads source files with ast.
Install
uv add --dev spotregen # a development dependency, pinned in uv.lockuv run spotregen --help
Python 3.13 or later is required. python -m spotregen works as well.
A first check
make_sample_repo writes a minimal, consistent repository: a package samplepkg with two subpackages, one regenerable unit, one decision, one evaluation file and one documentation page. The same repository drives the test suite, the docstring examples and the tutorials.
import subprocessimport sysimport tempfilefrom pathlib import Pathfrom spotregen import make_sample_repotmp = tempfile.TemporaryDirectory()root = make_sample_repo(Path(tmp.name) /"demo")print(sorted(str(p.relative_to(root)) for p in root.rglob("*") if p.is_file()))
Run the check in that repository, as you would on the command line:
def spotregen(*args):"""Run `spotregen` in the sample repository and show the call and its output.""" done = subprocess.run( [sys.executable, "-m", "spotregen", *args], cwd=root, capture_output=True, text=True, check=False, )print("$ spotregen", *args)print(done.stdout + done.stderr, end="")print(f"[exit {done.returncode}]")spotregen("check")
The summary line regen check: N units, E errors, W warnings is stable, and the exit code is 0 when no error was found (with --strict, when no warning was found either). Break something and the check says what and where:
$ spotregen check
ERROR DEL01 samplepkg.core.calc: scripts/use_it.py depends on the unit but is not a declared consumer
regen check: 1 units, 1 errors, 0 warnings
[exit 1]
A file outside the declared consumers depends on the unit (DEL01). The check tutorial walks through this; the schema page describes the regen/ files and lists every finding code.
The package and its command line are recorded in ADR 0001. spotregen checks itself with its own static check: its regen/ tree is part of the repository.