
The branch-based regeneration pattern
TL;DR
- Fractal regenerates onto a generator-only "vanilla" lineage, then merges it into your main branch with a real three-way merge.
- Your code lives in
custom/folders and betweenFRACTAL custommarkers, so it survives every run. - When changes overlap, you get an ordinary merge conflict, never silently lost work.
Code generators face a fundamental tension. The code has to be regenerated when the model changes, but developers need to customise that code. How do you regenerate without destroying the customisations?
Most generators handle this poorly. Either they forbid changes ("don't touch the generated code"), or they generate once and leave you to maintain everything by hand, or they need special tooling that fails at the worst possible moment.
Fractal builds on something every developer already knows: Git. Regenerated code arrives on its own branch, a three-way merge brings it together with your work, and hand-written code is clearly marked so it is never mistaken for generator output.
Every model change forces a bad choice

The usual options all hurt. Fractal takes a fourth one: a branch and a three-way merge.
Say you have generated an application and made these changes:
- Added validation logic to a command handler
- Extended a portal page
- Created a service that integrates with an external API
- Changed how a query filters its results
Now the model changes. You add an entity, change an existing one and add new commands. Time to regenerate. With traditional approaches, the options are bad:
- Regenerate and reapply by hand. Error-prone and slow, and it gets worse as the codebase grows.
- Never regenerate again. The code drifts away from the model, and every change becomes a manual change in five or ten places.
- Generate into a separate tree and copy over what you need. Two parallel codebases, which does not scale.
How Fractal regenerates without losing your work
Your code has a clearly marked home

Two homes for your code: custom/ folders the generator leaves alone, and marked blocks inside generated files.
Hand-written code lives in two kinds of places. Command handlers are scaffolded into a custom/ folder for you to fill in, and the generator leaves those files alone.
When you need to change something inside a generated file, the change goes between # FRACTAL custom begin and # FRACTAL custom end markers, so it is always clear which lines are yours.
Every regeneration arrives on its own branch

Fresh output lands on the vanilla lineage first, so you can diff and review it like any pull request before it reaches main.
When the model changes, Fractal generates the new version of the application on a branch of its own: a lineage that only ever contains generator output.
You can see exactly what changed with a normal diff, review it like any other pull request, and decide when it goes in.
A real three-way merge does the rest

Three inputs, three outcomes: your changes stay, generator changes come in, and overlaps become conflicts for a person.
Because the vanilla lineage keeps Fractal's own untouched output from the previous generation, the merge has three versions to compare: what the generator produced last time, what it produces now, and what is in your main branch.
Where you changed code, your version stays. Where only the generated code changed, the new version comes in. Where both changed in the same place, the conflict surfaces as ordinary conflict markers, left for a person to resolve on a separate branch with the tools your team already uses.
The generated project also ships with tooling that checks the custom markers are intact, so a merge cannot quietly drop a block of hand-written code.
Why it holds up in practice
Familiar: it is just Git
Every developer knows Git, and every team has a way of reviewing and merging branches. No special training is needed to understand what a regeneration did.
Visible: every change is a diff
You see exactly what changed between two generations. Code review catches problems before they reach production.
Reversible: don't like it, don't merge it
The branch exists on its own until you decide what to do with it.
Flexible: change anything, just mark it
The generated code is ordinary Python and SvelteKit. You can change anything; the markers simply record which changes are yours, so they survive the next run.
25 days in the life of a regenerated app

Generate, customise, regenerate cleanly, and handle the one real overlap like any other merge conflict.
Day 1: generate an application with Order and Customer entities.
Day 5: fill in the scaffolded handler for the CreateOrder command with stock and credit checks.
Day 20: the model changes: new fields on Order and a new ShippingAddress entity. Regenerate. The new entity, the changed Order model and the updated tests arrive on a branch; your handler is untouched, and the merge goes through cleanly.
Day 25: another model change touches the same generated code you adjusted inside custom markers. The merge keeps what it can and leaves the overlapping part as a conflict on a separate branch. You update your code to the new generated interface, resolve it like any merge conflict, and carry on.
Generation that works with Git, not around it
There is nothing magical about this pattern. It applies familiar tools, branches, diffs and merges, to a specific problem: generated code that has to keep evolving. It works because it:
- Uses tools developers already know
- Keeps all the flexibility of hand-written code
- Makes every change visible and reviewable
- Clearly marks custom code, so it can be put back after every run
- Fails gracefully, as an ordinary merge conflict, when changes overlap
When a generator works with Git instead of around it, you get both the speed of generation and the freedom of hand-written code. See how the platform works, or book a demo.