# Building an Agent That Turns DataHub Metadata Into Airflow DAGs

> Source: <https://dev.to/mark2k4/building-an-agent-that-turns-datahub-metadata-into-airflow-dags-gkk>
> Published: 2026-08-26 07:36:11+00:00

Built this with my teammate for DataHub's "Build with DataHub: The Agent Hackathon." The hackathon has wrapped up, but we're continuing to develop it.

**The problem**

If you're using DataHub, you already have lineage, freshness SLAs, PII tags, and glossary terms sitting there. But turning that into an actual Airflow DAG still means doing it by hand.

**What it does**

Give it a table name, and it:

Walks the lineage graph backwards to find every upstream dependency

Reads tags (pii, daily_refresh) and glossary terms (FreshnessSLA, EmptyLoad) on each table

Maps signals to tasks, pii → audit task, FreshnessSLA → freshness check

Topologically sorts and reduces the graph, then renders a clean, deterministic Airflow 3 DAG

Can optionally open a GitHub PR with a lineage summary

**How it's built**

Two modes: an agent mode, where an LLM (Claude, or any model via OpenRouter) explores the DataHub graph through the MCP protocol and produces a plan, and a script mode that skips the LLM entirely for CI use.

The design decision I'd love feedback on: the LLM never writes code directly. It only outputs a structured plan, and a separate deterministic renderer turns that into the actual Airflow task code. Felt like the right boundary between "useful agent" and "don't let an LLM generate arbitrary code that ends up scheduled in prod."

**Still rough around the edges**

No dbt or Spark operator support yet (just shell task stubs), no schema drift detection, and it's mostly only been tested against the DataHub NYC Taxi sample dataset so far.

**Try it**

GitHub: [github.com/tdm291104/datahub-dag-generator](//github.com/tdm291104/datahub-dag-generator)

Devpost: [devpost.com/software/datahub-dag-generator](//devpost.com/software/datahub-dag-generator)

Demo: [youtube.com/watch?v=2f0uNNmSBfc](//youtube.com/watch?v=2f0uNNmSBfc)

Feedback and contributions welcome, and if you find it useful, a star on the repo goes a long way!!!
