Regeneration of one unit by Claude Code (spotregen claude).
The protocol of the regeneration experiment, made repeatable. The run is blind: Claude Code could read the repository, so the driver confines it, which makes the generator memoryless. It sees the regeneration bundle, not the old module, its unit tests or the history.
The unit’s regeneration bundle is written into an empty workspace.
Only the bundle and the files named by --allow are copied into that workspace.
The generator, claude -p in restricted mode with the tools Read, Write and Edit, runs with the workspace as its only directory. It has no shell, so it can neither read the deleted module nor run the tests. Blindness is enforced, not requested.
The written module is copied into a detached git worktree of HEAD in which the original was deleted, and scored by the unit’s evaluations, then its unit tests, then its dependents inside the repository: the declared code consumers are imported and the docstring examples of the original are run against the module. On failure, the evaluation output is handed back for another attempt.
run.toml records model, CLI version, commit, hashes, attempts, the files the generator read and all three scores. The transcript and the generator’s report are kept.
--score FILE skips steps 1 to 3 and scores an existing module. --dry-run prepares the workspace and prints the generator command without calling it. An LLM call is not deterministic, so this command never belongs in make guard.
Usage::
spotregen claude core.calc --allow src/samplepkg/core/helpers.py --out /tmp/claude
--restricted removes every code-running tool and confines the file tools to the working directory; --safe-mode disables CLAUDE.md, skills, plugins, hooks and custom agents, so no project knowledge from the user’s setup reaches the generator.
Environment of the generator; with base_url, Claude Code talks to that server.
A local server with an Anthropic-compatible /v1/messages endpoint (LM Studio) serves the model. The helper-model variables point Claude Code’s background calls to the same model, and non-essential traffic (telemetry, update checks) is switched off, so neither code nor prompts leave the machine.
Every tool call: tool, path, whether it failed and whether the harness refused it.
A call is refused only when its error is the confinement message of --restricted; any other error (for example reading a directory) is a plain failure.