Codebase architecture#

genop is a pure code-generation CLI: it never talks to a Kubernetes cluster itself. Every command’s job is to compute a set of file operations and apply them to disk.

Builders and FileOperation#

Multi-file code generation is organized around builders (ProjectBuilder, ApiBuilder, StepBuilder in cmd/cli/): each accumulates a slice of FileOperation values — create a file, insert at a marker, rewrite between two markers — and only writes them to disk at the end, after every builder in the chain has had a chance to contribute. genop apply runs ProjectBuilder → ApiBuilder → StepBuilder for each operator, then a shared packaging pass that regenerates Kustomize/Helm manifests from the topology.

This is why a project assembled one genop create command at a time and one rebuilt by a single genop apply end up byte-identical: both paths funnel through the same builders producing the same FileOperations.

The marker vocabulary#

Files that need machine-owned regions inside otherwise hand-editable code (main.go is the main example) use a small comment-marker vocabulary — // +genop:scaffold:<name>:begin / :end — that OpInsertAt and OpRewriteBetween operations target. Anything outside a marked region is never touched again by a later apply.

Interfaces at the consumer#

Following this repo’s own CLAUDE.md: interfaces are defined where they’re used, not next to their implementation, and are extracted only once a second implementation actually appears — genop has intentionally few interfaces for this reason.

Testing strategy#

Builder tests (builder_*_test.go) use full-rendering, not ContainSubstring guesses: every generated byte is accounted for, using golden files under cmd/cli/testdata/ for whole created files and inline string assertions for patch operations (OpInsertAt/OpRewriteBetween). See DEVELOPER.md’s “Regenerating builder golden files” section for the regeneration commands.