Skip to main content

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 typeWhat it does
merge_modelsCombine models that should be one.
dedup_modelsRemove duplicate models.
divergent_modelsReconcile models that diverged from a common ancestor.
rename_modelsRename models to a consistent convention.
apply_layeringEnforce staging / intermediate / mart layering.
improve_staging_layerClean up the staging layer specifically.
discard_modelsRemove models that are no longer needed.
build_semantic_modelsGenerate semantic-layer definitions.
organize_macrosTidy and organize macros.
remove_nested_foldersFlatten unnecessary folder nesting.
clean_project_ymlClean up dbt_project.yml.
correct_seed_structureFix seed file structure.
rebuild_configsRebuild folder-level configs.
rewrite_formatted_ymlReformat YAML consistently.

Working through tasks

Each task moves through a lifecycle you control:

  1. Plan - the pipeline proposes what the task will do; you can review and edit the plan.
  2. Approve & start - kick off execution.
  3. Execute - the agent performs the change; you can watch logs.
  4. Impact - review what changed and its downstream impact.
  5. 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:

StrategyBehavior
single_prOne PR for the whole pipeline.
batched_prGroup related tasks into batched PRs.
per_subtask_prA 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.