Refactor pipelines
Refactor is Zingle AI's flagship engine for cleaning up an existing dbt project at scale. Instead of a single chat, a refactor is a pipeline - a set of tasks organized into phases and executed in dependency order, with a human reviewing and approving each step.
The pipeline model
Configuring a refactor
Before running, you configure the refactor per repository:
- Phases - which classes of transformation to include.
- Business domains - logical groupings that guide how models are organized.
- Locked models - models the pipeline must not touch.
Task types
A pipeline is built from task types, each handled by a specialized agent:
| Task type | What it does |
|---|---|
merge_models | Combine models that should be one. |
dedup_models | Remove duplicate models. |
divergent_models | Reconcile models that diverged from a common ancestor. |
rename_models | Rename models to a consistent convention. |
apply_layering | Enforce staging / intermediate / mart layering. |
improve_staging_layer | Clean up the staging layer specifically. |
discard_models | Remove models that are no longer needed. |
build_semantic_models | Generate semantic-layer definitions. |
organize_macros | Tidy and organize macros. |
remove_nested_folders | Flatten unnecessary folder nesting. |
clean_project_yml | Clean up dbt_project.yml. |
correct_seed_structure | Fix seed file structure. |
rebuild_configs | Rebuild folder-level configs. |
rewrite_formatted_yml | Reformat YAML consistently. |
Working through tasks
Each task moves through a lifecycle you control:
- Plan - the pipeline proposes what the task will do; you can review and edit the plan.
- Approve & start - kick off execution.
- Execute - the agent performs the change; you can watch logs.
- Impact - review what changed and its downstream impact.
- Confirm / skip / retry - accept the result, skip the task, or retry it. You can also fast-forward through tasks.
Pipelines can be resumed or cancelled, and you can always see the current task and the full task tree.
Pull-request strategies
How changes land in GitHub is configurable:
| Strategy | Behavior |
|---|---|
single_pr | One PR for the whole pipeline. |
batched_pr | Group related tasks into batched PRs. |
per_subtask_pr | A PR per subtask for the finest-grained review. |
When to use Refactor vs Optimize
- Use Refactor for structural change - reorganizing, renaming, merging, re-layering, and building the semantic layer.
- Use Optimize to scan for discrete issues (performance, materialization, DRY, tests) and apply targeted fixes.