Skip to main content

TUI for identifying and removing orphaned Snowflake objects not tracked in any dbt manifest

Project description

🧹 dbt-cleaner

Find and drop Snowflake objects that no dbt manifest claims.

A terminal UI for data engineers who need to keep Snowflake clean across multiple dbt projects. dbt-cleaner compares live database objects against one or more manifest.json files and gives you an interactive way to review and generate DROP statements — with zero risk of accidentally nuking something dbt still owns.


✨ Features

🔍 Scans tables, views, materialized views, dynamic tables, external tables
📦 Supports multiple dbt projects targeting the same database
🗄️ Supports multiple target databases in a single session
🔒 Locked schemas — schemas with dbt objects are protected; only orphaned objects inside are listed
⚙️ Manual mode per schema — drop a whole schema or cherry-pick individual objects
👁️ Implicitly Dropped tab shows what CASCADE will remove before you commit
📝 Generates a ready-to-run .sql script with correct DROP statements per object type
🔌 Reads connections from ~/.snowflake/config.toml with env-var override support
🧩 Extensible connector protocol — adding Postgres or Databricks = one new file

📦 Installation

pip install dbt-cleaner

Or with uv:

uv tool install dbt-cleaner

Requires Python 3.13+.


🚀 Usage

Interactive TUI

dbt-cleaner

Pre-fill fields from the command line:

dbt-cleaner \
  --connection prod \
  --database ANALYTICS \
  --database REPORTING \
  --manifest path/to/project_a/manifest.json \
  --manifest path/to/project_b/manifest.json

CLI flags

Flag Short Description
--connection NAME -c Snowflake connection name from config.toml
--database DB -d Target database (repeatable)
--manifest PATH -m Path to manifest.json (repeatable)
--include-schema SCHEMA Only scan these schemas (repeatable)
--exclude-schema SCHEMA Skip these schemas (repeatable)

🖥️ Screen flow

Config screen  ──►  Analysis screen  ──►  Results screen  ──►  Preview screen
  connections         scans Snowflake       review orphans        SQL + save/print
  databases           parses manifests      cycle schema state
  manifests

Schema states (Results screen)

Icon State Action
Not selected No action
Selected DROP SCHEMA … CASCADE
Manual Pick individual objects to drop
🔒 Locked Schema has dbt models — protected

Press Enter or Space to cycle state. Locked schemas cannot be changed.


🔑 Snowflake authentication

dbt-cleaner reads ~/.snowflake/config.toml:

[connections.prod]
account = "myorg-myaccount"
user = "deploy_user"
authenticator = "externalbrowser"

[connections.dev]
account = "myorg-myaccount"
authenticator = "PROGRAMMATIC_ACCESS_TOKEN"
token = "..."

Environment variable overrides follow the pattern SNOWFLAKE_CONNECTIONS_<NAME>_<PARAM>:

export SNOWFLAKE_CONNECTIONS_DEV_TOKEN="my-pat-token"
export SNOWFLAKE_CONNECTIONS_DEV_USER="deploy_user"

🧠 How orphan detection works

  1. Parses all supplied manifest.json files — model, snapshot, and seed nodes only (ephemeral models and sources are excluded)
  2. Fetches all objects from target databases via INFORMATION_SCHEMA
  3. Compares on (database, schema, identifier) — case-insensitive for unquoted identifiers
  4. Classifies schemas:
    • Orphan schema — zero dbt coverage → candidate for DROP SCHEMA CASCADE
    • Locked schema — at least one dbt object → only un-tracked objects listed individually

📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_cleaner-0.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbt_cleaner-0.1.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file dbt_cleaner-0.1.0.tar.gz.

File metadata

  • Download URL: dbt_cleaner-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dbt_cleaner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98cbc28c2fcb97f3e32db0be84f87e2afeb57f50ace63b85ac3e653e77c322be
MD5 11cf53b08794b4f004e1d3ac63ece1b0
BLAKE2b-256 dffd0277411d4ccdd663c90ef68ae1febab6429c498cb0ee9db09626652af74e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbt_cleaner-0.1.0.tar.gz:

Publisher: release.yml on crugroup/dbt-cleaner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbt_cleaner-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dbt_cleaner-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dbt_cleaner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d78f991cf4747d1410e843e6dda15a9d7cdc2a1724d89467db92942e49f74aac
MD5 6483f292ba97b1fc36e8081cff1461b6
BLAKE2b-256 166822bbf07080d3e9994f737f6408c2093eb4dca959264d0374006b015c4995

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbt_cleaner-0.1.0-py3-none-any.whl:

Publisher: release.yml on crugroup/dbt-cleaner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page